LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

single precision matrix multiplication

Hello, I need to speed up some computations based on matrix multiplications. I don't need a very high precision, so the conversion in to a single point values could be a solution... BUT ... I didn't find any function that enables to multiply 2D array and 1D array or corresponding matrices in single-precision (everything works with doubles). Is there any existing solution?

Thank you!

Lukas
0 Kudos
Message 1 of 17
(5,336 Views)

Hi Lukas,

In LV, almost all the primitives are polymorphic, so it can accept SGL precision matrices for Multiplication, Division, etc.

Just you need to wire the matrix of your preferred datatype to the function so that it adapts itself automatically.

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 2 of 17
(5,331 Views)
Sorry, I forgot that Matrices can be of only 2 datatypes, viz, DBL & CLX.
 
Also, arrays of 2 different dimeansions cannot be multiplied directly in LV. You have to code it in a manual way.
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 3 of 17
(5,328 Views)
Thank you for your response, Partha.

I don't know exactly what you mean by "
code it in a manual way." You mean to construct my own multiplication function? I can imagine to do this by some SubVI, but I'm not sure about the code efficiency. The result can be even slower then using a LV real-matrix multiplication Smiley Sad
I have also tried to use standard multiplication of 2 arrays, but it calculates something different (attached file)....

Lukas
0 Kudos
Message 4 of 17
(5,316 Views)
Hi Lukas,

you can use standard multiplication node for matrix datatypes too... Have you tried this before? (See attachment)
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 17
(5,303 Views)
Hi GerdW,

Thank you for your response;  Sorry, the VI a have attached was maybe a little bit confusing. It was meant just for the demonstration that those two ways of multiplication don't have the same result. The problem to discuss is that I can't use the matrix data type for single precision multiplication (it is double).
In brief - I need to decrease the precision to "single" because of the computational speed in real-time, but I don't know how to perform the matrix multiplication (or matix and vector).

Lukas
0 Kudos
Message 6 of 17
(5,296 Views)
Those functions call a DLL, so I think the only way to do what you want is to write your own function that performs those computations in SGL instead of DBL.
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 7 of 17
(5,290 Views)
This is exactly the thing I was afraid of Smiley Sad

Thank you, TWGomez
0 Kudos
Message 8 of 17
(5,285 Views)
FYI, some of the computations can be found in the help files and examples...
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 9 of 17
(5,278 Views)

A matrix multiplication in mathematically quite trivial, so it should not be very difficult to just make your own.

Here's the generic 2Dx2D matrix multiplication. To adapt to your problem, make the 1D "B" column vector into a single column 2D array as in the above examples or simplify the code in some other way to deal directly with teh 1D array. Shouldn't be very hard. :).

(You still need to add error handling if the dimensions don't match! Right now it just gives you a truncated result).



Message Edited by altenbach on 04-08-2008 07:52 AM
Download All
0 Kudos
Message 10 of 17
(5,253 Views)