ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Matrix\Builder Class Reference
+ Collaboration diagram for Matrix\Builder:

Static Public Member Functions

static createFilledMatrix ($fillValue, $rows, $columns=null)
 Create a new matrix of specified dimensions, and filled with a specified value If the column argument isn't provided, then a square matrix will be created. More...
 
static createIdentityMatrix ($dimensions, $fillValue=null)
 Create a new identity matrix of specified dimensions This will always be a square matrix, with the number of rows and columns matching the provided dimension. More...
 

Detailed Description

Definition at line 18 of file Builder.php.

Member Function Documentation

◆ createFilledMatrix()

static Matrix\Builder::createFilledMatrix (   $fillValue,
  $rows,
  $columns = null 
)
static

Create a new matrix of specified dimensions, and filled with a specified value If the column argument isn't provided, then a square matrix will be created.

Parameters
mixed$fillValue
int$rows
int | null$columns
Returns
Matrix
Exceptions
Exception

Definition at line 30 of file Builder.php.

31 {
32 if ($columns === null) {
34 }
35
38
39 return new Matrix(
40 array_fill(
41 0,
42 $rows,
43 array_fill(
44 0,
46 $fillValue
47 )
48 )
49 );
50 }
if(! $in) $columns
Definition: Utf8Test.php:45
static validateColumn(int $column)
Validate that a column number is a positive integer.
Definition: Matrix.php:110
static validateRow(int $row)
Validate that a row number is a positive integer.
Definition: Matrix.php:94
Class for the creating "special" Matrices.
Definition: Builder.php:11
$rows
Definition: xhr_table.php:10

References $columns, and $rows.

Referenced by PhpOffice\PhpSpreadsheet\Calculation\MathTrig\MatrixFunctions\identity(), and Matrix\Operators\Multiplication\multiplyMatrix().

+ Here is the caller graph for this function:

◆ createIdentityMatrix()

static Matrix\Builder::createIdentityMatrix (   $dimensions,
  $fillValue = null 
)
static

Create a new identity matrix of specified dimensions This will always be a square matrix, with the number of rows and columns matching the provided dimension.

Parameters
int$dimensions
Returns
Matrix
Exceptions
Exception

Definition at line 60 of file Builder.php.

61 {
62 $grid = static::createFilledMatrix($fillValue, $dimensions)->toArray();
63
64 for ($x = 0; $x < $dimensions; ++$x) {
65 $grid[$x][$x] = 1;
66 }
67
68 return new Matrix($grid);
69 }
$x
Definition: complexTest.php:9
$grid
Definition: test.php:8

References $grid, and $x.


The documentation for this class was generated from the following file: