TD_MATRIXMULTIPLY Function Examples | Teradata Vantage - TD_MATRIXMULTIPLY 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_MATRIXMULTIPLY Input Table Mtx1

BUOYID ROW_I COLUMN_1 SPEED1
35 1 1 1
35 1 2 2
35 1 3 3
35 2 1 4
... ... ... ...
37 1 3 3
37 2 1 4
37 2 2 5
37 2 3 6

TD_MATRIXMULTIPLY Input Table Mtx2

BUOYID ROW_I COLUMN_1 SPEED2
35 1 1 1
35 1 2 4
35 2 1 2
35 2 2 5
... ... ... ...
38 2 1 4
38 2 2 10
38 3 1 6
38 3 2 12

Example: TD_MATRIXMULTIPLY Call with ONE2ONE Parameter

EXECUTE FUNCTION INTO VOLATILE ART(MatrixProduct)
TD_MATRIXMULTIPLY(
   MATRIX_SPEC(TABLE_NAME(Mtx1), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)),COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD( FIELDS(speed1),CONTENT(REAL))) WHERE BUOYID = 35,
   MATRIX_SPEC(TABLE_NAME(Mtx2), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)),COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD(FIELDS(speed2), CONTENT(REAL))) WHERE BUOYID = 35,
   INPUT_FMT(INPUT_MODE(ONE2ONE)) 
);

TD_MATRIXMULTIPLY Output with ONE2ONE Parameter

SELECT * FROM MatrixProduct;
BUOYID      ROW_I       COLUMN_I    speed1
----------- ----------- ----------- ----------------------
35          0           0           14.0
35          0           1           32.0
35          1           0           32.0
35          1           2           77.0

Example: TD_MATRIXMULTIPLY Call with MANY2ONE Parameter

EXECUTE FUNCTION INTO VOLATILE ART(MatrixProduct)
TD_MATRIXMULTIPLY(
   MATRIX_SPEC(TABLE_NAME(Mtx1), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)), COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD( FIELDS(speed1),CONTENT(REAL))) where buoyid = 35,
   MATRIX_SPEC(TABLE_NAME(Mtx2), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)),COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD(FIELDS(speed2), CONTENT(REAL))) where buoyid = 35,
   INPUT_FMT(INPUT_MODE(MANY2ONE))
);

TD_MATRIXMULTIPLY Output with MANY2ONE Parameter

SELECT * FROM MatrixProduct;
BUOYID      ROW_I       COLUMN_I    speed1
----------- ----------- ----------- ----------------------
35          0           0           14.0
35          0           1           32.0
35          1           0           32.0
35          1           2           77.0

Example: TD_MATRIXMULTIPLY Call with MATCH Parameter

EXECUTE FUNCTION INTO VOLATILE ART(MatrixProduct)
TD_MATRIXMULTIPLY(
   MATRIX_SPEC(TABLE_NAME(Mtx1), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)),COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD( FIELDS(speed1),CONTENT(REAL))),
   MATRIX_SPEC(TABLE_NAME(Mtx2), MATRIX_ID(BuoyID),
      ROW_AXIS(SEQUENCE(row_I)), COLUMN_AXIS(SEQUENCE(column_I)),
      PAYLOAD(FIELDS(speed2), CONTENT(REAL))),
   INPUT_FMT(INPUT_MODE(MATCH))
);

TD_MATRIXMULTIPLY Output with MATCH Parameter

SELECT * FROM MatrixProduct;
BUOYID      ROW_I       COLUMN_I    speed1
----------- ----------- ----------- ----------------------
35          0           0           14.0
35          0           1           32.0
35          1           0           32.0
35          1           2           77.0