Determinant of a positive definite matrix, only symmetric matricies though
510851
def pddet(A):
    
    L = jitchol(A)
    logdetA = 2*sum(np.log(np.diag(L)))
    return logdetA
684271
def laplace(affinity_matrix, shi_malik_type=False):
    

    diagonal = affinity_matrix.sum(axis=1) - affinity_matrix.diagonal()
    zeros = diagonal <= 1e-10
    diagonal[zeros] = 1
    if (diagonal <= 1e-10).any():  # arbitrarily small value
        raise ZeroDivisionError
    if shi_malik_type:
        inv_d = np.diag(1 / diagonal)
        return inv_d.dot(affinity_matrix)
    diagonal = np.sqrt(diagonal)
    return affinity_matrix / diagonal / diagonal[:, np.newaxis]
452618
def inv_n(x):
    ''''''
    #
    # The inverse of a small matrix (e.g. 3x3) is
    #
    #   1
    # -----   C(j,i)
    # det(A)
    #
    # where C(j,i) is the cofactor of matrix A at position j,i
    #
    assert x.ndim == 3
    assert x.shape[1] == x.shape[2]
    c = np.array([ [cofactor_n(x, j, i) * (1 - ((i+j) % 2)*2)
                    for j in range(x.shape[1])]
                   for i in range(x.shape[1])]).transpose(2,0,1)
    return c / det_n(x)[:, np.newaxis, np.newaxis]
783628
public static boolean isDiagonalPositive( DMatrixRMaj a ) {
        for( int i = 0; i < a.numRows; i++ ) {
            if( !(a.get(i,i) >= 0) )
                return false;
        }
        return true;
    }
1213153
def make_symmetric_matrix_from_upper_tri(val):
    
    idx = [0,3,4,1,5,2]
    val = np.array(val)[idx]
    mask = ~np.tri(3,k=-1,dtype=bool)
    out = np.zeros((3,3),dtype=val.dtype)
    out[mask] = val
    out.T[mask] = val
    return out
944461
public double det ()
  {
    if (m_nRows != m_nCols)
      throw new IllegalArgumentException ("Matrix must be square.");
    double d = m_nPivSign;
    for (int j = 0; j < m_nCols; j++)
      d *= m_aLU[j][j];
    return d;
  }
1330754
public function det()
    {
        if ($this->m !== $this->n) {
            throw MatrixException::notSquareMatrix();
        }

        $d = $this->pivsign;
        for ($j = 0; $j < $this->n; ++$j) {
            $d *= $this->LU[$j][$j];
        }

        return $d;
    }
296597
def get_deter
    Error.call "Matrix::get_deter : This error comes from get_deter which works only with 2x2 matrix" if @columns != 2 or @lines != 2

    det = get_val(0, 0).to_i * get_val(1, 1).to_i
    det -= get_val(0, 1).to_i * get_val(1, 0).to_i
    return det
  end
1288297
def determinant_by_elimination
      m = dup
      det = ground.unity
      each_j do |d|
        if i = (d...size).find{|i| !m[i, d].zero?}
          if i != d
            m.sswap_r!(d, i)
            det = -det
          end
          c = m[d, d]
          det *= c
          (d+1...size).each do |i0|
            r = m.row!(i0)
            q = ground.unity * m[i0, d] / c #this lets the entries be in ground
            (d+1...size).each do |j0|
              r[j0] -= q * m[d, j0]
            end
          end
        else
          return ground.zero
        end
      end
      det
    end
134881
private double determinant3x3(double t00, double t01, double t02,
                                  double t10, double t11, double t12,
                                  double t20, double t21, double t22) {
        return (t00 * (t11 * t22 - t12 * t21) +
                t01 * (t12 * t20 - t10 * t22) +
                t02 * (t10 * t21 - t11 * t20));
    }
1283103
def get_pij_matrix(t, diag, A, A_inv):
    
    return A.dot(np.diag(np.exp(diag * t))).dot(A_inv)
416371
def aandb(a, b):
    """"""
    return matrix(np.logical_and(a, b).astype('float'), a.size)
1166853
function(matrix) {
    var M = matrix.elements || matrix;
    if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; }
    if (this.elements.length != M.length ||
        this.elements[0].length != M[0].length) { return false; }
    var ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j;
    do { i = ki - ni;
      nj = kj;
      do { j = kj - nj;
        if (Math.abs(this.elements[i][j] - M[i][j]) > Sylvester.precision) { return false; }
      } while (--nj);
    } while (--ni);
    return true;
  }
743454
def getProjectionMatrix(self, eEye, fNearZ, fFarZ):
        """"""

        fn = self.function_table.getProjectionMatrix
        result = fn(eEye, fNearZ, fFarZ)
        return result
1337444
def issymmetric(am):
    
    """
    if am.shape[0] != am.shape[1]:
        logger.warning('Matrix is not square, symmetrical is irrelevant')
        return False
    if am.format != 'coo':
        am = am.tocoo(copy=False)
    if istril(am) or istriu(am):
        return False
    # Compare am with its transpose, element wise
    sym = ((am != am.T).size) == 0
    return sym
677639
def symmetrise(matrix, tri='upper'):
    
    if tri == 'upper':
        tri_fn = np.triu_indices
    else:
        tri_fn = np.tril_indices
    size = matrix.shape[0]
    matrix[tri_fn(size)[::-1]] = matrix[tri_fn(size)]
    return matrix
876029
@Override
	public void computeHessian(DMatrixSparseCSC jacLeft , DMatrixSparseCSC jacRight) {
		A.reshape(jacLeft.numCols,jacLeft.numCols,1);
		B.reshape(jacLeft.numCols,jacRight.numCols,1);
		D.reshape(jacRight.numCols,jacRight.numCols,1);

		// take advantage of the inner product's symmetry when possible to reduce
		// the number of calculations
		CommonOps_DSCC.innerProductLower(jacLeft,tmp0,gw,gx);
		CommonOps_DSCC.symmLowerToFull(tmp0,A,gw);
		CommonOps_DSCC.multTransA(jacLeft,jacRight,B,gw,gx);
		CommonOps_DSCC.innerProductLower(jacRight,tmp0,gw,gx);
		CommonOps_DSCC.symmLowerToFull(tmp0,D,gw);
	}