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

Public Member Functions

 execute ($value)
 Execute the addition. More...
 
- Public Member Functions inherited from Matrix\Operators\Operator
 __construct (Matrix $matrix)
 Create an new handler object for the operation. More...
 
 result ()
 Return the result of the operation. More...
 

Protected Member Functions

 addScalar ($value)
 Execute the addition for a scalar. More...
 
 addMatrix (Matrix $value)
 Execute the addition for a matrix. More...
 
- Protected Member Functions inherited from Matrix\Operators\Operator
 validateMatchingDimensions (Matrix $matrix)
 Compare the dimensions of the matrices being operated on to see if they are valid for addition/subtraction. More...
 
 validateReflectingDimensions (Matrix $matrix)
 Compare the dimensions of the matrices being operated on to see if they are valid for multiplication/division. More...
 

Additional Inherited Members

- Protected Attributes inherited from Matrix\Operators\Operator
 $matrix
 
 $rows
 Number of rows in the matrix. More...
 
 $columns
 Number of columns in the matrix. More...
 

Detailed Description

Definition at line 8 of file Addition.php.

Member Function Documentation

◆ addMatrix()

Matrix\Operators\Addition::addMatrix ( Matrix  $value)
protected

Execute the addition for a matrix.

Parameters
Matrix$valueThe numeric value to add to the current base value
Returns
$this The operation object, allowing multiple additions to be chained
Exceptions
ExceptionIf the provided argument is not appropriate for the operation

Definition at line 56 of file Addition.php.

56 : Operator
57 {
58 $this->validateMatchingDimensions($value);
59
60 for ($row = 0; $row < $this->rows; ++$row) {
61 for ($column = 0; $column < $this->columns; ++$column) {
62 $this->matrix[$row][$column] += $value->getValue($row + 1, $column + 1);
63 }
64 }
65
66 return $this;
67 }
getValue(int $row, int $column)
Return a value from this matrix, from the "cell" identified by the row and column numbers Note that r...
Definition: Matrix.php:268
validateMatchingDimensions(Matrix $matrix)
Compare the dimensions of the matrices being operated on to see if they are valid for addition/subtra...
Definition: Operator.php:49
$rows
Number of rows in the matrix.
Definition: Operator.php:22
$columns
Number of columns in the matrix.
Definition: Operator.php:29
$row

References Matrix\Operators\Operator\$columns, $row, Matrix\Operators\Operator\$rows, Matrix\Matrix\getValue(), and Matrix\Operators\Operator\validateMatchingDimensions().

Referenced by Matrix\Operators\Addition\execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addScalar()

Matrix\Operators\Addition::addScalar (   $value)
protected

Execute the addition for a scalar.

Parameters
mixed$valueThe numeric value to add to the current base value
Returns
$this The operation object, allowing multiple additions to be chained

Definition at line 38 of file Addition.php.

38 : Operator
39 {
40 for ($row = 0; $row < $this->rows; ++$row) {
41 for ($column = 0; $column < $this->columns; ++$column) {
42 $this->matrix[$row][$column] += $value;
43 }
44 }
45
46 return $this;
47 }

References Matrix\Operators\Operator\$columns, $row, and Matrix\Operators\Operator\$rows.

Referenced by Matrix\Operators\Addition\execute().

+ Here is the caller graph for this function:

◆ execute()

Matrix\Operators\Addition::execute (   $value)

Execute the addition.

Parameters
mixed$valueThe matrix or numeric value to add to the current base value
Exceptions
ExceptionIf the provided argument is not appropriate for the operation
Returns
$this The operation object, allowing multiple additions to be chained

Definition at line 17 of file Addition.php.

17 : Operator
18 {
19 if (is_array($value)) {
20 $value = new Matrix($value);
21 }
22
23 if (is_object($value) && ($value instanceof Matrix)) {
24 return $this->addMatrix($value);
25 } elseif (is_numeric($value)) {
26 return $this->addScalar($value);
27 }
28
29 throw new Exception('Invalid argument for addition');
30 }
addScalar($value)
Execute the addition for a scalar.
Definition: Addition.php:38
addMatrix(Matrix $value)
Execute the addition for a matrix.
Definition: Addition.php:56
Class for the creating "special" Matrices.
Definition: Builder.php:11

References Matrix\Operators\Addition\addMatrix(), and Matrix\Operators\Addition\addScalar().

+ Here is the call graph for this function:

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