tomstewart89 / BasicLinearAlgebra

A library for using matrices and linear algebra on Arduino
MIT License
187 stars 38 forks source link

Multiplying a Matrix times a scalar #9

Closed keithmgould closed 7 years ago

keithmgould commented 7 years ago

Motivation: In an effort to do x_hat_new = A*x_hat + B*u

The A*x is easy since both are matrices.

I'd like to do something like:

Matrix<3,1> B, foo;
B << 1,2,3;
float u;
u = 0.5;
foo = B * u;
// or even:
ScalarMultiply(B, u, foo);
// where foo is now {{0.5},{1},{1.5}}

I suspect this is not possible given BLA's current state. If its possible let me know, otherwise I'd be happy to write a PR.

tomstewart89 commented 7 years ago

As of fairly recently this is supported along with elementwise addition subtraction and division. You can call them through the operators or use ElementwiseMultiply etc to save a bit of overhead.

Let me know you have problems!

keithmgould commented 7 years ago

Ah fantastic. Works great. I got lazy and did not read through source. Looks like it is not in readme (unless I missed it?) Want a PR augmenting?

tomstewart89 commented 7 years ago

Sure! I'm not one to turn down a good PR!