Concerns about MatrixMath.h Library

This is a fantastic library, however I am concerned why it requires matrices to be casted to float* for each function? I am not sure, but I believe this is very demanding on the micro, in terms of process time.

I ask this question because I am doing matrix math in real-time (for state-space modelling). I hardly use pointers so I am unaware why they are used here.

Are you referring to the float* in the function definitions, such as this one?:

void MatrixPrint(float* A, int m, int n, String label);

If so, it just means that you pass the address of the matrix A to the function. e.g. you might have a code snippet like this:

float A[3][5];
.
.
.
MatrixPrint(A, 3, 5, String("whatever"));

[+edit] i.e. the name of the array is already the address of the array. No cast needed.

Pete

It also means that your arrays should be floats already. What kind of arrays are you using?

I followed the example that was provided in the library.

For instance, if I have 2 matrices,

const double A[2][2] = {
 {1.95, -0.9512},
 {1, 0}
};

const double B[2][1] = {
 {1},
 {0}
};

And variable matrix,

double temp[2][1] = {
 {0},
 {0}
};

Using the library, I would multiply them and store the result into temp[][],

Matrix.Multiply((float*)A, (float*)B, 2, 2, 1, (float*)temp);

In my application, I require values in my matrices with precision of at least 8 decimal places.

This thread is ultimately leading to, what appropriate data types can I use with this library.

On the Arduino float == double. And 8 significant float figures is pushing it.

Which Arduino are you using? On Nano/UNO and similar, a double is the same as float (single precision).
But, if the library uses float, you aren't going to get the precision you need. The precision of float is only about 7 digits.

Pete

KeithRB:
On the Arduino float == double. And 8 significant float figures is pushing it.

Yes, thank you, I realized the float == double. I haven't finished my state space modelling and in most cases the precision I need is 4 decimal places. I can prevent my model from requiring such precision.

el_supremo:
Which Arduino are you using? On Nano/UNO and similar, a double is the same as float (single precision).
But, if the library uses float, you aren't going to get the precision you need. The precision of float is only about 7 digits.

Pete

I am using an Arduino Due. Thank you for letting me know.

OK. AFAIK, on the Due, "double" is double precision. But if the library uses float internally, that's not going to help you.

Pete

Though it should be pretty easy to re-write the library for double. Search and replace should do it.