sloisel / numeric

Numerical analysis in Javascript
http://www.numericjs.com/
Other
1.42k stars 177 forks source link

Problems solving Ax=b #10

Open ghost opened 11 years ago

ghost commented 11 years ago

Hello there,

I am relatively new to linear algebra, but I think I may have spotted a bug. When using numeric.solve(A, b), it appears b can only be a column vector. Should it not also be allowed to be a rectangular matrix?

For instance:

A is 3x3 matrix b is 3x1 vector numeric.solve(A, b) returns the expected x vector

But:

A = 3x3 matrix b = 3x2 matrix numeric.solve(A, b) returns vector of NaN.

While one could just use numeric.dot(numeric.inv(A), b) to get the same result, I feel it should be part of the solve function. My apologies if I am incorrect here, I just thought it was worth mentioning.

Thanks for reading, Richard.

sloisel commented 11 years ago

You are correct, the b parameter in numeric.solve(A,b) must be a vector, although that's not a bug, that's just the way it's implemented. I will try to improve this in the future.

ghost commented 11 years ago

Ok that's fair enough, sorry I am new to this stuff and don't understand it all conceptually yet. Thank you for the reply.