TD_BINARYMATRIXOP Function Examples | Teradata Vantage - TD_BINARYMATRIXOP Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743

TD_BINARYMATRIXOP Input Table BINARYM_COMPLEX_LEFT

Row ID SEQ TICK REAL_VAL IMAGINARY_VAL
1 1 1 1 1.1 10.1
2 1 1 2 1.2 10.2
3 1 1 3 1.3 10.3
4 1 1 4 1.4 10.4
... ... ... ... ... ...
19 2 2 4 5.4 50.4
20 2 2 5 5.5 50.5

TD_BINARYMATRIXOP Input Table BINARYM_COMPLEX_RIGHT

Row ID SEQ TICK REAL_VAL IMAGINARY_VAL
1 1 1 1 1.1 10.1
2 1 1 2 1.2 10.2
3 1 1 3 1.3 10.3
4 1 1 4 1.4 10.4
... ... ... ... ... ...
19 2 2 4 5.4 50.4
20 2 2 5 5.5 50.5

TD_BINARYMATRIXOP Input Table BINARYM_REALS_LEFT

ROW ID SEQ TICK A B C D
1 1 1 1 1.1 10.1 20.1 30.3
2 1 1 2 1.2 10.2 20.2 30.2
3 1 1 3 1.3 10.3 20.3 30.3
4 1 1 4 1.4 10.4 20.4 0.4
... ... ... ... ... ... ... ...
19 2 2 4 5.4 50.4 60.4 70.4
20 2 2 5 5.5 50.5 60.5 70.5

TD_BINARYMATRIXOP Input Table BINARYM_REALS_RIGHT

ROW ID SEQ TICK A B C D
1 1 1 1 1.1 10.1 20.1 30.3
2 1 1 2 1.2 10.2 20.2 30.2
3 1 1 3 1.3 10.3 20.3 30.3
4 1 1 4 1.4 10.4 20.4 0.4
... ... ... ... ... ... ... ...
19 2 2 4 5.4 50.4 60.4 70.4
20 2 2 5 5.5 50.5 60.5 70.5

TD_BINARYMATRIXOP Call with Addition

EXECUTE FUNCTION INTO VOLATILE ART(MATHEXAMPLE)
TD_BINARYMATRIXOP(
   MATRIX_SPEC( TABLE_NAME(BINARYM_COMPLEX_LEFT), ROW_AXIS(SEQUENCE(SEQ)), 
      COLUMN_AXIS(SEQUENCE(TICK)), MATRIX_ID(ID),
      PAYLOAD(FIELDS(REAL_VAL,IMAGINARY_VAL), CONTENT(COMPLEX)) ) ,
   MATRIX_SPEC( TABLE_NAME(BINARYM_COMPLEX_RIGHT), ROW_AXIS(SEQUENCE(SEQ)),
      COLUMN_AXIS(SEQUENCE(TICK)), MATRIX_ID(ID),
      PAYLOAD(FIELDS(REAL_VAL,IMAGINARY_VAL), CONTENT(COMPLEX)) ) 
   WHERE ID=1,
   FUNC_PARAMS( MATHOP(ADD) ),
   INPUT_FMT(INPUT_MODE(MANY2ONE))
);

TD_BINARYMATRIXOP Result with Addition

SELECT * FROM MATHEXAMPLE;
ID ROW_I COLUMN_I OUT_REAL_VAL OUT_IMAGINARY_VAL
----------- -------------------- -------------------- ---------------------- ----------------------
1 0 0 2.20000000000000E 000 2.02000000000000E 001
1 0 1 2.40000000000000E 000 2.04000000000000E 001
1 0 2 2.60000000000000E 000 2.06000000000000E 001
1 0 3 2.80000000000000E 000 2.08000000000000E 001
1 0 4 3.00000000000000E 000 2.10000000000000E 001
1 1 0 2.20000000000000E 000 2.02000000000000E 001
1 1 1 2.40000000000000E 000 2.04000000000000E 001
1 1 2 2.60000000000000E 000 2.06000000000000E 001
1 1 3 2.80000000000000E 000 2.08000000000000E 001
1 1 4 3.00000000000000E 000 2.10000000000000E 001
2 0 0 6.20000000000000E 000 6.02000000000000E 001
2 0 1 6.40000000000000E 000 6.04000000000000E 001
2 0 2 6.60000000000000E 000 6.06000000000000E 001
2 0 3 6.80000000000000E 000 6.08000000000000E 001
2 0 4 7.00000000000000E 000 6.10000000000000E 001
2 1 0 6.20000000000000E 000 6.02000000000000E 001
2 1 1 6.40000000000000E 000 6.04000000000000E 001
2 1 2 6.60000000000000E 000 6.06000000000000E 001
2 1 3 6.80000000000000E 000 6.08000000000000E 001
2 1 4 7.00000000000000E 000 6.10000000000000E 001

