coding style

In my opinion the used programming style makes reading and understanding the
code harder than necessary.
For example SymmetricMatrix_Wrapper::cholesky_semidefinite is hard too read.
Check line 21 (2 operations on 1 line), line 28 (no { used), line 31 (too
complex)

Another example of unnecessary hard to readible code is
SymmetricMatrix_Wrapper line 141 - 157.
Currently:
for (i= cols < rows ? cols: rows; i>=1; i--) {
ppi=i+1;
g=w(i);
for( j=ppi; j<=cols ; j++) U(i,j)=0.0;
if (g) {
g=1.0/g;
for ( j=ppi; j <= cols; j++) {
for( s=0.0, k=ppi; k<=rows ; k++) s += U(k,i)*U(k,j);
f=(s/U(i,i))*g;
for ( k=i; k <= rows;k++) U(k,j) += f*U(k,i);
}
for( j=i; j<=rows ; j++) U(j,i) *=g;
} else {
for( j=i; j<=rows ; j++) U(j,i) = 0.0;
}
++U(i,i);
}

I would change it in to:

for (i= cols < rows ? cols: rows; i>=1; i--) {
ppi=i+1;
g=w(i);
for( j=ppi; j<=cols ; j++) {
U(i,j)=0.0;
}
if (g) {
g=1.0/g;
for ( j=ppi; j <= cols; j++) {
for( s=0.0, k=ppi; k<=rows ; k++) {
s += U(k,i)*U(k,j);
}
f = (s/U(i,i))*g;
for ( k=i; k <= rows;k++) {
U(k,j) += f*U(k,i);
}
}
for( j=i; j<=rows ; j++) {
U(j,i) *=g;
}
} else {
for( j=i; j<=rows ; j++) {
U(j,i) = 0.0;
}
}
++U(i,i);
}

Some times style is very personal, but a clear, consistent code style makes
the code better to understand.
There are (linux) tools which can help to provide a consistent coding style.

With best regards,

Jürge
_______________________________________________
I hereby promise not to top-post on the
BFL mailing list
BFL [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/bfl

coding style

On Tue, Sep 1, 2009 at 9:33 AM, Jurge van Eijck
<jurge [dot] van [dot] eijck [..] ...>wrote:

> In my opinion the used programming style makes reading and understanding
> the
> code harder than necessary.
> For example SymmetricMatrix_Wrapper::cholesky_semidefinite is hard too
> read.
> Check line 21 (2 operations on 1 line), line 28 (no { used), line 31 (too
> complex)
>
....

>
>
> Some times style is very personal, but a clear, consistent code style makes
> the code better to understand.
> There are (linux) tools which can help to provide a consistent coding
> style.
>
> Thanks for the suggestions.
However, I would be even more happy to receive patches for them :).

Tinne
_______________________________________________
I hereby promise not to top-post on the
BFL mailing list
BFL [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/bfl