Check that ``matrix`` is square.

    Returns
    =======
    is_square : bool
        ``True`` if ``matrix`` is square, ``False`` otherwise.
482705
def isSquare(matrix):
    
    try:
        try:
            dim1, dim2 = matrix.shape
        except AttributeError:
            dim1, dim2 = _np.array(matrix).shape
    except ValueError:
        return False
    if dim1 == dim2:
        return True
    return False
700135
def is_filled(self, point):
        
        index = self.point_to_index(point)
        in_range = (np.array(index) < np.array(self.shape)).all()
        if in_range:
            is_filled = self.matrix[index]
        else:
            is_filled = False
        return is_filled
180973
def is_invertible(self,X):
        """"""
        if len(X.shape) == 2:
            return X.shape[0] == X.shape[1] and np.linalg.matrix_rank(X) == X.shape[0]
        else:
            return False
1172695
public static void square( DMatrix1Row mat )
    {
        int index = 1;
        int indexEnd = mat.numCols;
        for( int i = 0; i < mat.numRows;
             i++ , index += i+1 , indexEnd += mat.numCols ) {
            int indexOther = (i+1)*mat.numCols + i;
            for( ; index < indexEnd; index++, indexOther += mat.numCols) {
                double val = mat.data[ index ];
                mat.data[ index ] = mat.data[ indexOther ];
                mat.data[indexOther] = val;
            }
        }
    }
182534
def validate_square(data, message=None, exception=MatrixError):
    """"""
    rows, columns = len(data), len(data[0]) if data else 0
    if message is None:
        message = 'Number of rows: %s != number of columns: %s in matrix' % (
            rows, columns)
    if rows != columns:
        raise exception(message)
555630
def as_square_array(arr):
    
    arr = np.atleast_2d(arr)
    if len(arr.shape) != 2 or arr.shape[0] != arr.shape[1]:
        raise ValueError("Expected square array")
    return arr
6577
function _square($x = false)
    {
        return count($x) < 2 * self::KARATSUBA_CUTOFF ?
            $this->_trim($this->_baseSquare($x)) :
            $this->_trim($this->_karatsubaSquare($x));
    }
1365408
def det(L):
    
    size_L = L.shape
    if np.size(L) == 1:
        return np.array(L)
    else:    
        try: 
            assert np.all(np.tril(L)==L)
        except AssertionError:
            print 'Error: Input is not a lower triangular matrix.'
            return 0
        try:
            assert size_L[0] == size_L[1]
        except AssertionError:
            print 'Error: Not a square matrix.'
            return 0
        det_L = 1.
        for i in xrange(size_L[1]):
            det_L = det_L*L[i,i]
        return det_L
882375
@Override
    public boolean isSingular() {

        for( int i = 0; i < m; i++ ) {
            double real = dataLU[i*stride+i*2];
            double imaginary = dataLU[i*stride+i*2+1];

            double mag2 = real*real + imaginary*imaginary;

            if( mag2 < UtilEjml.EPS*UtilEjml.EPS )
                return true;
        }
        return false;
    }
917367
function is(x, y) {
  let ret = false;
  // SameValue algorithm
  if (x === y) { // Steps 1-5, 7-10
    // Steps 6.b-6.e: +0 != -0
    ret = (x !== 0 || 1 / x === 1 / y);
  } else {
    // Step 6.a: NaN == NaN
    ret = (x !== x && y !== y);
  }

  return ret;
}
1177891
def rotate(self, matrix, tol=1e-3):
        
        matrix = SquareTensor(matrix)
        if not matrix.is_rotation(tol):
            raise ValueError("Rotation matrix is not valid.")
        sop = SymmOp.from_rotation_and_translation(matrix,
                                                   [0., 0., 0.])
        return self.transform(sop)
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;
    }
