Class: Math_Matrix
Source Location: /Math_Matrix-0.8.7/Math/Matrix.php
Defines a matrix object.
Author(s):
Version:
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Method Detail
Math_Matrix (Constructor) [line 145]
Constructor for the matrix object
Parameters:
add [line 1023]
Adds a matrix to this one
Parameters:
cloneMatrix [line 305]
Returns a new Math_Matrix object with the same data as the current one
determinant [line 691]
number|PEAR_Error determinant(
)
|
|
Calculates the matrix determinant using Gaussian elimination with partial pivoting. At each step of the pivoting proccess, it checks that the normalized determinant calculated so far is less than 10^-18, trying to detect singular or ill-conditioned matrices
getCol [line 423]
array|Math_Vector|PEAR_Error getCol(
integer
$col, [optional
$asVector = false])
|
|
Returns the column with the given index This method checks that matrix has been initialized and that the column requested is not outside the range of column.
Parameters:
getData [line 215]
array|PEAR_Error getData(
)
|
|
Returns the array of arrays.
getDiagonal [line 915]
object Math_Vector|PEAR_Error &getDiagonal(
)
|
|
Returns the diagonal of a square matrix as a Math_Vector
getElement [line 343]
number|PEAR_Error getElement(
integer
$row, integer
$col)
|
|
Returns the value of the element at (row,col)
Parameters:
getMax [line 582]
number|PEAR_Error getMax(
)
|
|
Returns the maximum value of the elements in the matrix
getMaxIndex [line 630]
array|PEAR_Error getMaxIndex(
)
|
|
Gets the position of the element with the maximum value
getMin [line 569]
number|PEAR_Error getMin(
)
|
|
Returns the minimum value of the elements in the matrix
getMinIndex [line 616]
array|PEAR_Error getMinIndex(
)
|
|
Gets the position of the element with the minimum value
getRow [line 363]
array|Math_Vector|PEAR_Error getRow(
integer
$row, [optional
$asVector = false])
|
|
Returns the row with the given index This method checks that matrix has been initialized and that the row requested is not outside the range of rows.
Parameters:
getSize [line 264]
array|PEAR_Error getSize(
)
|
|
Returns an array with the number of rows and columns in the matrix
getSubMatrix [line 887]
Returns a submatrix from the position (row, col), with nrows and ncols
Parameters:
getValueIndex [line 596]
array|PEAR_Error getValueIndex(
numeric
$val)
|
|
Gets the position of the first element with the given value
Parameters:
getZeroThreshold [line 245]
float getZeroThreshold(
)
|
|
Returns the value of the upper bound used to minimize round off errors
invert [line 788]
number|PEAR_Error invert(
)
|
|
Inverts a matrix using Gauss-Jordan elimination with partial pivoting
isEmpty [line 254]
Checks if the matrix has been initialized.
isMatrix [line 1311]
Checks if the object is a Math_Matrix instance
Parameters:
isSquare [line 276]
Checks if it is a square matrix (i.e. num rows == num cols)
makeHankel [line 1444]
Returns a Hankel matrix from a array of size m (C), and (optionally) of an array if size n (R). C will define the first column and R the last row. If R is not defined, C will be used. Also, if the last element of C is not the same to the first element of R, the last element of C is used. H(i,j) = C(i+j-1), i+j-1 <= m H(i,j) = R(i+j-m), otherwise where: i = 1..m j = 1..n
Parameters:
makeHilbert [line 1413]
Returns a Hilbert matrix of the given size: H(i,j) = 1 / (i + j - 1) where {i,j = 1..n}
Parameters:
makeIdentity [line 1401]
Returns the identity matrix of the given size. An alias of Math_Matrix::makeUnit()
Parameters:
makeMatrix [line 1327]
object Math_Matrix|PEAR_Error &makeMatrix(
integer
$nrows, integer
$ncols, numeric
$value)
|
|
Returns a Math_Matrix object of size (nrows, ncols) filled with a value
Parameters:
makeOne [line 1348]
Returns the Math_Matrix object of size (nrows, ncols), filled with the value 1 (one)
Parameters:
makeUnit [line 1376]
Returns a square unit Math_Matrix object of the given size A unit matrix is one in which the elements follow the rules: e[i][j] = 1, if i == j e[i][j] = 0, if i != j Such a matrix is also called an 'identity matrix'
Parameters:
makeZero [line 1360]
Returns the Math_Matrix object of size (nrows, ncols), filled with the value 0 (zero)
Parameters:
multiply [line 1158]
Multiplies this matrix (A) by another one (B), and stores the result back in A
Parameters:
norm [line 291]
Returns the Euclidean norm of the matrix. Euclidean norm = sqrt( sum( e[i][j]^2 ) )
normalizedDeterminant [line 767]
number|PEAR_Error normalizedDeterminant(
)
|
|
Returns the normalized determinant = abs(determinant)/(euclidean norm)
readFromFile [line 1229]
void &readFromFile(
$filename, [
$format = 'serialized'])
|
|
Create a matrix from a file, using data stored in the given format
Parameters:
scale [line 1099]
boolean|PEAR_Error scale(
numeric
$scale)
|
|
Scales the matrix by a given factor
Parameters:
scaleRow [line 1125]
boolean|PEAR_Error scaleRow(
integer
$row, numeric
$factor)
|
|
Multiplies (scales) a row by the given factor
Parameters:
setCol [line 456]
boolean|PEAR_Error setCol(
integer
$col, array
$arr)
|
|
Sets the column with the given index to the array This method checks that the column is less than the size of the matrix columns, and that the array size equals the number of rows in the matrix.
Parameters:
setData [line 162]
boolean|PEAR_Error setData(
array
$data)
|
|
Validates the data and initializes the internal variables (except for the determinant). The validation is performed by by checking that each row (first dimension in the array of arrays) contains the same number of colums (e.g. arrays of the same size)
Parameters:
setElement [line 322]
boolean|PEAR_Error setElement(
integer
$row, integer
$col, numeric
$value)
|
|
Sets the value of the element at (row,col)
Parameters:
setRow [line 393]
boolean|PEAR_Error setRow(
integer
$row, array
$arr)
|
|
Sets the row with the given index to the array This method checks that the row is less than the size of the matrix rows, and that the array size equals the number of columns in the matrix.
Parameters:
setZeroThreshold [line 231]
boolean|PEAR_Error setZeroThreshold(
number
$epsilon)
|
|
Sets the threshold to consider a numeric value as zero: if number <= epsilon then number = 0
Parameters:
solve [line 1509]
Solves a system of linear equations: Ax = b A system such as: a11*x1 + a12*x2 + ... + a1n*xn = b1
a21*x1 + a22*x2 + ... + a2n*xn = b2
...
ak1*x1 + ak2*x2 + ... + akn*xn = bk can be rewritten as: Ax = b where: - A is matrix of coefficients (aij, i=1..k, j=1..n),
- b a vector of values (bi, i=1..k),
- x the vector of unkowns (xi, i=1..n)
Using: x = (Ainv)*b where:
Parameters:
solveEC [line 1566]
Solves a system of linear equations: Ax = b, using an iterative error correction algorithm A system such as: a11*x1 + a12*x2 + ... + a1n*xn = b1
a21*x1 + a22*x2 + ... + a2n*xn = b2
...
ak1*x1 + ak2*x2 + ... + akn*xn = bk can be rewritten as: Ax = b where: - A is matrix of coefficients (aij, i=1..k, j=1..n),
- b a vector of values (bi, i=1..k),
- x the vector of unkowns (xi, i=1..n)
Using: x = (Ainv)*b where: The error correction algorithm uses the approach that if: - xp is the approximate solution
- bp the values obtained from pluging xp into the original equation
We obtain
Parameters:
sub [line 1061]
Substracts a matrix from this one
Parameters:
swapCols [line 514]
boolean|PEAR_Error swapCols(
integer
$i, integer
$j)
|
|
Swaps the columns with the given indices
Parameters:
swapRowCol [line 541]
boolean|PEAR_Error swapRowCol(
integer
$row, integer
$col)
|
|
Swaps a given row with a given column. Only valid for square matrices.
Parameters:
swapRows [line 487]
boolean|PEAR_Error swapRows(
integer
$i, integer
$j)
|
|
Swaps the rows with the given indices
Parameters:
toHTML [line 960]
Returns an HTML table representation of the matrix elements
toString [line 936]
string|PEAR_Error toString(
[optional
$format = '%6.2f'])
|
|
Returns a simple string representation of the matrix
Parameters:
trace [line 668]
number|PEAR_Error trace(
)
|
|
Returns the trace of the matrix. Trace = sum(e[i][j]), for all i == j
transpose [line 643]
boolean|PEAR_Error transpose(
)
|
|
Transpose the matrix rows and columns
vectorMultiply [line 1198]
object Math_Vector|PEAR_Error &vectorMultiply(
&$v1, object Math_Vector
$v1)
|
|
Multiplies a vector by this matrix
Parameters:
writeToFile [line 1276]
boolean|PEAR_Error writeToFile(
object Math_Matrix
$matrix, string
$filename, [optional
$format = 'serialized'])
|
|
Writes matrix object to a file using the given format
Parameters:
_maxElementIndex [line 989]
Returns the index of the row with the maximum value under column of the element e[i][i]
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:39:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|