本文整理汇总了PHP中Matrix::getRowDimension方法的典型用法代码示例。如果您正苦于以下问题:PHP Matrix::getRowDimension方法的具体用法?PHP Matrix::getRowDimension怎么用?PHP Matrix::getRowDimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::getRowDimension方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkMatrixDimensions
/**
* checkMatrixDimensions
*
* Is matrix B the same size?
* @param Matrix $B Matrix B
* @return boolean
*/
public function checkMatrixDimensions($B = null)
{
if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
if ($this->m == $B->getRowDimension() && $this->n == $B->getColumnDimension()) {
return true;
} else {
throw new PHPExcel_Calculation_Exception(self::MATRIX_DIMENSION_EXCEPTION);
}
} else {
throw new PHPExcel_Calculation_Exception(self::ARGUMENT_TYPE_EXCEPTION);
}
}
示例2: checkMatrixDimensions
/**
* checkMatrixDimensions
*
* Is matrix B the same size?
* @param Matrix $B Matrix B
* @return boolean
*/
public function checkMatrixDimensions($B = null)
{
if ($B instanceof Matrix) {
if ($this->m == $B->getRowDimension() && $this->n == $B->getColumnDimension()) {
return true;
} else {
throw new Exception(JAMAError(MatrixDimensionException));
}
} else {
throw new Exception(JAMAError(ArgumentTypeException));
}
}
示例3: TestMatrix
//.........这里部分代码省略.........
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()
* 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
示例4: solve
/**
* Least squares solution of A*X = B
*
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
*/
public function solve($B)
{
if ($B->getRowDimension() == $this->m) {
if ($this->isFullRank()) {
// Copy right hand side
$nx = $B->getColumnDimension();
$X = $B->getArrayCopy();
// Compute Y = transpose(Q)*B
for ($k = 0; $k < $this->n; ++$k) {
for ($j = 0; $j < $nx; ++$j) {
$s = 0.0;
for ($i = $k; $i < $this->m; ++$i) {
$s += $this->QR[$i][$k] * $X[$i][$j];
}
$s = -$s / $this->QR[$k][$k];
for ($i = $k; $i < $this->m; ++$i) {
$X[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
// Solve R*X = Y;
for ($k = $this->n - 1; $k >= 0; --$k) {
for ($j = 0; $j < $nx; ++$j) {
$X[$k][$j] /= $this->Rdiag[$k];
}
for ($i = 0; $i < $k; ++$i) {
for ($j = 0; $j < $nx; ++$j) {
$X[$i][$j] -= $X[$k][$j] * $this->QR[$i][$k];
}
}
}
$X = new PHPExcel_Shared_JAMA_Matrix($X);
return $X->getMatrix(0, $this->n - 1, 0, $nx);
} else {
throw new Exception(self::MatrixRankException);
}
} else {
throw new Exception(PHPExcel_Shared_JAMA_Matrix::MatrixDimensionException);
}
}
示例5: checkMatrixDimensions
/**
* checkMatrixDimensions
*
* Is matrix B the same size?
* @param Matrix $B Matrix B
* @return boolean
*/
public function checkMatrixDimensions($B = null)
{
if ($B instanceof PHPExcel_Shared_JAMA_Matrix) {
if ($this->m == $B->getRowDimension() && $this->n == $B->getColumnDimension()) {
return true;
} else {
throw new PHPExcel_Calculation_Exception(self::MatrixDimensionException);
}
} else {
throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException);
}
}
示例6: solve
/**
* Least squares solution of A*X = B
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
*/
function solve($B)
{
if ($B->getRowDimension() == $this->m) {
if ($this->isFullRank()) {
// Copy right hand side
$nx = $B->getColumnDimension();
$X = $B->getArrayCopy();
// Compute Y = transpose(Q)*B
for ($k = 0; $k < $this->n; $k++) {
for ($j = 0; $j < $nx; $j++) {
$s = 0.0;
for ($i = $k; $i < $this->m; $i++) {
$s += $this->QR[$i][$k] * $X[$i][$j];
}
$s = -$s / $this->QR[$k][$k];
for ($i = $k; $i < $this->m; $i++) {
$X[$i][$j] += $s * $this->QR[$i][$k];
}
}
}
// Solve R*X = Y;
for ($k = $this->n - 1; $k >= 0; $k--) {
for ($j = 0; $j < $nx; $j++) {
$X[$k][$j] /= $this->Rdiag[$k];
}
for ($i = 0; $i < $k; $i++) {
for ($j = 0; $j < $nx; $j++) {
$X[$i][$j] -= $X[$k][$j] * $this->QR[$i][$k];
}
}
}
$X = new Matrix($X);
return $X->getMatrix(0, $this->n - 1, 0, $nx);
} else {
trigger_error(MatrixRankException, ERROR);
}
} else {
trigger_error(MatrixDimensionException, ERROR);
}
}