Matrix

A two-dimensional matrix.

Example

    -- Create a default 2x2 double matrix of zeros
    
m1 = pf.Matrix.Zeros(2)
 
    -- Assign values to each element of the matrix

m1[1][1] = 1
m1[2][1] = 2
m1[1][2] = 3
m1[2][2] = 4

    -- Create a 2x2 double matrix with a fill value of 3
    
    
m2 = pf.Matrix(2, 2, 3) 
 
    -- Determine the transpose and determinant of the matrix
    
transpose = m1:Transpose()
determinant = m1:Determinant()

    -- Some of the valid operators for 'Matrix'
 
m3 = m1 * 2
m4 = m2 * (3 + j)
m5 = m1 + 2
m6 = m1 - 1
m7 = m1 + m2
m8 = m1 - m2

Usage locations (object properties)

The following objects have properties using the Matrix object:

Property List

ColumnCount
The number of columns in the matrix. (Read only number)
Im
The imaginary component of the complex matrix. (Read/Write Matrix)
Re
The real component of the complex matrix. (Read/Write Matrix)
RowCount
The number of rows in the matrix. (Read only number)
Type
The object type string. (Read only string)

Method List

Abs ()
Calculate the absolute value of all the entries in the matrix. (Returns a Matrix object.)
Angle ()
Calculate the angle of all the entries in the matrix. (Returns a Matrix object.)
Conj ()
Calculate the conjugate of all the entries in the matrix. (Returns a ComplexMatrix object.)
Determinant ()
Calculate the determinant of the matrix. (Returns a number object.)
Duplicate ()
Duplicate the matrix. (Returns a Matrix object.)
ExportMatFile (filename string, varname string)
Writes the given ComplexMatrix object to a *.mat file. (Returns a boolean object.)
FFT ()
Calculates the fast Fourier transform of the column or row matrix. For a matrix containing multiple columns and rows, the fast Fourier transform will be calculated for each of the columns. (Returns a ComplexMatrix object.)
IFFT ()
Calculates the inverse fast Fourier transform of the column or row matrix. For a matrix containing multiple columns and rows, the inverse fast Fourier transform will be calculated for each of the columns. (Returns a ComplexMatrix object.)
Imag ()
Extract the imaginary part of all the entries in the matrix. (Returns a Matrix object.)
Inverse ()
Calculate the inverse matrix. (Returns a Matrix object.)
Magnitude ()
Calculate the magnitude of all the entries in the matrix. (Returns a Matrix object.)
Max ()
Extracts the maximum from the matrix. (Returns a number object.)
Mean ()
Calculates the mean value of the elements of the matrix. (Returns a number object.)
Min ()
Extracts the minimum from the matrix. (Returns a number object.)
Phase ()
Calculate the phase of all the entries in the matrix. (Returns a Matrix object.)
Real ()
Extract the real part of all the entries in the matrix. (Returns a Matrix object.)
ReplaceSubMatrix (matrix Matrix, rowstart number, columnstart number)
Replace the sub matrix starting at the given indices with the provided matrix.
SubMatrix (rowstart number, rowend number, columnstart number, columnend number)
Obtain the sub matrix from the given parameters. (Returns a Matrix object.)
Sum ()
Calculates the sum of all the elements of the matrix. (Returns a number object.)
Transpose ()
Calculate the transpose of the matrix. (Returns a Matrix object.)

Constructor Function List

Diagonal (values List of number)
Creates a diagonal matrix. (Returns a Matrix object.)
Identity (size number)
Creates an identity matrix. (Returns a Matrix object.)
New (rows number, columnValues List of number)
Creates a new matrix. (Returns a Matrix object.)
New (rowValues List of number, columns number)
Creates a new matrix. (Returns a Matrix object.)
New (rows number, columns number, fill number)
Creates a new matrix. (Returns a Matrix object.)
New (rows number, columns number)
Creates a new matrix with uninitialised elements. (Returns a Matrix object.)
Ones (size number)
Creates a new matrix filled with ones. (Returns a Matrix object.)
Zeros (size number)
Creates a new matrix filled with zeros. (Returns a Matrix object.)

Static Function List

