National Instruments AutoCode NI MATRIX User Manual

Page 209

Advertising
background image

Chapter 7

Code Optimization

AutoCode Reference

7-18

ni.com

If you have decided on the MatrixRightDivide block, the tips for optimizing
the inputs are much the same as for the MatrixInverse block. In this case
there are two inputs, A and B, and both are modified by the callout
algorithm. Thus, a copy-in must occur for each input. Again, you cannot
avoid the copy-in, but you can get tighter code with good input connectivity
because the code will be looped rather than unrolled.

If you cannot avoid using the MatrixLeftDivide block, you should know
how to cause it to be generated with maximum optimality. This block has a
built-in optimization that kicks in when the B matrix (from AX=B) is a row
or column vector. When this built-in optimization is active, both the A and
B inputs are modified by the callout algorithm and each must be subjected
to a copy-in. Good input connectivity will let you generate looped rather
than unrolled code, but the copy-in cannot be avoided. Furthermore, the
disadvantage to using the MatrixLeftDivide block does not apply with the
optimization active.

If your B matrix is not a row or column vector, then the algorithm must
do an internal transpose-copy. Under these circumstances, the A input is
modified by the algorithm, but the B input is not. Thus, the copy-in is
unavoidable for the A input but will only be present for the B input if you
have bad connectivity.

For this reason, it is very important when dealing with a MatrixLeftDivide
that has a true matrix (not 1

× n or n × 1) as B that you have good input

connectivity—just as important as the rule mentioned earlier about
applying to all three callout blocks encouraging good output connectivity.
In this case, good input connectivity for B means that B can be taken in
place from the source matrix.

For a summary of inputs and outputs for callout blocks, refer to Table 7-1.

Advertising