@exception IllegalArgumentException if <tt>B.rows() != A.rows()</tt>.
@exception IllegalArgumentException if <tt>!isSymmetricPositiveDefinite()</tt>.
*/
public DoubleMatrix2D solve(DoubleMatrix2D B) {
// Copy right hand side.
DoubleMatrix2D X = B.copy();
int nx = B.columns();
// fix by MG Ferreira <mgf@webmail.co.za>
// old code is in method xxxSolveBuggy()
for (int c = 0; c < nx; c++ ) {
// Solve L*Y = B;
for (int i = 0; i < n; i++) {
double sum = B.getQuick( i, c );
for (int k = i-1; k >= 0; k--) {
sum -= L.getQuick(i,k) * X.getQuick( k, c );
}
X.setQuick( i, c, sum / L.getQuick( i, i ) );
}
// Solve L'*X = Y;
for (int i = n-1; i >= 0; i--) {
double sum = X.getQuick( i, c );
for (int k = i+1; k < n; k++) {
sum -= L.getQuick(k,i) * X.getQuick( k, c );
}
X.setQuick( i, c, sum / L.getQuick( i, i ) );
}
}
return X;
}