Compute the means of each row and return them in a vector.

@throws \InvalidArgumentException
@return \Rubix\Tensor\ColumnVector
341830
public function mean() : ColumnVector
    {
        if ($this->n < 1) {
            throw new RuntimeException('Median is not defined for matrices'
                . ' with less than 1 column.');
        }

        return $this->sum()->divide($this->n);
    }
523728
public function getColModel()
    {
        if (count($this->colNames) != count($this->colModel)) {
            throw new \InvalidArgumentException('The number of colNames is not equal to the number of colModel');
        } 

        return $this->colModel;
    }
953033
public function less($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->lessMatrix($b);
                break;
            
            case $b instanceof ColumnVector:
                $c = $this->lessColumnVector($b);
                break;

            case $b instanceof Vector:
                $c = $this->lessVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->lessScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot compare matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
1076550
public function getValues()
    {
        while ($row = $this->getNextRow()) {
            if ($this->columnCount() > 1) {
                $key = rtrim(reset($row));
                $val = rtrim(next($row));
                yield $key => $val;
            } else {
                yield rtrim(reset($row));
            }
        }
    }
679998
public function subtract($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->subtractMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->subtractColumnVector($b);
                break;
                
            case $b instanceof Vector:
                $c = $this->subtractVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->subtractScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot subtract a '
                    . gettype($b) . ' from a matrix.');
        }

        return $c;
    }
314238
public function toArray()
    {
        $returnValue = array();

        

		//sort columns:
		$this->sortColumns();

		foreach($this->rows as $rowId => $cells){
			$returnValue[$rowId] = array();

			foreach($this->columns as $columnId => $column){
				if($column->hasAdapter()){

					//fill content with adapter:
					$data = null;
					if(isset($returnValue[$rowId][$columnId])){
						$data = $returnValue[$rowId][$columnId];
					}else if(isset($cells[$columnId])){
						$data = $cells[$columnId];
					}
					$returnValue[$rowId][$columnId] = $column->getAdaptersData($rowId, $data);

				}else if(isset($cells[$columnId])){

					if($cells[$columnId] instanceof tao_helpers_grid_Grid){
						$returnValue[$rowId][$columnId] = $cells[$columnId]->toArray();
					}else{
						$returnValue[$rowId][$columnId] = $cells[$columnId];
					}

				}else{
					$returnValue[$rowId][$columnId] = null;//empty cell
				}
			}

		}
        

        return (array) $returnValue;
    }
597720
public function rows()
	{
		$rows = parent::rows();

		// Now remove any associative fields
		foreach ($rows as $row)
		{
			$associatives = new \stdClass();

			foreach ($row->getAttributes() as $k => $v)
			{
				if (strpos($k, 'associative_') === 0)
				{
					$key = substr($k, 12);
					$associatives->$key = $v;
					$row->removeAttribute($k);
				}
			}

			if (!empty($associatives))
			{
				$row->associated = $associatives;
			}
		}

		return $rows;
	}
347831
public function getS()
    {
        for ($i = 0; $i < $this->n; ++$i) {
            for ($j = 0; $j < $this->n; ++$j) {
                $S[$i][$j] = 0.0;
            }
            $S[$i][$i] = $this->s[$i];
        }
        return new Matrix($S);
    }
178137
public ConcatVectorTableProto.ConcatVectorTable.Builder getProtoBuilder() {
        ConcatVectorTableProto.ConcatVectorTable.Builder b = ConcatVectorTableProto.ConcatVectorTable.newBuilder();
        for (int n : getDimensions()) {
            b.addDimensionSize(n);
        }
        for (int[] assignment : this) {
            b.addFactorTable(getAssignmentValue(assignment).get().getProtoBuilder());
        }
        return b;
    }
1005046
public function transpose() : self
    {
        if ($this->m > 1) {
            $b = array_map(null, ...$this->a);
        } else {
            $b = [];

            for ($i = 0; $i < $this->n; $i++) {
                $b[] = array_column($this->a, $i);
            }
        }

        return self::quick($b);
    }
1340344
public function greaterEqual($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->greaterEqualMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->greaterEqualColumnVector($b);
                break;

            case $b instanceof Vector:
                $c = $this->greaterEqualVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->greaterEqualScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot compare matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
1194756
public function rref() : self
    {
        [$b, $swaps] = $this->ref();

        $b = $b->asArray();

        $row = $col = 0;

        while ($row < $this->m and $col < $this->n) {
            $t = $b[$row];

            if (abs($t[$col]) == 0) {
                $col++;

                continue 1;
            }

            $divisor = $t[$col];

            if ($divisor != 1) {
                for ($i = 0; $i < $this->n; $i++) {
                    $t[$i] /= $divisor;
                }
            }

            for ($i = $row - 1; $i >= 0; $i--) {
                $scale = $b[$i][$col];

                if ($scale != 0) {
                    for ($j = 0; $j < $this->n; $j++) {
                        $b[$i][$j] += -$scale * $t[$j];
                    }
                }
            }

            $b[$row] = $t;

            $row++;
            $col++;
        }

        return self::quick($b);
    }
223353
public function getAdjoinMatrix() : Matrix {
        $matrix = new static();
        for ($i=0; $i<static::ROWS; $i++) {
            for ($j=0; $j<static::COLUMNS; $j++) {
                $subMatrix      = MatrixMath::getSubMatrix($this->toArray(), $i, $j);
                $matrix[$i][$j] = MatrixMath::calculateDeterminant($subMatrix);
            }
        }
        return $matrix;
    }
454790
public function lessEqual($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->lessEqualMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->lessEqualColumnVector($b);
                break;
            
            case $b instanceof Vector:
                $c = $this->lessEqualVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->lessEqualScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot compare matrix'
                    . ' to a ' . gettype($b) . '.');
        }

        return $c;
    }
292790
public function median()
    {
        if ($this->n < 1) {
            throw new RuntimeException('Median is not defined for vectors'
                . ' with less than 1 element.');
        }

        $mid = intdiv($this->n, 2);

        $a = $this->a;

        sort($a);

        if ($this->n % 2 === 1) {
            $median = $a[$mid];
        } else {
            $median = ($a[$mid - 1] + $a[$mid]) / 2.;
        }

        return $median;
    }
650060
public function divide($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->divideMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->divideColumnVector($b);
                break;
            
            case $b instanceof Vector:
                $c = $this->divideVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->divideScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot divide matrix'
                    . ' with a ' . gettype($b) . '.');
        }

        return $c;
    }
771897
public RowVector getRow(int r) throws MatrixException
    {
        if ((r < 0) || (r >= nRows)) {
            throw new MatrixException(MatrixException.INVALID_INDEX);
        }

        RowVector rv = new RowVector(nCols);
        for (int c = 0; c < nCols; ++c) {
            rv.values[0][c] = this.values[r][c];
        }

        return rv;
    }