function Matrix::row_vectors in Recommender API 7.6
Same name and namespace in other branches
- 6.2 Matrix.php \Matrix::row_vectors()
Only return the row vectors that have at least one element. Work for both RealMatrix and SparseMatrix
Return value
unknown_type
File
- classes/
Matrix.php, line 67
Class
- Matrix
- This PHP file does not require 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
function row_vectors() {
// $this could be either RealMatrix or SparseMatrix
$type = $this instanceof RealMatrix ? 'RealVector' : 'SparseVector';
$vectors = array();
foreach ($this->values as $row_i => &$row_value) {
$vectors[$row_i] = Vector::wrap($type, $row_value);
// note, by default this is passing by reference.
}
return $vectors;
// don't have to return by reference.
// Do not use return-by-reference to increase performance. The engine will automatically optimize this on its own. Only return references when you have a valid technical reason to do so.
}