NAME
for_op -- unit to iterate operands
PROTOTYPE
unitptr for_op( int nu, int ni, char *pcFmt, unitptr uHost)
ARGUMENTS
- int nu
- ABS(nu)=number of successor units to iterate.
- int ni
- number of iterations
- char *pcFmt
- option string (see below)
- unitptr uHost
- host unit
RETURN VALUE:
A pointer to the created unit or NULL in the case of an error.
INTERFACE OF CREATED UNIT:
- X_in[1]
- index limit. The for_op will iterate its operands for
integer index values 0=< i < X_in[0].
- out_0[1]
- current iteration index; operands are iterated
for all integer index values out_0[k]
between 0 and X_in[0]-1, inclusive.
DESCRIPTION:
This unit is provided to perform repeated iterations of its
nu successor units in the exec-queue. These will become
operands of the for_op unit.
EXECUTION:
An
exec call to the for_op unit will have the effect
to iterate its nu successors over all integer index tuples
in the range given by 0..X_in[0](with the latter
limit excluded).
Changes to the input field of this unit are only noticed
before or after the iterations are executed (i.e., changes
to the input fields effected by the iterated operands take
only effect after the last iteration has been completed).
By specifying the %a option (``exec+adapt'' in NEO), the
for-iterations will include adaptation steps according to the
pattern
for (i=0; i<steps; i++) {
exec_unit(Operand_1) ... exec_unit(Operand_nu);
adapt_unit(Operand_nu) ... adapt_unit(Operand_1);
}
In this case, no further adaptation calls to the operands
will be made during
the adapt_unit() call for the for_op.
ADAPTATION:
Usually, the or_op unit does not adapt its operand units.
Adaptation must be explicitly enabled by setting options.
As explained above, the %a will provide adaptation during
the exec_unit call for the for_op unit. The following two
options will enable adaptation for the operands of the for_op unit
when the adapt_unit call is made.
- %A
- (``adapt1'' in NEO) adapt_unit() acts as if
for (i=0; i<ABS(nr); i++) {
adapt_unit(Operand_nu) ... adapt_unit(Operand_1);
}
- %p
- (``adapt2'' in NEO)
modifies %A-option by prefixing each adapt_unit(operand) with a
exec_unit(operand), ie. now adapt_unit() acts as if
for (i=0; i<ABS(nr); i++) {
exec_unit(Operand_nu); adapt_unit(uOperand_nu)
...
exec_unit(Operand_1); adapt_unit(Operand_1)
}
If the iterated units contain an adaptable unit, each adapt should usually
be prefixed by an exec-call, i.e., the %p - mode should be used.
If neither of %A or %p is present, the adapt_unit() call is
without any effect.
NOTE:
This unit supersedes the older for_loop unit, which should no longer
be used for new work.
SEE ALSO:
multi_for_op, iterator
FILE
/homes/jontrup/nst5/man/../o.sol2//../nstsrc/nst_stdr.c