Computes the product of the diagonal elements.  For a diagonal or triangular
matrix this is the determinant.

@param T A matrix.
@return product of the diagonal elements.
485187
public static double diagProd( DMatrix1Row T )
    {
        double prod = 1.0;
        int N = Math.min(T.numRows,T.numCols);
        for( int i = 0; i < N; i++ ) {
            prod *= T.unsafe_get(i,i);
        }

        return prod;
    }
241017
public Matrix transpose() {
        Matrix result = blankOfShape(columns, rows);
        MatrixIterator it = result.iterator();

        while (it.hasNext()) {
            it.next();
            int i = it.rowIndex();
            int j = it.columnIndex();
            it.set(get(j, i));
        }

        return result;
    }
958530
public static double innerProdA(DMatrixD1 x, DMatrixD1 A , DMatrixD1 y )
    {
        int n = A.numRows;
        int m = A.numCols;

        if( x.getNumElements() != n )
            throw new IllegalArgumentException("Unexpected number of elements in x");
        if( y.getNumElements() != m )
            throw new IllegalArgumentException("Unexpected number of elements in y");

        double result = 0;

        for( int i = 0; i < m; i++ ) {
            double total = 0;

            for( int j = 0; j < n; j++ ) {
                total += x.get(j)*A.unsafe_get(j,i);
            }

            result += total*y.get(i);
        }

        return result;
    }
196556
public static double elementSum( DMatrixD1 mat ) {
        double total = 0;

        int size = mat.getNumElements();

        for( int i = 0; i < size; i++ ) {
            total += mat.get(i);
        }

        return total;
    }
186029
public IVector getVectorFromDiagonal() {
        int size = Math.min(rows, columns);
        IVector result = new IVector(size);
        for (int i = 0; i < rows; i++) {
            result.realvector[i] = realmatrix[i][i];
            result.imagvector[i] = imagmatrix[i][i];
        }
        return result;
    }
1188044
public Matrix transpose()
    {
        final Matrix A = new Matrix(m_columns, m_rows);

        for (int i = 0; i < m_rows; i++)
        {
            for (int j = 0; j < m_columns; j++)
            {
                A.m_data[j][i] = this.m_data[i][j];
            }
        }
        return A;
    }
365099
def determinant(self):
        
        a, b, c, d, e, f, g, h, i = self
        return a * e - b * d
592287
public static double[] toArray(DoubleTuple t)
    {
        int d = t.getSize();
        double result[] = new double[d];
        for (int i=0; i<d; i++)
        {
            result[i] = t.get(i);
        }
        return result;
    }
277697
public Matrix getIminus() {
        Matrix Iminus = new Matrix(size, size);
        int i, j;
        for (i = 0; i < size; i++)
            for (j = 0; j < size; j++)
                Iminus.matrix[i][j] = 0d;
        for (i = 1; i < size; i++)
            Iminus.matrix[i][i - 1] = Math.sqrt(J * J + J - (J - i) * (J - i) - (J - i));
        return Iminus;
    }
670378
public double getDet()
    {
        double det = 1;
        for(int i = 0; i < L.rows(); i++)
            det *= L.get(i, i);
        return det;
    }
594405
public DoubleMatrix multiply(double c)
    {
        DoubleMatrix clone = clone();
        clone.scalarMultiply(c);
        return clone;
    }
107289
public static double[][] diag(double[] vector){

		// Note: According to the Java Language spec, an array is initialized with the default value, here 0.
		double[][] diagonalMatrix = new double[vector.length][vector.length];

		for(int index = 0; index < vector.length; index++) {
			diagonalMatrix[index][index] = vector[index];
		}

		return diagonalMatrix;
	}
427468
public Matrix getLT()
    {
        Matrix LT = new DenseMatrix(L.rows(), L.cols());
        
        for(int i = 0; i < L.rows(); i++)
            for(int j = i; j < L.rows(); j++)
                LT.set(i, j, L.get(i, j));
        
        return LT;
    }
517864
public Matrix getD () {
		Matrix X = new Matrix(n,n);
		double[][] D = X.getArray();
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				D[i][j] = 0.0;
			}
			D[i][i] = d[i];
			if (e[i] > 0) {
				D[i][i+1] = e[i];
			} else if (e[i] < 0) {
				D[i][i-1] = e[i];
			}
		}
		return X;
	}
732793
public Matrix getU () {
      Matrix X = MatrixFactory.createMatrix(n,n);
      for (int i = 0; i < n; i++) {
         for (int j = 0; j < n; j++) {
            if (i <= j) {
					X.set(i, j, LU[i][j]);
            }
         }
      }
      return X;
   }
273196
public static final double calculateDeterminant(double[][] ai, int dim) {
		double det = 0;
		if (dim == 1) {
			det = ai[0][0];
		} else if (dim == 2) {
			det = ai[0][0] * ai[1][1] - ai[0][1] * ai[1][0];
		} else {
			double ai1[][] = new double[dim - 1][dim - 1];
			for (int k = 0; k < dim; k++) {
				for (int i1 = 1; i1 < dim; i1++) {
					int j = 0;
					for (int j1 = 0; j1 < dim; j1++) {
						if (j1 != k) {
							ai1[i1 - 1][j] = ai[i1][j1];
							j++;
						}
					}
				}
				if (k % 2 == 0) {
					det += ai[0][k] * calculateDeterminant(ai1, dim - 1);
				} else {
					det -= ai[0][k] * calculateDeterminant(ai1, dim - 1);
				}
			}
		}
		return det;
	}
939324
public Matrix multiply(Matrix B)
    {
        Matrix C = new DenseMatrix(this.rows(), B.cols());
        multiply(B, C);
        return C;
    }