/**
  * Construct a SparseMatrixAsArray
  * with the specified dimensions and row fill.
  *
  * @param integer $numRows The number of rows.
  * @param integer $numCols The number of columns.
  * @param integer $fill The maximum number of non-zero entries in any row.
  */
 public function __construct($numRows, $numCols, $fill)
 {
     parent::__construct($numRows, $numCols);
     $this->fill = $fill;
     $this->values = new DenseMatrix($numRows, $fill);
     $this->columns = new DenseMatrix($numRows, $fill);
     for ($i = 0; $i < $this->numRows; ++$i) {
         $this->columns[array($i, 0)] = self::END_OF_ROW;
     }
 }
Beispiel #2
0
 /**
  * Constructs a DenseMatrix with the given number of rows and columns.
  *
  * @param integer $rows The number of rows.
  * @param integer $columns The number of columns.
  */
 public function __construct($rows, $columns)
 {
     parent::__construct($rows, $columns);
     $this->array = new MultiDimensionalArray(array($rows, $columns));
 }
 /**
  * Construct a SparseMatrixAsVector
  * with the specified dimensions and maximum number of non-zero elements.
  *
  * @param integer $numRows The number of rows.
  * @param integer $numCols The number of columns.
  * @param integer $maxElements The maximum number of non-zero elements
  * in this matrix.
  */
 public function __construct($numRows, $numCols, $maxElements)
 {
     parent::__construct($numRows, $numCols);
     $this->array = new BasicArray($maxElements);
     for ($i = 0; $i < $maxElements; ++$i) {
         $this->array[$i] = new SparseMatrixAsVector_Entry();
     }
     $this->numberOfElements = 0;
 }
 /**
  * Construct a <code>SparseMatrixAsLinkedLists</code>
  * with the specified dimensions.
  *
  * @param integer $numRows The number of rows.
  * @param integer $numCols The number of columns.
  */
 public function __construct($numRows, $numCols)
 {
     parent::__construct($numRows, $numCols);
     $this->lists = new BasicArray($numRows);
     for ($i = 0; $i < $this->numRows; ++$i) {
         $this->lists[$i] = new LinkedList();
     }
 }