DADiSP Worksheet Functions > Function Categories > Matrix Math and Special Matrices > INTERPOSE

 

INTERPOSE

Purpose:

Inserts an operator between every observation in a series, then evaluates associatively, producing a vector of successive intermediate results.

Syntax:

INTERPOSE(a, "op", opcode)

 

a

-

A rectangular array

"op"

-

Optional. A string, the binary operator.

opcode

-

Optional. An integer, the binary operator function code.

Returns:

An array or series.

Example:

interpose({2, 3, 4}, "*")

 

produces the series {2, 6, 24} by expanding to the expression (((2) * 3) * 4), and evaluating associatively, producing one value for each pair of parentheses.  The binary operator is specified as a function string, "*".

Example:

interpose({2, 3, 4}, 3)

 

returns the series {2, 6, 24}. In this case, the binary operator is specified as a function code, i.e. the value 3 representing multiplication.

Example:

W1: ravel(1..9, 3)

W2: interpose(W1, "+")

W3: colreduce(W1, "+")

 

W1 == {{1, 4, 7},

       {2, 5, 8},

       {3, 6, 9}}

 

W2 == {{1,  4,  7},

       {3,  9, 15},

       {6, 15, 24}}

 

W3 == {{6, 15, 24}}

 

Each row of W2 is the partial result of adding the row value to the running sum. The last row of W2 is equal to the result of COLREDUCE in W3.

Remarks:

Operators include the arithmetic and logical operators. The logical "Exclusive OR" operator is represented by the string "XOR".

 

The function also accepts an explicit function code instead of an operator string. Either an operator string or function code must be supplied.

 

The following function codes are supported:

 

Code

Operator

Function

Description

1

+

ADD

add

2

-

SUB

subtract

3

*

MULT

multiply

4

/

DIV

divide

5

^

POW

raise to power

6

>

GREATER

greater than

7

<

LESS

less than

8

>=

GREATEREQ

greater or equal to

9

<=

LESSEREQ

less or equal to

10

==

EQUAL

equal to

11

!=

NOTEQUAL

not equal to

12

&&

AND

logical and

13

||

OR

logical or

14

XOR

XOR

logical exclusive or

15

FLIPFLOP

FLIPFLOP

dual pad flipflop

16

ATAN2

ATAN2

inverse tangent

17

&

BITAND

bit and

18

<<

BITLSHIFT

bit left shift

19

>>

BITRSHIFT

bit right shift

20

|+

BITOR

bit or

21

%

MOD

modulo

22

|^

BITXOR

bit exclusive or

23

~

BITCOMP

bit complement

24

MAKECART

MAKECART

convert to Cartesian form

25

MAKEPOLAR

MAKEPOLAR

convert to polar form

26

MAX

MAX

maximum

27

MIN

MIN

minimum

 

See Also:

INNERPROD

OUTERPROD

REDUCE