Matrix ApplyOperationWithMatrix

From GECK
Jump to: navigation, search


A function added by the ShowOff NVSE Plugin version 1.40.

Description

Returns the Matrix affected by an operation with another Matrix.

The operation to apply is specified via the operator string. See Notes for valid operator strings and what they do.

Syntax

[help]
(resultMatrix:array) Matrix_ApplyOperationWithMatrix matrixA:array_var operator:string matrixB:array_var 

Or:

(resultMatrix:array) Mat_ApplyOpWithMat matrixA:array_var operator:string matrixB:array_var 

Notes

  • Valid operator strings, and what they do:
Operators
Description
+
Element-wise addition of two matrices
-
Element-wise subtraction of two matrices
*
Matrix multiplication (online resource to test that here)
/ Element-wise division of two matrices
 % Element-wise multiplication of two matrices (Schur Product)

Examples

array_var aMatrixA
array_var aMatrixB
array_var aRes

Example #1:

	aMatrixA = ar_List 1, 2, 3 
	aMatrixB = ar_List 1, 2, 3
	aRes = Mat_ApplyOpWithMat aMatrixA "+" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 3 as Matrix **
   2.0000   4.0000   6.0000

Example #2:

	aMatrixA = ar_List 1, 2, 3 
	aMatrixB = ar_List 1, 2, 3
	aRes = Mat_ApplyOpWithMat aMatrixA "/" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 6 as Matrix **
   1.0000   1.0000   1.0000

Example #3:

	aMatrixA = ar_List 1, 2, 3 
	aMatrixB = ar_List 1, 2, 3
	aRes = Mat_ApplyOpWithMat aMatrixA "*" aMatrixB 

aRes will be an invalid array, since matrix multiplication is only defined if the number of columns in the first array is equal to the number of rows in the second.

Example #4:

	aMatrixA = ar_List 1
	aMatrixB = ar_List 2
	aRes = Mat_ApplyOpWithMat aMatrixA "*" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 11 as Matrix **
   2.0000

Example #5:

	aMatrixA = ar_List (ar_List 3, 4) (ar_List 5, 6)
	aMatrixB = ar_List (ar_List 7, 8) (ar_List 9, 10)
	aRes = Mat_ApplyOpWithMat aMatrixA "*" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 18 as Matrix **
   5.7000e+01   6.4000e+01
   8.9000e+01   1.0000e+02

Example #6:

	aMatrixA = ar_List 1, 2, 3 
	aMatrixB = ar_List 1, 2, 3
	aRes = Mat_ApplyOpWithMat aMatrixA "-" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 23 as Matrix **
        0        0        0

Example #7:

	aMatrixA = ar_List 1, 2, 3 
	aMatrixB = ar_List 1, 2, 3
	aRes = Mat_ApplyOpWithMat aMatrixA "%" aMatrixB 

By calling Matrix_Dump on aRes, we get the following text in console:

** Dumping Array 26 as Matrix **
   1.0000   4.0000   9.0000

See Also