本文整理汇总了PHP中Matrix::getArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Matrix::getArray方法的具体用法?PHP Matrix::getArray怎么用?PHP Matrix::getArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::getArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TestMatrix
//.........这里部分代码省略.........
}
/**
* Access Methods:
*
* getColumnDimension()
* getRowDimension()
* getArray()
* getArrayCopy()
* getColumnPackedCopy()
* getRowPackedCopy()
* get(int,int)
* getMatrix(int,int,int,int)
* getMatrix(int,int,int[])
* getMatrix(int[],int,int)
* getMatrix(int[],int[])
* set(int,int,double)
* setMatrix(int,int,int,int,Matrix)
* setMatrix(int,int,int[],Matrix)
* setMatrix(int[],int,int,Matrix)
* setMatrix(int[],int[],Matrix)
*/
print "<p>Testing access methods...</p>";
$B = new Matrix($avals);
if ($B->getRowDimension() == $rows) {
$this->try_success("getRowDimension...");
} else {
$errorCount = $this->try_failure($errorCount, "getRowDimension...");
}
if ($B->getColumnDimension() == $cols) {
$this->try_success("getColumnDimension...");
} else {
$errorCount = $this->try_failure($errorCount, "getColumnDimension...");
}
$barray = $B->getArray();
if ($this->checkArrays($barray, $avals)) {
$this->try_success("getArray...");
} else {
$errorCount = $this->try_failure($errorCount, "getArray...");
}
$bpacked = $B->getColumnPackedCopy();
if ($this->checkArrays($bpacked, $columnwise)) {
$this->try_success("getColumnPackedCopy...");
} else {
$errorCount = $this->try_failure($errorCount, "getColumnPackedCopy...");
}
$bpacked = $B->getRowPackedCopy();
if ($this->checkArrays($bpacked, $rowwise)) {
$this->try_success("getRowPackedCopy...");
} else {
$errorCount = $this->try_failure($errorCount, "getRowPackedCopy...");
}
/**
* Array-like methods:
* minus
* minusEquals
* plus
* plusEquals
* arrayLeftDivide
* arrayLeftDivideEquals
* arrayRightDivide
* arrayRightDivideEquals
* arrayTimes
* arrayTimesEquals
* uminus
*/
print "<p>Testing array-like methods...</p>";
示例2: mpMatrix
/**
* Multiply Matrices
*
* This function will multiply the current matrix with the matrix provided.
* If current Matrix is denoted by 'A' and the inputted is denoted by 'B',
* When written, this will return AB.
*
* @link http://en.wikipedia.org/wiki/Matrix_multiplication
* @param Matrix $bMatrix The matrix to multiply with the current
* @return Matrix The result of multiplication.
* @throws \Exception $msg explains why operation failed
*/
public function mpMatrix(Matrix $bMatrix)
{
if (!$this->_verify() || !$bMatrix->_verify()) {
$eM1 = $this->toString();
$eM2 = $bMatrix->toString();
throw new \Exception("Either '{$eM1}' and/or '{$eM2}' is not a valid Matrix", Matrix::E_INVALID_MATRIX);
}
$aArray = $this->matrix;
$bArray = $bMatrix->getArray();
//The number of columns in A must match the number of rows in B
if (count($aArray[0]) != count($bArray)) {
$mA = $this->toString();
$mB = $bMatrix->toString();
throw new \Exception("Columns in '{$mA}' don't match Rows of '{$mB}'", Matrix::E_NOT_EQUAL);
}
$rArray = array();
//Loop through rows of Matrix A
for ($i = 0; $i < count($aArray); $i++) {
//Loop through the columns of Matrix B
for ($j = 0; $j < count($bArray[0]); $j++) {
$value = 0;
//loop through the rows of Matrix B
for ($k = 0; $k < count($bArray); $k++) {
$value += $aArray[$i][$k] * $bArray[$k][$j];
}
$rArray[$i][$j] = $value;
}
}
$rMatrix = new Matrix($this->toString($rArray));
return $rMatrix;
}
示例3: testGetArray
public function testGetArray()
{
$arr = array(array(1, 2, 3), array(3, 4, 5));
$this->assertEquals($arr, $this->A->getArray());
}
示例4: __construct
/**
* Constructor: Check for symmetry, then construct the eigenvalue decomposition
*
* @param Matrix $Arg
* @internal param Matrix $Arg Square matrix
*/
public function __construct($Arg)
{
$this->A = $Arg->getArray();
$this->n = $Arg->getColumnDimension();
$isSymmetric = true;
for ($j = 0; $j < $this->n & $isSymmetric; ++$j) {
for ($i = 0; $i < $this->n & $isSymmetric; ++$i) {
$isSymmetric = $this->A[$i][$j] == $this->A[$j][$i];
}
}
if ($isSymmetric) {
$this->V = $this->A;
// Tri-diagonalize.
$this->tRed();
// Diagonalize.
$this->tql2();
} else {
$this->H = $this->A;
$this->ort = array();
// Reduce to Hessenberg form.
$this->ortHes();
// Reduce Hessenberg to real Schur form.
$this->hqr2();
}
}