ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Builder.php
Go to the documentation of this file.
1 <?php
2 
11 namespace Matrix;
12 
18 class Builder
19 {
30  public static function createFilledMatrix($fillValue, $rows, $columns = null)
31  {
32  if ($columns === null) {
33  $columns = $rows;
34  }
35 
36  $rows = Matrix::validateRow($rows);
37  $columns = Matrix::validateColumn($columns);
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  }
51 
60  public static function createIdentityMatrix($dimensions, $fillValue = null)
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  }
70 }
$grid
Definition: test.php:8
static createFilledMatrix($fillValue, $rows, $columns=null)
Create a new matrix of specified dimensions, and filled with a specified value If the column argument...
Definition: Builder.php:30
static createIdentityMatrix($dimensions, $fillValue=null)
Create a new identity matrix of specified dimensions This will always be a square matrix...
Definition: Builder.php:60
$rows
Definition: xhr_table.php:10
Class for the creating "special" Matrices.
Definition: Builder.php:11
if(! $in) $columns
Definition: Utf8Test.php:45
$x
Definition: complexTest.php:9