10-27-2025 12:23 PM - edited 10-27-2025 12:28 PM
I am multiplying two matrix against each other. I am getting strange results and I am hoping that someone can tell me why. When I multiply Sigma_reg and Sigma_inv i get this result:
When I probe I do see all of the decimals. but the result is 1 with no following decimals:
The strange thing is that I when I just multiply these two numbers I get this value. This is what I expect to see when index 0 is multiplied by index zero:
I am missing my decimals. I always get a one. Any thoughts?
Solved! Go to Solution.
10-27-2025 12:31 PM
I would start with attaching your code containing your shown default values.
(What datatypes are there (2D array, matrix?) and what functions are you using?)
10-27-2025 12:33 PM
Why does Sigma_inv show '-0' in the bottom row? Is there actually data there that's not being fully shown?
Works fine for me:
10-27-2025 12:41 PM
Here is my VI
10-27-2025 12:50 PM
Here is a simple version
10-27-2025 01:06 PM - edited 10-27-2025 01:09 PM
First of all, you need to be careful. An element-by-element multiplication (your loop stack!) of two matrices is only the same as AxB if both matrices are diagonal.
The inverse of a diagonal matrix is a diagonal matrix with the diagonal containing the inverse of each original element.
In general, a matrix inverse is a complicated process, and numerical instabilities can sneak in. If you know your matrix is diagonal, do as follows:
While A-B is zero her, that -0 in your case is suspicious.
I am pretty sure that LabVIEW is using well known libraries (e.g. MKL) for matrix inversion, so there is really nothing they can do.
10-27-2025 01:10 PM
I did try multiplying the two using multiply matrix and got the same result. I only added the for loop after I got an unexpected result. I will try try your method. The issue is that it seems that the numbers are coming out other than double. Did you look at my simple version when I used number to multiply and the results of index 0 for both arrays to get the answer. There is something wrong with that.
10-27-2025 01:24 PM
OK I built it your way and I am still not seeing the decimals from the multiply. Am I doing something wrong?
10-27-2025 01:29 PM
The example image in your first post where you're getting 1.000000778040 is because you're missing a lot of the decimals from the true values. LabVIEW truncates to 6 sig figs by default. Crank the number of sig figs way up and you can see the true values do indeed equal 1.0:
10-27-2025 01:34 PM
In the x*y I never see my decimals. You are not seeing them either. Look at the difference between the first x*y and x*y 2. Why are they not the same?