本文整理匯總了PHP中Matrix::rank方法的典型用法代碼示例。如果您正苦於以下問題:PHP Matrix::rank方法的具體用法?PHP Matrix::rank怎麽用?PHP Matrix::rank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Matrix
的用法示例。
在下文中一共展示了Matrix::rank方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: TestMatrix
function TestMatrix()
{
// define test variables
$errorCount = 0;
$warningCount = 0;
$columnwise = array(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0);
$rowwise = array(1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0);
$avals = array(array(1.0, 4.0, 7.0, 10.0), array(2.0, 5.0, 8.0, 11.0), array(3.0, 6.0, 9.0, 12.0));
$rankdef = $avals;
$tvals = array(array(1.0, 2.0, 3.0), array(4.0, 5.0, 6.0), array(7.0, 8.0, 9.0), array(10.0, 11.0, 12.0));
$subavals = array(array(5.0, 8.0, 11.0), array(6.0, 9.0, 12.0));
$rvals = array(array(1.0, 4.0, 7.0), array(2.0, 5.0, 8.0, 11.0), array(3.0, 6.0, 9.0, 12.0));
$pvals = array(array(1.0, 1.0, 1.0), array(1.0, 2.0, 3.0), array(1.0, 3.0, 6.0));
$ivals = array(array(1.0, 0.0, 0.0, 0.0), array(0.0, 1.0, 0.0, 0.0), array(0.0, 0.0, 1.0, 0.0));
$evals = array(array(0.0, 1.0, 0.0, 0.0), array(1.0, 0.0, 2.0E-7, 0.0), array(0.0, -2.0E-7, 0.0, 1.0), array(0.0, 0.0, 1.0, 0.0));
$square = array(array(166.0, 188.0, 210.0), array(188.0, 214.0, 240.0), array(210.0, 240.0, 270.0));
$sqSolution = array(array(13.0), array(15.0));
$condmat = array(array(1.0, 3.0), array(7.0, 9.0));
$rows = 3;
$cols = 4;
$invalidID = 5;
/* should trigger bad shape for construction with val */
$raggedr = 0;
/* (raggedr,raggedc) should be out of bounds in ragged array */
$raggedc = 4;
$validID = 3;
/* leading dimension of intended test Matrices */
$nonconformld = 4;
/* leading dimension which is valid, but nonconforming */
$ib = 1;
/* index ranges for sub Matrix */
$ie = 2;
$jb = 1;
$je = 3;
$rowindexset = array(1, 2);
$badrowindexset = array(1, 3);
$columnindexset = array(1, 2, 3);
$badcolumnindexset = array(1, 2, 4);
$columnsummax = 33.0;
$rowsummax = 30.0;
$sumofdiagonals = 15;
$sumofsquares = 650;
/**
* Test matrix methods
*/
/**
* Constructors and constructor-like methods:
*
* Matrix(double[], int)
* Matrix(double[][])
* Matrix(int, int)
* Matrix(int, int, double)
* Matrix(int, int, double[][])
* constructWithCopy(double[][])
* random(int,int)
* identity(int)
*/
echo "<p>Testing constructors and constructor-like methods...</p>";
$A = new Matrix($columnwise, 3);
if ($A instanceof Matrix) {
$this->try_success("Column-packed constructor...");
} else {
$errorCount = $this->try_failure($errorCount, "Column-packed constructor...", "Unable to construct Matrix");
}
$T = new Matrix($tvals);
if ($T instanceof Matrix) {
$this->try_success("2D array constructor...");
} else {
$errorCount = $this->try_failure($errorCount, "2D array constructor...", "Unable to construct Matrix");
}
$A = new Matrix($columnwise, $validID);
$B = new Matrix($avals);
$tmp = $B->get(0, 0);
$avals[0][0] = 0.0;
$C = $B->minus($A);
$avals[0][0] = $tmp;
$B = Matrix::constructWithCopy($avals);
$tmp = $B->get(0, 0);
$avals[0][0] = 0.0;
/** check that constructWithCopy behaves properly **/
if ($tmp - $B->get(0, 0) != 0.0) {
$errorCount = $this->try_failure($errorCount, "constructWithCopy... ", "copy not effected... data visible outside");
} else {
$this->try_success("constructWithCopy... ", "");
}
$I = new Matrix($ivals);
if ($this->checkMatrices($I, Matrix::identity(3, 4))) {
$this->try_success("identity... ", "");
} else {
$errorCount = $this->try_failure($errorCount, "identity... ", "identity Matrix not successfully created");
}
/**
* Access Methods:
*
* getColumnDimension()
* getRowDimension()
* getArray()
* getArrayCopy()
* getColumnPackedCopy()
* getRowPackedCopy()
//.........這裏部分代碼省略.........