AnsweredAssumed Answered

VRf-Recursive_Computations

Question asked by VRFuser on Aug 21, 1997



[VEE] Iterative Computations In VEE

* A customer had an interesting query on HP VEE ... he wanted to compute
recursive equations, for example:

   X(n) = X(n-1) + B*U(n)

-- where X and U are vectors (1D arrays) and B is a real scalar.  I tend to
like queries like these, since they are a lot more fun to deal with than most
problems and make useful topics for articles.

The answer to this query isn't hard in the absolute sense, but it's one of
those things which requires having your brain pretty well wrapped around VEE
-- and so it also makes an excellent tutorial example.

In any case, the solution is as follows:

                                                           +--------------+
                                                           | AlphaNumeric |
                                                           +--------------+
             +-------------------------------------+       | 0: 9         |
   +------+  |                                     |       | 1: 21        |
   | Init |  +-->+-----+                           |   +-->| 2: 87        |
   +------+      | JCT +--+                        |   |   | 3: 87        |
   | 0    +----->+-----+  |                        |   |   | 4: 87        |
   +------+ Real          |                        |   |   | 5: 87        |
                          |   +-----------------+  |   |   +--------------+
   +------+               |   |     Formula     |  |   |
   |  B   |               |   +---+-------------+  |   +--------------+
   +------+               +-->| X |             |  |                  |
   | 3    +------------------>| B | X + B*U[N]  +--+-->+-----------+  |
   +------+ Real      +------>| U |             |      | Collector +--+
                      |   +-->| N |             |  +-->+-----------+  
                      |   |   +---+-------------+  |                  
                      |   |                        |
   +---------------+  |   |                        +------+
   |       U       |  |   |                               |
   +---------------+  |   +----------------------------+  |
   | 0000: 3       |  |                                |  |
   | 0001: 4       |  |   +---------+   +-----------+  |  |
   | 0002: 6       +--+-->| TotSize +-->| For Count +--+  |
   | 0003: 12      |      +---------+   +-----+-----+     |
   | 0004: 3       |                          |           |
   | 0005: 1       |                          +-----------+
   +---------------+ Real

This program works as follows:

% There are three Real Constants driving the program:  an initial value for
   X, the constant B, and the constant array U.

% The output array X is produced dynamically by a collector that obtains
   the results of each iteration of the computation.

% The number of iterations is given by the size of the array B (through the
   Totsize() function); this is the same as the size of the output array
   X.  The size is loaded into a For Count object, which drives the
   computation through its iterations and then fires its Sequence Out pin
   when done.

% A Formula box performs the actual computation, X + B*U[N].  The input pin
   X is fed through a Junction that connects to the Init constant (for the
   initial value in the first iteration) and to the output of the Formula
   itself (for all other iterations).

% The outputs of the Formula box are also put into an array by a Collector
   and then output when the For Count object reaches the end of its count.

Note that if you are using feedback loops in versions of VEE before 4.0, you
will need to put a Start button on the Init object ... it was one of the
eccentricities of VEE that it insisted on having one for feedback loops.

[<>]

Outcomes