TD_​BINARYMATRIXOP

There is a need in data science to be able to create a new data matrix that is the result of performing a point-wise mathematical operation against two matrices having the same number of elements. The principal mathematical operations of interest being that of subtraction, addition, multiplication, and division. It is called a point-wise operation because it performs the mathematical operation on one sample point at a time. For example, if the mathematical operation being performed is subtraction, then for two matrices each with NxM sample points, a new matrix is generated in which: ResultMatrix1_1 = MinuendMatrix1_1 - SubtrahendMatrix1_1 ; ResultMatrix2_1 = MinuendMatrix2_1 - SubtrahendMatrix2_1 ; ResultMatrix3_1 = MinuendMatrix3_1 - SubtrahendMatrix3_1 ; ..., up to ResultMatrixN_M = MinuendMatrixN_M - SubtrahendMatrixN_M. The result matrix/2D array produced by the TD_BINARYMATRIXOP is the same size, 'NxM', as its inputs and inherits the identifiers, MATRIX_ID(), in this case, from the minuend matrix.. Thus the TD_BINARYMATRIXOP takes two equally sized logical-runtime matrices as input - the first matrix referenced in the function call is referred to as being the 'primary matrix', whereas the second matrix referenced is the secondary matrix. The result matrix always inherits the identifiers, MATRIX_ID() from the primary matrix. Mathematically, the significance of being a primary matrix or secondary matrix is as follows:. For MATHOP(SUB), subtraction, the secondary matrix is subtracted from the primary matrix.. For MATHOP(ADD), addition, the secondary matrix is added to the primary matrix.. For MATHOP(MUL), multiply, the primary matrix is multiplied by the secondary matrix.. For MATHOP(DIV), divide, the primary matrix is divided by the secondary matrix.. The TD_BINARYMATRIXOP function can be configured to operate in one of three input modes - ONE2ONE, MANY2ONE, and MATCH. These modes determine the number of primary matrices and number of secondary matrices involved in the operation, as well as determining how the primary and secondary matrix will be matched together. See the INPUT_FMT section for more information.. Some Use Case Examples for these Operators include:. A use for the subtraction - MATHOP(SUB) - and addition - MATHOP(ADD) - operations is to respectively remove trends from the original matrix and to later restore the trends while engaged in forecasting with the model. Some background for this is: In building statistical ARMA-style forecasting models, a necessary precondition is that the time matrix being modelled be stationary: stationary with respect to mean; stationary with respect to covariance; and, stationary with respect to variance. Transforming a non-stationary matrix into a stationary matrix typically requires the completion of two main tasks: the first task requiring the data scientist to model the trend or periodicity inherent in the data, then use that model to generate a representative matrix; the second task being to execute an operator that forms a new matrix, formed by subtracting the just generated trend or periodicity matrix from the original matrix. The TD_BINARYMATRIXOP function supplies just such an operator, it forms one or more new matrices by enabling the data scientist to perform a point-wise subtraction between the original matrix, aka, the 'minuend-matrix', and the matrix to be subtracted, aka, the 'subtrahend', so minuend minus subtrahend.. A use case for the multiplication - MATHOP(SUB) - comes with respect to applying a filter function against a time matrix. To apply a filter function - low pass, band pass, high pass - to a time matrix in the time domain requires a complex operation known as conjugation. In contrast, if one first were to take the Fourier Transform of the time matrix and the Fourier Transform of the filter matrix; transitioning both data matrices from the time domain over to the frequency domain, then while in the frequency domain, the filter could be applied simply by running the two Fourier result matrices through a point-wise multiplier to produce a filtered result in the frequency domain. In other words, conjugation in the time domain (a complex process) is equivalent to point-wise multiplication in the frequency domain. Once the multiplication operation is complete, the data scientist could then take the inverse transform of the multiplied result set, obtaining the filtered version of the time matrix.. Use case for TD_BINARYMATRIXOP - Removal of trends present within a time matrix. One task frequently performed by the Forecast Model developer is the removal of a trend from a time matrix, prior to modelling that matrix. There are several different approaches available to the data scientist for removing trends. As inferred in the below diagram, most of those involve executing a function against the original matrix that produces a new matrix containing the “trend”. This initial processing step is followed by another processing step in which the original matrix and “trend” matrix is run through a point-wise subtractor, which subtracts - for each sample time point - the trend matrix from the original, producing a third 'detrended' matrix. In other words, given an original matrix and a 'trend' matrix with five sample points at times: T0, T1, T2, T2, T4; the subtractor performs, original(T0) - trend(T0); original(T1) - trend(T1); …; original(T4) - trend(T4); producing a detrended matrix with five sample points. The net effect of this operation, see diagram below, is to create a new matrix that is “rotated down”, once the trend has been removed. Forecast Modelling can then proceed on the 'detrended' matrix.

Options

InputFormat
Specifies the input mode supported by the function.
MATHOP
Dictates mathematical operation to be performed between the passed in primary and secondary matrices. It is an operation, where: result-matrix = primary-matrix MATHOP secondary-matrix. Specifics of the operation depend on the passed in PAYLOAD(CONTENT(); meaning that the operation will be a real operation, a multivariate real operation, a complex number operation, or an amplitude phase operation.
OutputFormat
Specifies the INDEX_STYLE of the output format.
Output Schema
Output Schema, if Volatile is true then use user login as the schema.
Output Table
Output Table
VAL Location
VAL Location
Volatile
Specifies whether the table should be a VOLATILE table. If true, then the table is automatically deleted, otherwise it is users responsibility to remove or clean it up for space.

Input Ports

Icon
Connection to a Teradata Database Instance
Icon
This function takes two equally sized data matrices as inputs, performs the specified mathematical operation - add, subtract, multiply, divide - on a sample point by sample point basis, producing a result matrix, which is the result of performing the mathematical operation.
Icon
secondary matrix of equal size to be operated on

Output Ports

Icon
output of TD_BINARYMATRIXOP

Nodes

Extensions

Links