# COLREDUCE

## Purpose:

Applies the REDUCE function to each column of a table.

## Syntax:

COLREDUCE(a, "op", opcode)

 a - An array with one or more columns. "op" - Optional. A string, the binary operator name. opcode - Optional. An integer, the binary operator function code.

## Returns:

A one-row table with the same number of columns as the input table.

## Example:

W1: {{1, 2},

{2, 3},

{3, 4}}

W2: colreduce(W1, "+")

returns {{6, 9}} the result of summing each column of W1.

## Example:

colreduce(ravel({1, 2, 3},{2, 3, 4}), "*")

returns {{6, 24}}

## Example:

colreduce(ravel({1, 2, 3},{2, 3, 4}), 3)

returns {{6, 24}}

## Remarks:

Binary 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