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.

References $columns, and $rows.

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

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

References $grid, and $x.

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  }
$grid
Definition: test.php:8
Class for the creating "special" Matrices.
Definition: Builder.php:11
$x
Definition: complexTest.php:9

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