TD_BINARYMATRIXOP Call with REAL and MULTIVAR_REAL matrixes

EXECUTE FUNCTION INTO VOLATILE ART(MATHEXAMPLE)
TD_BINARYMATRIXOP(
   MATRIX_SPEC(TABLE_NAME(BINARYM_REALS_LEFT), ROW_AXIS(SEQUENCE(SEQ)),
      COLUMN_AXIS(SEQUENCE(TICK)),MATRIX_ID(ID),
      PAYLOAD(FIELDS(A), CONTENT(REAL)) ) WHERE ID=1,
   MATRIX_SPEC(TABLE_NAME(BINARYM_REALS_RIGHT), ROW_AXIS(SEQUENCE(SEQ)), 
      COLUMN_AXIS(SEQUENCE(TICK)),MATRIX_ID(ID),
      PAYLOAD(FIELDS(A,B,C,D), CONTENT(MULTIVAR_REAL)) ) WHERE ID=1,
   FUNC_PARAMS( MATHOP(ADD) ),
   INPUT_FMT(INPUT_MODE(ONE2ONE))
);

TD_BINARYMATRIXOP Result with REAL and MULTIVAR_REAL matrixes

SELECT * FROM MATHEXAMPLE;
ID ROW_I COLUMN_I OUT_A OUT_B OUT_C OUT_D
----------- -------------------- -------------------- ---------------------- ---------------------- ---------------------- ---------------------
1 0 0 2.20000000000000E 000 1.12000000000000E 001 2.12000000000000E 001 3.12000000000000E 001
1 0 1 2.40000000000000E 000 1.14000000000000E 001 2.14000000000000E 001 3.14000000000000E 001
1 0 2 2.60000000000000E 000 1.16000000000000E 001 2.16000000000000E 001 3.16000000000000E 001
1 0 3 2.80000000000000E 000 1.18000000000000E 001 2.18000000000000E 001 3.18000000000000E 001
1 0 4 3.00000000000000E 000 1.20000000000000E 001 2.20000000000000E 001 3.20000000000000E 001
1 1 0 2.20000000000000E 000 1.12000000000000E 001 2.12000000000000E 001 3.12000000000000E 001
1 1 1 2.40000000000000E 000 1.14000000000000E 001 2.14000000000000E 001 3.14000000000000E 001
1 1 2 2.60000000000000E 000 1.16000000000000E 001 2.16000000000000E 001 3.16000000000000E 001
1 1 3 2.80000000000000E 000 1.18000000000000E 001 2.18000000000000E 001 3.18000000000000E 001
1 1 4 3.00000000000000E 000 1.20000000000000E 001 2.20000000000000E 001 3.20000000000000E 001

TD_BINARYMATRIXOP Call with ONE2ONE Subtraction

EXECUTE FUNCTION INTO VOLATILE ART (TRENDREMOVED)
  TD_BINARYMATRIXOP (
    MATRIX_SPEC (
      TABLE_NAME (BOUY_TABLE),
      ROW_AXIS (TIMECODE (MYTIMECODE)),
      COLUMN_AXIS (
        SEQUENCE (SEQNO), 
        MATRIX_ID (BOUYID),
        PAYLOAD (FIELDS (SALINITY), CONTENT (REAL))
      )
    ) WHERE BUOYID = 33,
    MATRIX_SPEC (
      TABLE_NAME (SMOOTHED_DATA),
      ROW_AXIS (SEQUENCE (ROW_I)),
      COLUMN_AXIS (
        SEQUENCE (COLUMN_I),
        MATRIX_ID (ROW_I),
        PAYLOAD (FIELDS (MAGNITUDE), CONTENT (REAL))
      )
    ) WHERE ROW_I = 33,
    FUNC_PARAMS (MATHOP (SUB)),
    INPUT_FMT(INPUT_MODE (ONE2ONE))
  );

TD_BINARYMATRIXOP Output

Display the RETURNS TABLE with this statement:

SELECT * FROM TRENDREMOVED;
STATIONID  ROW_I  COLUMN_I  OUT_VELOCITY
 33          0      0       128.0
 33          0      1       126.9
 33          0      2       127.9
 33          1      0       126.8
 33          1      1       128.1
 33          1      2       128.3

TD_BINARYMATRIXOP Call with MANY2ONE Subtraction

