LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arithmetic performance

For some signal processing code (to be used in LV RT, but that should not matter), I get some input data as single data from the AI buffered read.vi and have to deliver as single data to AO buffer write.vi. In between, I build arrays of the data, do matrix computations and have to do also some complex computations.

As many of the linear algebra vis are not available for single types (single or complex single), I have to use them for the double types.

Now, my question: Are there some general rules or recommendations on how and where to make the type casts? For example,
a) is it more useful to do the type casts directly after/before I/O operations to avoid additional casts or to do them more close to the computations to save memory for interme
diate data arrays?
b) Is it more useful to use a complex representation for real data in order to avoid implicit type casts at mixed real/complex computation vis or is it more useful to save the memory for the unnecessary imaginary part?

Target processor will be a PIII with Labview RT 7 in this special case and my problem is time critical, not so much memory limited.

Any hint is welcome!

Regards,

acoustics
0 Kudos
Message 1 of 4
(2,820 Views)
> Now, my question: Are there some general rules or recommendations on
> how and where to make the type casts? For example,
> a) is it more useful to do the type casts directly after/before I/O
> operations to avoid additional casts or to do them more close to the
> computations to save memory for intermediate data arrays?
> b) Is it more useful to use a complex representation for real data in
> order to avoid implicit type casts at mixed real/complex computation
> vis or is it more useful to save the memory for the unnecessary
> imaginary part?
>

In general, you want to avoid changing types back and forth. Both
explicit conversions and automatic coercion dots almost always represent
additional storage. It is sometimes possible to put the coercion ins
ide
a loop to avoid building a large buffer that then needs to be converted.
But in general, it is best to look for the most common type and go
with it. You can also use the profiler to get a better idea of how much
is being used in order to make your experiments make more sense.

If you want more details, post pictures and more detailed questions.

Greg McKaskle
0 Kudos
Message 2 of 4
(2,820 Views)
Hello Greg,

thanks for your reply. My core problem is:
I have a real valued single vector (measurement data) and a complex double matrix to multiply. Size: vector about 10 elements, matrix about square 10x10.

Which is the most efficient way to compute in LV? There seems to be no explicit real times complex and I do not know, how coercion is done in detail (e.g. explicitly with memory movements or implicitly during loading in Pentium FP registers).

Regards,

acoustics
0 Kudos
Message 3 of 4
(2,820 Views)
> I have a real valued single vector (measurement data) and a complex
> double matrix to multiply. Size: vector about 10 elements, matrix
> about square 10x10.
>
> Which is the most efficient way to compute in LV? There seems to be no
> explicit real times complex and I do not know, how coercion is done in
> detail (e.g. explicitly with memory movements or implicitly during
> loading in Pentium FP registers).
>

The VI for matrix vector multiplication could be used to muliply the
vector times the real and imaginary parts of the complex matrix, then
recombined. Or you could use a loop to iterate through the rows or
columns of the matrix, then multiply by the vector and sum the result to
create the item for the output vector. The vec
tor will be accumulated
using autoindexing on the loop. If you only want the real portion of
the output, do the cast inside the loop. At least that is what I think
you want to do. You will have to pardon my rusty linear algebra.

As for which will be more memory efficient, it is hard to say since I
still don't know for sure what you want as an output. With only ten
elements in the vector, we aren't talking about much memory in either
case. Both solutions should take ten minutes to whip up and compare in
terms of performance and/or memory usage. Typically the faster will
also use less memory in this sort of VI. Avoid using local variables or
other items and you should be fine.

By the way to time this, you will likely need to do the multiplication
10 or 100 thousand times to get a decent elapsed time for the PC clock
resolution.

Greg McKaskle
0 Kudos
Message 4 of 4
(2,820 Views)