manual:chapter5:listproc

This is an old revision of the document!


Parallel processing is the idea that, generally, if a command can be applied to one or more individual arguments, then it can also be extended to be applied to one or more sets of arguments.

As a rule-of-thumb, a given command can use parallel list processing if all the following are true:

  • The command checks for valid argument types. Commands that apply to all object types, such as DUP, SWAP, ROT, and so forth, do not use parallel list processing.
  • The command takes exactly one, two, three, four, or five arguments, none of which may itself be a list. Commands that use an indefinite number of arguments (such as →LIST) do not use parallel list processing.
  • The command isn’t a programming branch command (IF, FOR, CASE, NEXT, and so forth).

The remainder of this chapter describes how the many and various commands available on the calculator are grouped with respect to parallel processing.

A command must take arguments before it can parallel process, since a zero-argument command (such as DEPTH, VARS, or RAND) has no arguments with which to form a group.

This group of commands cannot use parallel processing directly, but can be “coerced” into it using the DOLIST command (see Using D later in this appendix). This group consists of several subgroups:

  • Stack manipulation commands A stack manipulation command cannot parallel process because the stack is manipulated as a whole and list objects are treated the same as any other object. Stack commands (such as DROP) that take level 1 arguments will not accept level 1 list arguments.
  • Commands that operate on a list as a whole. Certain commands accept lists as arguments but treat them no differently than any other data object. They perform their function on the object as a whole without respect to its elements. For example, →STR converts the entire list object to a string rather than converting each individual element, and the == command tests the level 1 object against the level 2 object regardless of the objects’ types.
  • List manipulation commands. List manipulation commands will not parallel process since they operate on list arguments as lists rather than as sets of parallel data. However, a list manipulation command can be forced to parallel process lists of lists by using the DOLIST command. For example,
    { { 1 2 3 } { 4 5 6 } }
    1
    « ΠLIST »
    DOLIST

    returns { 6 120 }.

  • Other commands that have list arguments. Because a list can hold any number of objects of any type, it is commonly used to hold a variable number of parameters of various types. Some commands accept such lists, and because of this are insensitive to parallel processing, except by using DOLIST.
  • Index-oriented commands. Many array commands either establish the size of an array in rows and columns or manipulate individual elements by their row and column indices. These commands expect these row and column indices to be real number pairs collected in lists. For example,
    { 3 4 }
    RANM

    will generate a random integer matrix having 3 rows and 4 columns. Since these commands can normally use lists as arguments, they cannot perform parallel processing, except by using DOLIST.

  • Program control commands. Program control structures and commands do no perform parallel processing and cannot be forced to do so. However, programs containing these structures can be made to parallel process by using DOLIST. For example,
    { 1 2 3 4 5 6 }
    1
    « IF 
        DUP 3 ≤
      THEN
        DROP
      END
    »
    DOLIST

    returns { 4 5 6 }.

FIXME

FIXME

Commands that store values in system-specific locations so as to control certain modes and machine states can generally be used to parallel process data. The problem is that each successive parameter in the list cancels the setting established by the previous parameter. For example,

{ 1 2 3 4 5 }
FIX

is effectively the same as

5
FIX

These commands are the easiest to use with parallel processing. Simply provide the command with a list of arguments instead of the expected single argument. Some examples:

  • { 1 -2 3 -4 }
    ABS

    returns { 1 2 3 4 }.

  • DEG
    { 0 30 60 90 }
    SIN

    returns { 0 .5. .866025403784. 1 }.

  • { 1 A 'SIN(Z)'}
    INV

    returns { 1 'INV(A)' 'INV(SIN(Z))' }.

Two-argument commands can operate in parallel in any of three different ways:

  • { list } { list }
  • { list } object
  • object { list }

In the first form, parallel elements are combined by the command:

{ 1 2 3 }
{ 4 5 6 }
%

returns { .04 .1 .18 }.

In the second form, the level 1 object is combined with each element in the level 2 list in succession:

{ 1 2 3 }
30
%CH

returns { 2900 1400 900 }.

In the third form, the level 2 object is combined with each element of the level 1 list in succession:

50
{ 1 2 3 }
%T

returns { 2 4 6 }.

Commands that take multiple (3, 4, or 5) arguments can perform parallel processing only if all arguments are lists. For example, { 'SIN(X)' 'COS(X)' 'TAN(X)' } { X X X } { 0 0 0 } ROOT returns { 0 90 0 }. Notice that lists must be used even though the level 1 and level 2 lists each contain multiples of the same element. FIXME

  • manual/chapter5/listproc.1570050790.txt.gz
  • Last modified: 2019/10/02 14:13
  • by jojo1973