Description

Reduces one dimension of a multi-dimensional data array by combining all elements along the given dimension using a specified operator.

Return Type

A McObject object.  

A McObject of the same type as the NDimArray argument with one dimension reduced. If NDimArray has more than 1 dimension, the returned object will have one less dimensionality; if NDimArray is a 1-D vector, the returned object will be a length-1 array. The returned object will have a “standard” shape (slowest moving dimension VAR, all others FIX'ed size).

Syntax

object.McReduce (NDimArray, [Operator], [DimToReduce])

The McReduce Method syntax has these parts:

PartDescription
objectAn expression evaluating to an object of type McOMGlobal.
NDimArrayRequired. A Variant value.

May be a scalar or array of any numeric type. It may also be a McObject instance of a numeric type.

OperatorOptional. A String value.

The binary operator to be used for the reduction. The allowed values are given in the following table. The default is “+”, that is summation.

"*" multiply.
"+" addition.
"<>"    smaller of ("min" is also accepted).
"><"    larger of ("max" is also accepted).
"&" bitwise AND,  integral types only.
"|" bitwise OR,  integral types only.

DimToReduceOptional. A Long value.

The number (0 is the slowest moving dimension, the leftmost in C and the rightmost in VB) of the dimension to be reduced. By default the value is -1, which indicates that the fastest moving dimension (right-most in C, left-most in VB) dimension is to be reduced.

Remarks

The returned object has the same shape as the original object, less the reduced dimension. For example, for a two dimensional matrix, mA (declared mA[N][M] in C or Dim mA(0 to M-1, 0 to N-1) in VB), reduced with a “+” operation along dimension 0 (slowest moving dimension; the leftmost in C, or the rightmost in VB) the return value is a 1-dimensional array vB[M] where each element is created so that (in C syntax),

vB[m] = mA[0,m]+mA[1,m]+...+mA[N-1,m] for m, 0 to M-1 (i.e., the slowest moving, row dimension of mA was “reduced” by adding together all rows). A similar reduction along dimension 1 (the “column” dimension) would return a vector of length N, with all columns added together. In VB syntax, the reduction would look like

vB(m) = mA(m,0)+mA(m,1)+...+mA(m,N-1) for m, 0 to M-1 (i.e., the slowest moving, column dimension of mA was “reduced” by adding together all columns).