static function Matrix::create in Recommender API 6.2
Same name and namespace in other branches
- 7.6 classes/Matrix.php \Matrix::create()
6 calls to Matrix::create()
- CorrelationRecommender::computePredictionMemory in ./Recommender.php
- CorrelationRecommender::_computePredictionMemory in ./Recommender.php
- Matrix::correlation in ./Matrix.php
- Compute the covariance matrix for the row vectors.
- Recommender::loadDirectMatrix in ./Recommender.php
- Load matrix from the database into a matrix class in memory
- Recommender::loadSimilarityMatrix in ./Recommender.php
... See full list
File
- ./Matrix.php, line 26
Class
- Matrix
- This PHP file has to work with Drupal.
Including both Matrix and Vector implementation.
Missing data are treated as NAN.
Some extra complexity comes from trying to increase memory/cpu performance
Note, this implementation does check input parameters.…
Code
static function create($type, $row, $column, $value = 0) {
if ($type == 'SparseMatrix') {
$matrix = new SparseMatrix();
$matrix->values = array();
}
elseif ($type == 'RealMatrix') {
$matrix = new RealMatrix();
$matrix->values = array_fill(0, $row, array_fill(0, $column, $value));
}
else {
trigger_error('Matrix type not recognized', E_USER_ERROR);
}
$matrix->row = $row;
$matrix->column = $column;
return $matrix;
}