Abs (matrix Matrix)
Calculates the absolute value of each entry. (Returns a Matrix object.)
Acos (matrix Matrix)
Calculate the arc cosine of all the entries in the matrix. (Returns a Matrix object.)
Asin (matrix Matrix)
Calculate the arc sine of all the entries in the matrix. (Returns a Matrix object.)
Atan (matrix Matrix)
Calculate the arc tangent of all the entries in the matrix. (Returns a Matrix object.)
Atan2 (matrix Matrix, matrix Matrix)
Calculate the arc tangent of all the entries in the matrix. (Returns a Matrix object.)
Ceil (matrix Matrix)
Calculate the ceiling of all the elements in the matrix. (Returns a Matrix object.)
Cos (matrix Matrix)
Calculate the cosine of all the entries in the matrix. (Returns a Matrix object.)
Exponent (matrix Matrix)
Calculate the exponent of all the entries in the matrix. (Returns a Matrix object.)
Find (matrix Matrix)
Finds all entries in the matrix that are non-zero. (Returns a table object.)
Floor (matrix Matrix)
Calculate the floor of all the entries in the matrix. (Returns a Matrix object.)
GreaterThan (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are greater than each other. (Returns a Matrix object.)
GreaterThan (matrix Matrix, value number)
Determines if a matrix has entries greater than the specified value. (Returns a Matrix object.)
GreaterThanOrEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are greater than or equal to each other. (Returns a Matrix object.)
GreaterThanOrEqual (matrix Matrix, value number)
Determines if a matrix has entries greater than or equal to the specified value. (Returns a Matrix object.)
IsEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are equal. (Returns a Matrix object.)
IsEqual (matrix Matrix, value number)
Determines if a matrix has entries equal to the specified value. (Returns a Matrix object.)
LessThan (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are less than each other. (Returns a Matrix object.)
LessThan (matrix Matrix, value number)
Determines if a matrix has entries less than the specified value. (Returns a Matrix object.)
LessThanOrEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are less than or equal to each other. (Returns a Matrix object.)
LessThanOrEqual (matrix Matrix, value number)
Determines if a matrix has entries less than or equal to the specified value. (Returns a Matrix object.)
Log (matrix Matrix)
Calculate the log of all the entries in the matrix. (Returns a Matrix object.)
Log10 (matrix Matrix)
Calculate the log10 of all the entries in the matrix. (Returns a Matrix object.)
Magnitude (matrix Matrix)
Calculates the magnitude value of each entry. (Returns a Matrix object.)
Max (matrix Matrix, matrix Matrix)
Calculate the maximum of two corresponding entries from two matrices. (Returns a Matrix object.)
Max (matrix Matrix)
Calculate the maximum of all the entries in the matrix. (Returns a number object.)
Mean (matrix Matrix)
Calculate the mean of all the entries in the matrix. (Returns a number object.)
Min (matrix Matrix, matrix Matrix)
Calculate the minimum of two corresponding entries from two matrices. (Returns a Matrix object.)
Min (matrix Matrix)
Calculate the minimum of all the entries in the matrix. (Returns a number object.)
Modulo (matrix Matrix, matrix Matrix)
Calculates the Modulo of each entry with the corresponding entry in the second matrix. (Returns a Matrix object.)
Modulo (matrix Matrix, value number)
Calculates the Modulo of each entry with the value. (Returns a Matrix object.)
MultiplyByElement (matrix Matrix, matrix Matrix)
Calculate the exponent of all the elements in the matrix. (Returns a Matrix object.)
MultiplyByElement (matrix Matrix, value number)
Calculate the exponent of all the elements in the matrix. (Returns a Matrix object.)
Negate (matrix Matrix)
Negate each entry of the matrix. (Returns a Matrix object.)
NotEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are not equal. (Returns a Matrix object.)
NotEqual (matrix Matrix, value number)
Determines if a matrix has entries not equal to the specified value. (Returns a Matrix object.)
Power (matrix Matrix, matrix Matrix)
Raise all entries of the first matrix to the power of each entry in the second matrix. (Returns a Matrix object.)
Power (matrix Matrix, exponent number)
Raise each entry to the power of the exponent. (Returns a Matrix object.)
Sin (matrix Matrix)
Calculate the sine of all the entries in the matrix. (Returns a Matrix object.)
Sqrt (matrix Matrix)
Calculate the square root of all the entries in the matrix. (Returns a Matrix object.)
Sum (matrix Matrix)
Calculate the sum of all the entries in the matrix. (Returns a number object.)
Tan (matrix Matrix)
Calculate the tan of all the entries in the matrix. (Returns a Matrix object.)

Index List

[number]
Access the specified row in the matrix. (Read MatrixIndexer)

Property Details

ColumnCount
The number of columns in the matrix.
Type
number
Access
Read only
Im
The imaginary component of the complex matrix.
Type
Matrix
Access
Read/Write
Re
The real component of the complex matrix.
Type
Matrix
Access
Read/Write
RowCount
The number of rows in the matrix.
Type
number
Access
Read only
Type
The object type string.
Type
string
Access
Read only

Method Details

Abs ()
Calculate the absolute value of all the entries in the matrix.
Return
Matrix
The absolute value.
Angle ()
Calculate the angle of all the entries in the matrix.
Return
Matrix
The angle.
Conj ()
Calculate the conjugate of all the entries in the matrix.
Return
ComplexMatrix
The conjugate.
Determinant ()
Calculate the determinant of the matrix.
Return
number
The determinant of the matrix.
Duplicate ()
Duplicate the matrix.
Return
Matrix
The duplicated matrix.
ExportMatFile (filename string, varname string)
Writes the given ComplexMatrix object to a *.mat file.
Input Parameters
filename(string)
The name of the file.
varname(string)
The name of the variable to export.
Return
boolean
Boolean indicating success.
FFT ()
Calculates the fast Fourier transform of the column or row matrix. For a matrix containing multiple columns and rows, the fast Fourier transform will be calculated for each of the columns.
Return
ComplexMatrix
The calculated FFT complex matrix.
IFFT ()
Calculates the inverse fast Fourier transform of the column or row matrix. For a matrix containing multiple columns and rows, the inverse fast Fourier transform will be calculated for each of the columns.
Return
ComplexMatrix
The calculated IFFT complex matrix.
Imag ()
Extract the imaginary part of all the entries in the matrix.
Return
Matrix
The imaginary value.
Inverse ()
Calculate the inverse matrix.
Return
Matrix
The inverse of the matrix.
Magnitude ()
Calculate the magnitude of all the entries in the matrix.
Return
Matrix
The magnitude value.
Max ()
Extracts the maximum from the matrix.
Return
number
The maximum value.
Mean ()
Calculates the mean value of the elements of the matrix.
Return
number
The mean value.
Min ()
Extracts the minimum from the matrix.
Return
number
The minimum value.
Phase ()
Calculate the phase of all the entries in the matrix.
Return
Matrix
The phase.
Real ()
Extract the real part of all the entries in the matrix.
Return
Matrix
The real value.
ReplaceSubMatrix (matrix Matrix, rowstart number, columnstart number)
Replace the sub matrix starting at the given indices with the provided matrix.
Input Parameters
matrix(Matrix)
The new sub matrix.
rowstart(number)
Starting row index of the sub matrix.
columnstart(number)
Starting column index of the sub matrix.
SubMatrix (rowstart number, rowend number, columnstart number, columnend number)
Obtain the sub matrix from the given parameters.
Input Parameters
rowstart(number)
Row start index.
rowend(number)
Row end index.
columnstart(number)
Column start index.
columnend(number)
Column end index.
Return
Matrix
The sub matrix.
Sum ()
Calculates the sum of all the elements of the matrix.
Return
number
The sum.
Transpose ()
Calculate the transpose of the matrix.
Return
Matrix
The transpose of the matrix.

Static Function Details

Abs (matrix Matrix)
Calculates the absolute value of each entry.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Acos (matrix Matrix)
Calculate the arc cosine of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Asin (matrix Matrix)
Calculate the arc sine of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Atan (matrix Matrix)
Calculate the arc tangent of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Atan2 (matrix Matrix, matrix Matrix)
Calculate the arc tangent of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
The result matrix.
Ceil (matrix Matrix)
Calculate the ceiling of all the elements in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Cos (matrix Matrix)
Calculate the cosine of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Diagonal (values List of number)
Creates a diagonal matrix.
Input Parameters
values(List of number)
The values to fill the matrix.
Return
Matrix
The new matrix.
Exponent (matrix Matrix)
Calculate the exponent of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Find (matrix Matrix)
Finds all entries in the matrix that are non-zero.
Input Parameters
matrix(Matrix)
The matrix.
Return
table
The result matrix.
Floor (matrix Matrix)
Calculate the floor of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
GreaterThan (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are greater than each other.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The matrix used to test each entry.
Return
Matrix
One and zero filled matrix.
GreaterThan (matrix Matrix, value number)
Determines if a matrix has entries greater than the specified value.
Input Parameters
matrix(Matrix)
The first matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
GreaterThanOrEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are greater than or equal to each other.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
GreaterThanOrEqual (matrix Matrix, value number)
Determines if a matrix has entries greater than or equal to the specified value.
Input Parameters
matrix(Matrix)
The first matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
Identity (size number)
Creates an identity matrix.
Input Parameters
size(number)
The size of the matrix.
Return
Matrix
The new matrix.
IsEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are equal.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
One and zero filled matrix.
IsEqual (matrix Matrix, value number)
Determines if a matrix has entries equal to the specified value.
Input Parameters
matrix(Matrix)
The matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
LessThan (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are less than each other.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The matrix used to test each entry.
Return
Matrix
One and zero filled matrix.
LessThan (matrix Matrix, value number)
Determines if a matrix has entries less than the specified value.
Input Parameters
matrix(Matrix)
The first matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
LessThanOrEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are less than or equal to each other.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
LessThanOrEqual (matrix Matrix, value number)
Determines if a matrix has entries less than or equal to the specified value.
Input Parameters
matrix(Matrix)
The first matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
Log (matrix Matrix)
Calculate the log of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Log10 (matrix Matrix)
Calculate the log10 of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Magnitude (matrix Matrix)
Calculates the magnitude value of each entry.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Max (matrix Matrix, matrix Matrix)
Calculate the maximum of two corresponding entries from two matrices.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
The result matrix.
Max (matrix Matrix)
Calculate the maximum of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
number
The maximum value.
Mean (matrix Matrix)
Calculate the mean of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
number
The mean value.
Min (matrix Matrix, matrix Matrix)
Calculate the minimum of two corresponding entries from two matrices.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
The result matrix.
Min (matrix Matrix)
Calculate the minimum of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
number
The minimum value.
Modulo (matrix Matrix, matrix Matrix)
Calculates the Modulo of each entry with the corresponding entry in the second matrix.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
The result matrix.
Modulo (matrix Matrix, value number)
Calculates the Modulo of each entry with the value.
Input Parameters
matrix(Matrix)
The matrix.
value(number)
The value used to do the modulus on each entry in the matrix.
Return
Matrix
The result matrix.
MultiplyByElement (matrix Matrix, matrix Matrix)
Calculate the exponent of all the elements in the matrix.
Input Parameters
matrix(Matrix)
The matrix used to perform operation.
matrix(Matrix)
The multiply matrix.
Return
Matrix
The result of the two matrices entries multiplied with each other.
MultiplyByElement (matrix Matrix, value number)
Calculate the exponent of all the elements in the matrix.
Input Parameters
matrix(Matrix)
The matrix used to perform operation.
value(number)
The value that will be multiplied to each of the entries in the matrix.
Return
Matrix
The result of all the entries multiplied by the scalar value.
Negate (matrix Matrix)
Negate each entry of the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
New (rows number, columnValues List of number)
Creates a new matrix.
Input Parameters
rows(number)
The number of rows in the matrix. Each column value will be duplicated for every row.
columnValues(List of number)
The values to place in each of the columns.
Return
Matrix
The new matrix.
New (rowValues List of number, columns number)
Creates a new matrix.
Input Parameters
rowValues(List of number)
The values to place in each of the rows.
columns(number)
The number of columns in the matrix. Each row value will be duplicated for every column.
Return
Matrix
The new matrix.
New (rows number, columns number, fill number)
Creates a new matrix.
Input Parameters
rows(number)
The number of rows in the matrix.
columns(number)
The number of columns in the matrix.
fill(number)
The value used to fill the matrix.
Return
Matrix
The new matrix.
New (rows number, columns number)
Creates a new matrix with uninitialised elements.
Input Parameters
rows(number)
The number of rows in the matrix.
columns(number)
The number of columns in the matrix.
Return
Matrix
The new matrix.
NotEqual (matrix Matrix, matrix Matrix)
Determines if the entries of two matrices are not equal.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
One and zero filled matrix.
NotEqual (matrix Matrix, value number)
Determines if a matrix has entries not equal to the specified value.
Input Parameters
matrix(Matrix)
The matrix.
value(number)
The value used to test each entry.
Return
Matrix
One and zero filled matrix.
Ones (size number)
Creates a new matrix filled with ones.
Input Parameters
size(number)
The size of the matrix.
Return
Matrix
The new matrix.
Power (matrix Matrix, matrix Matrix)
Raise all entries of the first matrix to the power of each entry in the second matrix.
Input Parameters
matrix(Matrix)
The first matrix.
matrix(Matrix)
The second matrix.
Return
Matrix
The power of all the elements in the matrix.
Power (matrix Matrix, exponent number)
Raise each entry to the power of the exponent.
Input Parameters
matrix(Matrix)
The matrix.
exponent(number)
The exponent.
Return
Matrix
The result matrix.
Sin (matrix Matrix)
Calculate the sine of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Sqrt (matrix Matrix)
Calculate the square root of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Sum (matrix Matrix)
Calculate the sum of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
number
The sum.
Tan (matrix Matrix)
Calculate the tan of all the entries in the matrix.
Input Parameters
matrix(Matrix)
The matrix.
Return
Matrix
The result matrix.
Zeros (size number)
Creates a new matrix filled with zeros.
Input Parameters
size(number)
The size of the matrix.
Return
Matrix
The new matrix.