EXECUTE FUNCTION INTO VOLATILE ART(MATHEXAMPLE)
TD_BINARYMATRIXOP(
   MATRIX_SPEC( TABLE_NAME(BINARYM_COMPLEX_LEFT), ROW_AXIS(SEQUENCE(SEQ)), COLUMN_AXIS(SEQUENCE
      (TICK)), MATRIX_ID(ID), PAYLOAD(FIELDS(REAL_VAL,IMAGINARY_VAL), CONTENT(COMPLEX)) ) ,
   MATRIX_SPEC( TABLE_NAME(BINARYM_COMPLEX_RIGHT), ROW_AXIS(SEQUENCE(SEQ)), COLUMN_AXIS(SEQUENCE
      (TICK)), MATRIX_ID(ID),PAYLOAD(FIELDS(REAL_VAL,IMAGINARY_VAL), CONTENT(COMPLEX)) ) 
   WHERE ID=1,
   FUNC_PARAMS( MATHOP(SUB) ),
   INPUT_FMT(INPUT_MODE(MANY2ONE))
);

TD_BINARYMATRIXOP Output

Display the RETURNS TABLE with this statement:

SELECT * FROM MATHEXAMPLE;
ID ROW_I COLUMN_I OUT_REAL_VAL OUT_IMAGINARY_VAL
----------- -------------------- -------------------- ---------------------- ----------------------
1 0 0 2.20000000000000E 000 2.02000000000000E 001
1 0 1 2.40000000000000E 000 2.04000000000000E 001
1 0 2 2.60000000000000E 000 2.06000000000000E 001
1 0 3 2.80000000000000E 000 2.08000000000000E 001
1 0 4 3.00000000000000E 000 2.10000000000000E 001
1 1 0 2.20000000000000E 000 2.02000000000000E 001
1 1 1 2.40000000000000E 000 2.04000000000000E 001
1 1 2 2.60000000000000E 000 2.06000000000000E 001
1 1 3 2.80000000000000E 000 2.08000000000000E 001
1 1 4 3.00000000000000E 000 2.10000000000000E 001
2 0 0 6.20000000000000E 000 6.02000000000000E 001
2 0 1 6.40000000000000E 000 6.04000000000000E 001
2 0 2 6.60000000000000E 000 6.06000000000000E 001
2 0 3 6.80000000000000E 000 6.08000000000000E 001
2 0 4 7.00000000000000E 000 6.10000000000000E 001
2 1 0 6.20000000000000E 000 6.02000000000000E 001
2 1 1 6.40000000000000E 000 6.04000000000000E 001
2 1 2 6.60000000000000E 000 6.06000000000000E 001
2 1 3 6.80000000000000E 000 6.08000000000000E 001
2 1 4 7.00000000000000E 000 6.10000000000000E 001

TD_BINARYMATRIXOP Call with MATCH Subtraction

EXECUTE FUNCTION INTO VOLATILE ART(MATHEXAMPLE)
TD_BINARYMATRIXOP(
   MATRIX_SPEC(TABLE_NAME(BINARYM_REALS_LEFT), ROW_AXIS(SEQUENCE(SEQ)), COLUMN_AXIS(SEQUENCE
      (TICK)),MATRIX_ID(ID),PAYLOAD(FIELDS(A), CONTENT(REAL)) ),
   MATRIX_SPEC(TABLE_NAME(BINARYM_REALS_RIGHT), ROW_AXIS(SEQUENCE(SEQ)), COLUMN_AXIS(SEQUENCE
      (TICK)),MATRIX_ID(ID),PAYLOAD(FIELDS(B), CONTENT(REAL)) ),
   FUNC_PARAMS( MATHOP(MUL) ),
   INPUT_FMT(INPUT_MODE(MATCH))
);

TD_BINARYMATRIXOP Output

Display the RETURNS TABLE with this statement:

SELECT * FROM MATHEXAMPLE;
ID ROW_I COLUMN_I OUT_A
----------- -------------------- -------------------- ----------------------
1 0 0 1.11100000000000E 001
1 0 1 1.22400000000000E 001
1 0 2 1.33900000000000E 001
1 0 3 1.45600000000000E 001
1 0 4 1.57500000000000E 001
1 1 0 1.11100000000000E 001
1 1 1 1.22400000000000E 001
1 1 2 1.33900000000000E 001
1 1 3 1.45600000000000E 001
1 1 4 1.57500000000000E 001
2 0 0 2.55510000000000E 002
2 0 1 2.61040000000000E 002
2 0 2 2.66590000000000E 002
2 0 3 2.72160000000000E 002
2 0 4 2.77750000000000E 002
2 1 0 2.55510000000000E 002
2 1 1 2.61040000000000E 002
2 1 2 2.66590000000000E 002
2 1 3 2.72160000000000E 002
2 1 4 2.77750000000000E 002