/*!
\private
Helper method to matrices.
186300
function dumpMatrix( $arr, $rows, $cols )
    {
        for ( $i = 0; $i < $rows; $i++ )
        {
            for ( $j = 0; $j < $cols; $j++ )
            {
                print( $arr->get( $i, $j ) . " " );
                if ( $j == $cols-1 )
                    print( "\n" );
            }
        }
    }
1182020
function(matrix) {
  const rows = matrix.length;
  const columns = matrix[0].length;
  const res = [];
  for (let row = 0; row < rows; ++row) {
    res.push([]);
    for (let column = 0; column < columns; ++column) {
      res[row][column] = matrix[column][columns - row - 1];
    }
  }
  return res;
}
173161
public static Matrix from1DArray(int rows, int columns, double[] array) {
        return Basic1DMatrix.from1DArray(rows, columns, array);
    }
1105523
public void applyMatrix()
	{
		transformMatrix.translate(new Vector3f(-0.5F, -0.5F, -0.5F));

		for (Vertex v : vertexes)
			v.applyMatrix(transformMatrix);

		resetMatrix();

		return;
	}
172290
public static function transpose(Matrix $matrix)
    {
        $grid = call_user_func_array(
            'array_map',
            array_merge(
                [null],
                $matrix->toArray()
            )
        );

        return new Matrix($grid);
    }
212048
function(a, b, c, d) {
            	var elements = [], ni = c, i, nj, j;
            	var rows = this.elements.length, cols = this.elements[0].length;
            	while (ni--) {
            	    i = c - ni - 1;
            	    elements[i] = [];
            	    nj = d;
            	    while (nj--) {
            		j = d - nj - 1;
            		elements[i][j] = this.elements[(a + i - 1) % rows][(b + j - 1) % cols];
            	    }
            	}
            	return Matrix$b.create(elements);
                }
513784
def to_nmatrix
      each_vector.select do |vector|
        vector.numeric? && !vector.include_values?(*Daru::MISSING_VALUES)
      end.map(&:to_a).transpose.to_nm
    end
778870
function() {
    var rows = this.elements.length, cols = this.elements[0].length;
    var elements = [], ni = cols, i, nj, j;
    do { i = cols - ni;
      elements[i] = [];
      nj = rows;
      do { j = rows - nj;
        elements[i][j] = this.elements[j][i];
      } while (--nj);
    } while (--ni);
    return Matrix.create(elements);
  }
1327515
protected function get_CellMatrix() {

    $matrix = new CellMatrix(
      $this->nRows,
      $this->MatrixEmptyRow);

    $cellClassesIndexed = [];
    foreach ($this->CellClasses as $rowName => $rowCellClasses) {
      if ($this->rows->nameIsLeaf($rowName)) {
        $iRow = $this->rows->subtreeIndex($rowName);
        $rowCellClassesIndexed = [];
        foreach ($rowCellClasses as $colName => $classes) {
          if ($this->columns->nameIsLeaf($colName)) {
            $iCol = $this->columns->subtreeIndex($colName);
            $rowCellClassesIndexed[$iCol] = $classes;
          }
        }
        $cellClassesIndexed[$iRow] = $rowCellClassesIndexed;
      }
    }

    $matrix->setCellClasses($cellClassesIndexed);

    foreach ($this->NamedCells as $rowName => $rowCells) {
      $rowRange = $this->rows->subtreeRange($rowName);
      foreach ($rowCells as $colName => $cell) {
        $colRange = $this->columns->subtreeRange($colName);
        $cell = $cell->setRowspan($rowRange->getCount())->setColspan($colRange->getCount());
        $matrix->addCell($rowRange->iMin(), $colRange->iMin(), $cell);
      }
    }

    foreach ($this->OpenEndCells as $rowName => $rowCells) {
      $iRow = $this->rows->subtreeIndex($rowName);
      foreach ($rowCells as $colName => $cTrue) {
        $iCol = $this->columns->subtreeIndex($colName);
        $colRange = $this->columns->subtreeRange($colName);
        /** @var \Donquixote\Cellbrush\Axis\RangeInterface $colRange */
        while ($colRange = $colRange->getNext()) {
          $iColSup = $colRange->iSup();
          if (!$matrix->cellGrowRight($iRow, $iCol, $iColSup)) {
            break;
          }
        }
      }
    }

    return $matrix;
  }
925732
private static function getCofactors(Matrix $matrix)
    {
        $cofactors = self::getMinors($matrix);
        $dimensions = $matrix->rows;

        $cof = 1;
        for ($i = 0; $i < $dimensions; ++$i) {
            $cofs = $cof;
            for ($j = 0; $j < $dimensions; ++$j) {
                $cofactors[$i][$j] *= $cofs;
                $cofs = -$cofs;
            }
            $cof = -$cof;
        }

        return new Matrix($cofactors);
    }
278387
def matrix2lha(M):
    """"""
    l = []
    ind = np.indices(M.shape).reshape(M.ndim, M.size).T
    for i in ind:
        l.append([j+1 for j in i] + [M[tuple(i)]])
    return l
1216686
function transpose(matrix) {
                var resultMatrix = new Array(matrix[0].length);
                for (var i = 0; i < resultMatrix.length; ++i) {
                    resultMatrix[i] = new Array(matrix.length);
                }

                for (i = 0; i < matrix.length; ++i) {
                    for (var j = 0; j < matrix[0].length; ++j) {
                        resultMatrix[j][i] = matrix[i][j];
                    }
                }

                return resultMatrix;
            }
181214
function() {
                	var matrix_rows = [];
                	var n = this.elements.length;
                	for (var i = 0; i < n; i++) {
                    matrix_rows.push(this.elements[i]);
                	}
                  return matrix_rows;
                }
578026
private function getSamplesMatrix(): Matrix
    {
        $samples = [];
        foreach ($this->samples as $sample) {
            array_unshift($sample, 1);
            $samples[] = $sample;
        }

        return new Matrix($samples);
    }
661758
def to_matrix(self, n_qubits=-1):
        """"""
        if n_qubits == -1:
            n_qubits = self.max_n() + 1
        mat = I.to_matrix(n_qubits)
        for op in self.ops:
            if op.is_identity:
                continue
            mat = mat @ op.to_matrix(n_qubits)
        return mat * self.coeff
1320237
function multiply_matrices(l, r) {
          var al = l[0];
          var cl = l[1];
          var el = l[2];
          var bl = l[3];
          var dl = l[4];
          var fl = l[5];

          var ar = r[0];
          var cr = r[1];
          var er = r[2];
          var br = r[3];
          var dr = r[4];
          var fr = r[5];

          var a = al * ar + cl * br;
          var c = al * cr + cl * dr;
          var e = al * er + cl * fr + el;
          var b = bl * ar + dl * br;
          var d = bl * cr + dl * dr;
          var f = bl * er + dl * fr + fl;

          return [a, c, e, b, d, f];
      }
311851
def get_matrix(self, indices):
        """"""
        new = numpy.empty(self.samples1.shape)
        for idx in range(len(indices)):
            if indices[idx]:
                new[idx] = self.samples1[idx]
            else:
                new[idx] = self.samples2[idx]

        if self.poly:
            new = self.poly(*new)
        return new