Matrix IsMatrix

From GECK
(Redirected from Mat IsMat)
Jump to: navigation, search


A function added by the ShowOff NVSE Plugin version 1.40.

Description

Returns true if an array can be considered a mathematical Matrix, false otherwise.

Expects that either all elements in the main array are sub-arrays (for two-dimensional arrays) containing numbers, or are numbers. The array must have the same number of elements in each row. Empty or invalid arrays are not considered valid matrices.

Two-dimensional and one-dimensional arrays can both be matrices if they follow the above rules.

Syntax

[help]
(isMatrix:bool) Matrix_IsMatrix array:array_var 

Or:

(isMatrix:bool) Mat_IsMat array:array_var

Example

array_var aRes
aRes = ar_List "test"
print "Is array a matrix?: " + $(Matrix_IsMatrix aRes)

Prints that the array is not a valid matrix, since it has a non-numeric member.

aRes = ar_List (Ar_List 1)
print "Is array a matrix?: " + $(Matrix_IsMatrix aRes)

Prints that the array is a valid matrix.

aRes = ar_List (Ar_List 1), (Ar_List 2 3)
print "Is array a matrix?: " + $(Matrix_IsMatrix aRes)

Prints that the array is not a valid matrix, since its second row has more elements than its first row.

aRes = ar_List (Ar_List 1), (Ar_List 2 SunnyREF)
print "Is array a matrix?: " + $(Matrix_IsMatrix aRes)

Prints that the array is not a valid matrix, since its second row has more elements than its first row. Not only that, but one of its elements is also non-numeric.

aRes = ar_List (Ar_List SunnyREF) (Ar_List SunnyREF)
print "Is array a matrix?: " + $(Mat_IsMat aRes)

Prints that the array is not a valid matrix, since it has non-numeric elements.

aRes = ar_List (Ar_List 1, 2), (Ar_List 2, 3)
print "Is array a matrix?: " + $(Mat_IsMat aRes)

Prints that the array is a valid matrix.

aRes = ar_List 5, (Ar_List 2, 3)
print "Is array a matrix?: " + $(Mat_IsMat aRes)

Prints that the array is not a valid matrix, since its second element is an array (expects that either all elements in the main array are sub-arrays, or are numbers).

See Also