PHP Класс MathPHP\LinearAlgebra\MatrixFactory

Use factory instead of instantiating individual Matrix classes.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
create ( array $A, integer $n = null ) : Matrix Factory method
eye ( integer $m, integer $n, integer $k, number $x = 1 ) : Matrix Eye matrix - ones on the k diagonal and zeros everywhere else.
identity ( integer $n, number $x = 1 ) : SquareMatrix Identity matrix - n x n matrix with ones in the diagonal Option to set the diagonal to any number.
one ( integer $m, integer $n ) : Matrix Ones matrix - m x n matrix with all elements being ones
zero ( integer $m, integer $n ) : Matrix Zero matrix - m x n matrix with all elements being zeros

Приватные методы

Метод Описание
checkParams ( array $A, integer $n = null ) : boolean Check input parameters
determineMatrixType ( array $A, $vandermonde_n ) : string Determine what type of matrix to create

Описание методов

create() публичный статический Метод

Factory method
public static create ( array $A, integer $n = null ) : Matrix
$A array 1- or 2-dimensional array of Matrix data 1-dimensional array for Diagonal and Vandermonde matrices 2-dimensional array for Square, Function, and regular Matrices
$n integer Optional n for Vandermonde matrix
Результат Matrix

eye() публичный статический Метод

Diagonal can start at any column. Option to set the diagonal to any number. Example: m = 3; n = 3; k = 1; x = 1 (3x3 matrix with 1s on the kth (1) diagonal) [0 1 0] A = [0 0 1] [0 0 0]
public static eye ( integer $m, integer $n, integer $k, number $x = 1 ) : Matrix
$m integer number of rows
$n integer number of columns
$k integer Diagonal to fill with xs
$x number (optional; default 1)
Результат Matrix

identity() публичный статический Метод

Example: n = 3; x = 1 [1 0 0] A = [0 1 0] [0 0 1]
public static identity ( integer $n, number $x = 1 ) : SquareMatrix
$n integer size of matrix
$x number (optional; default 1)
Результат SquareMatrix

one() публичный статический Метод

Example: m = 3; n = 3 [1 1 1] A = [1 1 1] [1 1 1]
public static one ( integer $m, integer $n ) : Matrix
$m integer rows
$n integer columns
Результат Matrix

zero() публичный статический Метод

Example: m = 3; n = 3 [0 0 0] A = [0 0 0] [0 0 0]
public static zero ( integer $m, integer $n ) : Matrix
$m integer rows
$n integer columns
Результат Matrix