1195680
def is_Quadratic(self):
        """"""
        if self.expression.is_Atom:
            return False
        if all((len(key.free_symbols) < 2 and (key.is_Add or key.is_Mul or key.is_Atom)
                for key in self.expression.as_coefficients_dict().keys())):
            return False
        if self.expression.is_Add:
            terms = self.expression.args
            is_quad = False
            for term in terms:
                if len(term.free_symbols) > 2:
                    return False
                if term.is_Pow:
                    if not term.args[1].is_Number or term.args[1] > 2:
                        return False
                    else:
                        is_quad = True
                elif term.is_Mul:
                    if len(term.free_symbols) == 2:
                        is_quad = True
                    if term.args[1].is_Pow:
                        if not term.args[1].args[1].is_Number or term.args[1].args[1] > 2:
                            return False
                        else:
                            is_quad = True
            return is_quad
        else:
            if isinstance(self.expression, sympy.Basic):
                sympy_expression = self.expression
            else:
                sympy_expression = sympy.sympify(self.expression)
            # TODO: Find a way to do this with symengine (Poly is not part of symengine, 23 March 2017)
            poly = sympy_expression.as_poly(*sympy_expression.atoms(sympy.Symbol))
            if poly is None:
                return False
            else:
                return poly.is_quadratic
731679
public static boolean isOrthogonal(DMatrixRMaj Q , double tol )
    {
       if( Q.numRows < Q.numCols ) {
            throw new IllegalArgumentException("The number of rows must be more than or equal to the number of columns");
        }

        DMatrixRMaj u[] = CommonOps_DDRM.columnsToVector(Q, null);

        for( int i = 0; i < u.length; i++ ) {
            DMatrixRMaj a = u[i];

            for( int j = i+1; j < u.length; j++ ) {
                double val = VectorVectorMult_DDRM.innerProd(a,u[j]);

                if( !(Math.abs(val) <= tol))
                    return false;
            }
        }

        return true;
    }
475422
private boolean checkAtTaxNumber(final String ptaxNumber) {
    final int checkSum = ptaxNumber.charAt(8) - '0';
    final int sum = ptaxNumber.charAt(0) - '0' + squareSum((ptaxNumber.charAt(1) - '0') * 2) //
        + ptaxNumber.charAt(2) - '0' + squareSum((ptaxNumber.charAt(3) - '0') * 2) //
        + ptaxNumber.charAt(4) - '0' + squareSum((ptaxNumber.charAt(5) - '0') * 2) //
        + ptaxNumber.charAt(6) - '0' + squareSum((ptaxNumber.charAt(7) - '0') * 2);
    final int calculatedCheckSum = (80 - sum) % 10;
    return checkSum == calculatedCheckSum;
  }
337844
def _check_periodic(periodic):
    ''''''
    periodic = np.array(periodic)

    # If it is a matrix
    if len(periodic.shape) == 2:
        assert periodic.shape[0] == periodic.shape[1], 'periodic shoud be a square matrix or a flat array'
        return np.diag(periodic)
    elif len(periodic.shape) == 1:
        return periodic
    else:
        raise ValueError("periodic argument can be either a 3x3 matrix or a shape 3 array.")
1168230
def scalogram(M, circ=False):
    

    # Sanity checks
    if not type(M) is np.ndarray:
        M = np.array(M)

    if M.shape[0] != M.shape[1]:
        raise ValueError("Matrix is not square.")

    try:
        n = min(M.shape)
    except AttributeError:
        n = M.size

    N = np.zeros(M.shape)
    for i in range(n):
        for j in range(n):
            if i + j < n and i >= j:
                N[i, j] = M[i, i - j:i + j + 1].sum()
            elif circ and i + j < n and i < j:
                N[i, j] = M[i, i - j:].sum() + M[i, :i + j + 1].sum()
            elif circ and i >= j and i + j >= n:
                N[i, j] = M[i, i - j:].sum() + M[i, :i + j - n + 1].sum()
            elif circ and i < j and i + j >= n:
                N[i, j] = (M[i, i - j:].sum() +
                           M[i, :].sum() +
                           M[i, :i + j - n + 1].sum())

    return N