Package ptolemy.math

Class LongMatrixMath


  • public class LongMatrixMath
    extends java.lang.Object
    This class provides a library for mathematical operations on matrices of longs. Rows and column numbers of matrices are specified with zero-based indices. All calls expect matrix arguments to be non-null. In addition, all rows of the matrix are expected to have the same number of columns.
    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Jeff Tsay
    Pt.AcceptedRating:
    Yellow (ctsay)
    Pt.ProposedRating:
    Yellow (ctsay)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void _checkSameDimension​(java.lang.String caller, long[][] matrix1, long[][] matrix2)
      Check that the two matrix arguments are of the same dimension.
      protected static int _checkSquare​(java.lang.String caller, long[][] matrix)
      Check that the argument matrix is a square matrix.
      protected static int _columns​(long[][] matrix)
      Return the number of columns of a matrix.
      protected static java.lang.String _dimensionString​(long[][] matrix)
      Return a string that describes the number of rows and columns.
      protected static int _rows​(long[][] matrix)
      Return the number of rows of a matrix.
      static long[][] add​(long[][] matrix, long z)
      Return a new matrix that is constructed from the argument by adding the second argument to every element.
      static long[][] add​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed from the argument by adding the second matrix to the first one.
      static long[][] allocCopy​(long[][] matrix)
      Return a new matrix that is a copy of the matrix argument.
      static long[][] applyBinaryOperation​(LongBinaryOperation op, long[][] matrix, long z)
      Return a new array that is formed by applying an instance of a LongBinaryOperation to each element in the input matrix, using the matrix elements as the left operands and z as the right operand in all cases (op.operate(matrix[i][j], z)).
      static long[][] applyBinaryOperation​(LongBinaryOperation op, long[][] matrix1, long[][] matrix2)
      Return a new array that is formed by applying an instance of a LongBinaryOperation to the two matrices, element by element, using the elements of the first matrix as the left operands and the elements of the second matrix as the right operands.
      static long[][] applyBinaryOperation​(LongBinaryOperation op, long z, long[][] matrix)
      Return a new array that is formed by applying an instance of a LongBinaryOperation to each element in the input matrix, using z as the left operand in all cases and the matrix elements as the right operands (op.operate(z, matrix[i][j])).
      static long[][] applyUnaryOperation​(LongUnaryOperation op, long[][] matrix)
      Return a new array that is formed by applying an instance of a LongUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
      static long[][] bitwiseAnd​(long[][] matrix, long z)
      Return a new matrix that is the formed by bitwise ANDing z with each element of the input matrix (matrix[i][j] & z).
      static long[][] bitwiseAnd​(long[][] matrix1, long[][] matrix2)
      Return a new array that is the element-by-element bitwise AND of the two input matrices (matrix1[i][j] & matrix2[i][j]).
      static long[][] bitwiseComplement​(long[][] matrix)
      Return a new array that formed by the bitwise complement of each element in the input matrix (~matrix[i][j]).
      static long[][] bitwiseOr​(long[][] matrix, long z)
      Return a new matrix that is the formed by bitwise ORing z with each element of the input matrix (matrix[i][j] | z).
      static long[][] bitwiseOr​(long[][] matrix1, long[][] matrix2)
      Return a new array that is the element-by-element bitwise OR of the two input matrices (matrix1[i][j] | matrix2[i][j]).
      static long[][] bitwiseXor​(long[][] matrix, long z)
      Return a new matrix that is the formed by bitwise XORing z with each element of the input matrix (matrix[i][j] ^ z).
      static long[][] bitwiseXor​(long[][] matrix1, long[][] matrix2)
      Return a new array that is the element-by-element bitwise XOR of the two input matrices (matrix1[i][j] & matrix2[i][j]).
      static long[][] crop​(long[][] matrix, int rowStart, int colStart, int rowSpan, int colSpan)
      Return a new matrix that is a sub-matrix of the input matrix argument.
      static long[][] diag​(long[] array)
      Return a new matrix that is constructed by placing the elements of the input array on the diagonal of the square matrix, starting from the top left corner down to the bottom right corner.
      static long[][] divide​(long[][] matrix, long z)
      Return a new matrix that is constructed from the argument by dividing the second argument to every element.
      static long[][] divideElements​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed by element by element division of the two matrix arguments.
      static long[] fromMatrixToArray​(long[][] matrix)
      Return a new array that is filled with the contents of the matrix.
      static long[] fromMatrixToArray​(long[][] matrix, int maxRow, int maxCol)
      Return a new array that is filled with the contents of the matrix.
      static long[][] identity​(int dim)
      Return an new identity matrix with the specified dimension.
      static long[][] identityMatrixLong​(int dim)
      Return an new identity matrix with the specified dimension.
      static void matrixCopy​(long[][] srcMatrix, int srcRowStart, int srcColStart, long[][] destMatrix, int destRowStart, int destColStart, int rowSpan, int colSpan)
      Replace the first matrix argument's values, in the specified row and column range, with the second matrix argument's values, starting from specified row and column of the second matrix.
      static void matrixCopy​(long[][] srcMatrix, long[][] destMatrix)
      Replace the first matrix argument elements with the values of the second matrix argument.
      static long[][] modulo​(long[][] matrix, long z)
      Return a new matrix that is constructed by computing the remainders between each element in the matrix and z.
      static long[][] modulo​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed by computing the remainders between each element in the first matrix argument and the corresponding element in the second matrix argument.
      static long[][] multiply​(long[][] matrix, long scaleFactor)
      Return a new matrix that is constructed by multiplying the matrix by a scaleFactor.
      static long[] multiply​(long[][] matrix, long[] array)
      Return a new array that is constructed from the argument by pre-multiplying the array (treated as a row vector) by a matrix.
      static long[][] multiply​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed from the argument by multiplying the first matrix by the second one.
      static long[] multiply​(long[] array, long[][] matrix)
      Return a new array that is constructed from the argument by post-multiplying the matrix by an array (treated as a row vector).
      static long[][] multiplyElements​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed by element by element multiplication of the two matrix arguments.
      static long[][] negative​(long[][] matrix)
      Return a new matrix that is the additive inverse of the argument matrix.
      static long[][] shiftArithmetic​(long[][] matrix, int shiftAmount)
      Return a new matrix that is constructed from the argument by arithmetically shifting the elements in the matrix by the second argument.
      static long[][] shiftLogical​(long[][] matrix, int shiftAmount)
      Return a new matrix that is constructed from the argument by logically shifting the elements in the matrix by the second argument.
      static long[][] subtract​(long[][] matrix1, long[][] matrix2)
      Return a new matrix that is constructed from the argument by subtracting the second matrix from the first one.
      static long sum​(long[][] matrix)
      Return the sum of the elements of a matrix.
      static Complex[][] toComplexMatrix​(long[][] matrix)
      Return a new matrix that is formed by converting the long values in the argument matrix to complex numbers.
      static double[][] toDoubleMatrix​(long[][] matrix)
      Return a new matrix that is formed by converting the longs in the argument matrix to doubles.
      static float[][] toFloatMatrix​(long[][] matrix)
      Return a new matrix that is formed by converting the longs in the argument matrix to floats.
      static int[][] toIntegerMatrix​(long[][] matrix)
      Return a new matrix that is formed by converting the longs in the argument matrix to integers.
      static long[][] toMatrixFromArray​(long[] array, int rows, int cols)
      Return a new matrix of longs that is initialized from a 1-D array.
      static java.lang.String toString​(long[][] matrix)
      Return a new String representing the matrix, formatted as in Java array initializers.
      static java.lang.String toString​(long[][] matrix, java.lang.String elementDelimiter, java.lang.String matrixBegin, java.lang.String matrixEnd, java.lang.String vectorBegin, java.lang.String vectorDelimiter, java.lang.String vectorEnd)
      Return a new String representing the matrix, formatted as specified by the ArrayStringFormat argument.
      static long trace​(long[][] matrix)
      Return the trace of a square matrix, which is the sum of the diagonal entries A11 + A22 + ...
      static long[][] transpose​(long[][] matrix)
      Return a new matrix that is constructed by transposing the input matrix.
      static boolean within​(long[][] matrix1, long[][] matrix2, long distance)
      Return true if the elements of the two matrices differ by no more than the specified distance.
      static boolean within​(long[][] matrix1, long[][] matrix2, long[][] errorMatrix)
      Return true if the elements of the two matrices differ by no more than the specified distances.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • add

        public static final long[][] add​(long[][] matrix,
                                         long z)
        Return a new matrix that is constructed from the argument by adding the second argument to every element.
        Parameters:
        matrix - A matrix of longs.
        z - The long number to add.
        Returns:
        A new matrix of longs.
      • add

        public static final long[][] add​(long[][] matrix1,
                                         long[][] matrix2)
        Return a new matrix that is constructed from the argument by adding the second matrix to the first one. If the two matrices are not the same size, throw an IllegalArgumentException.
        Parameters:
        matrix1 - The first matrix of longs.
        matrix2 - The second matrix of longs.
        Returns:
        A new matrix of longs.
      • allocCopy

        public static final long[][] allocCopy​(long[][] matrix)
        Return a new matrix that is a copy of the matrix argument.
        Parameters:
        matrix - A matrix of longs.
        Returns:
        A new matrix of longs.
      • applyBinaryOperation

        public static final long[][] applyBinaryOperation​(LongBinaryOperation op,
                                                          long z,
                                                          long[][] matrix)
        Return a new array that is formed by applying an instance of a LongBinaryOperation to each element in the input matrix, using z as the left operand in all cases and the matrix elements as the right operands (op.operate(z, matrix[i][j])).
      • applyBinaryOperation

        public static final long[][] applyBinaryOperation​(LongBinaryOperation op,
                                                          long[][] matrix,
                                                          long z)
        Return a new array that is formed by applying an instance of a LongBinaryOperation to each element in the input matrix, using the matrix elements as the left operands and z as the right operand in all cases (op.operate(matrix[i][j], z)).
      • applyBinaryOperation

        public static final long[][] applyBinaryOperation​(LongBinaryOperation op,
                                                          long[][] matrix1,
                                                          long[][] matrix2)
        Return a new array that is formed by applying an instance of a LongBinaryOperation to the two matrices, element by element, using the elements of the first matrix as the left operands and the elements of the second matrix as the right operands. (op.operate(matrix1[i][j], matrix2[i][j])). If the matrices are not the same size, throw an IllegalArgumentException.
      • applyUnaryOperation

        public static final long[][] applyUnaryOperation​(LongUnaryOperation op,
                                                         long[][] matrix)
        Return a new array that is formed by applying an instance of a LongUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
      • bitwiseAnd

        public static final long[][] bitwiseAnd​(long[][] matrix,
                                                long z)
        Return a new matrix that is the formed by bitwise ANDing z with each element of the input matrix (matrix[i][j] & z).
      • bitwiseAnd

        public static final long[][] bitwiseAnd​(long[][] matrix1,
                                                long[][] matrix2)
        Return a new array that is the element-by-element bitwise AND of the two input matrices (matrix1[i][j] & matrix2[i][j]). If the two matrices are not the same size, throw an IllegalArgumentException.
      • bitwiseComplement

        public static final long[][] bitwiseComplement​(long[][] matrix)
        Return a new array that formed by the bitwise complement of each element in the input matrix (~matrix[i][j]).
      • bitwiseOr

        public static final long[][] bitwiseOr​(long[][] matrix,
                                               long z)
        Return a new matrix that is the formed by bitwise ORing z with each element of the input matrix (matrix[i][j] | z).
      • bitwiseOr

        public static final long[][] bitwiseOr​(long[][] matrix1,
                                               long[][] matrix2)
        Return a new array that is the element-by-element bitwise OR of the two input matrices (matrix1[i][j] | matrix2[i][j]). If the two matrices are not the same size, throw an IllegalArgumentException.
      • bitwiseXor

        public static final long[][] bitwiseXor​(long[][] matrix,
                                                long z)
        Return a new matrix that is the formed by bitwise XORing z with each element of the input matrix (matrix[i][j] ^ z).
      • bitwiseXor

        public static final long[][] bitwiseXor​(long[][] matrix1,
                                                long[][] matrix2)
        Return a new array that is the element-by-element bitwise XOR of the two input matrices (matrix1[i][j] & matrix2[i][j]). If the two matrices are not the same size, throw an IllegalArgumentException.
      • crop

        public static final long[][] crop​(long[][] matrix,
                                          int rowStart,
                                          int colStart,
                                          int rowSpan,
                                          int colSpan)
        Return a new matrix that is a sub-matrix of the input matrix argument. The row and column from which to start and the number of rows and columns to span are specified.
        Parameters:
        matrix - A matrix of longs.
        rowStart - An int specifying which row to start on.
        colStart - An int specifying which column to start on.
        rowSpan - An int specifying how many rows to copy.
        colSpan - An int specifying how many columns to copy.
      • diag

        public static final long[][] diag​(long[] array)
        Return a new matrix that is constructed by placing the elements of the input array on the diagonal of the square matrix, starting from the top left corner down to the bottom right corner. All other elements are zero. The size of of the matrix is n x n, where n is the length of the input array.
      • divide

        public static final long[][] divide​(long[][] matrix,
                                            long z)
        Return a new matrix that is constructed from the argument by dividing the second argument to every element.
        Parameters:
        matrix - A matrix of longs.
        z - The long number to divide.
        Returns:
        A new matrix of longs.
      • divideElements

        public static final long[][] divideElements​(long[][] matrix1,
                                                    long[][] matrix2)
        Return a new matrix that is constructed by element by element division of the two matrix arguments. Each element of the first matrix is divided by the corresponding element of the second matrix. If the two matrices are not the same size, throw an IllegalArgumentException.
      • fromMatrixToArray

        public static final long[] fromMatrixToArray​(long[][] matrix)
        Return a new array that is filled with the contents of the matrix. The longs are stored row by row, i.e. using the notation (row, column), the entries of the array are in the following order for a (m, n) matrix : (0, 0), (0, 1), (0, 2), ... , (0, n-1), (1, 0), (1, 1), ..., (m-1)(n-1)
        Parameters:
        matrix - A matrix of longs.
        Returns:
        A new array of longs.
      • fromMatrixToArray

        public static final long[] fromMatrixToArray​(long[][] matrix,
                                                     int maxRow,
                                                     int maxCol)
        Return a new array that is filled with the contents of the matrix. The maximum numbers of rows and columns to copy are specified so that entries lying outside of this range can be ignored. The maximum rows to copy cannot exceed the number of rows in the matrix, and the maximum columns to copy cannot exceed the number of columns in the matrix. The longs are stored row by row, i.e. using the notation (row, column), the entries of the array are in the following order for a matrix, limited to m rows and n columns : (0, 0), (0, 1), (0, 2), ... , (0, n-1), (1, 0), (1, 1), ..., (m-1)(n-1)
        Parameters:
        matrix - A matrix of longs.
        Returns:
        A new array of longs.
      • identity

        public static final long[][] identity​(int dim)
        Return an new identity matrix with the specified dimension. The matrix is square, so only one dimension specifier is needed.
      • identityMatrixLong

        public static final long[][] identityMatrixLong​(int dim)
        Return an new identity matrix with the specified dimension. The matrix is square, so only one dimension specifier is needed.
      • matrixCopy

        public static final void matrixCopy​(long[][] srcMatrix,
                                            long[][] destMatrix)
        Replace the first matrix argument elements with the values of the second matrix argument. The second matrix argument must be large enough to hold all the values of second matrix argument.
        Parameters:
        destMatrix - A matrix of longs, used as the destination.
        srcMatrix - A matrix of longs, used as the source.
      • matrixCopy

        public static final void matrixCopy​(long[][] srcMatrix,
                                            int srcRowStart,
                                            int srcColStart,
                                            long[][] destMatrix,
                                            int destRowStart,
                                            int destColStart,
                                            int rowSpan,
                                            int colSpan)
        Replace the first matrix argument's values, in the specified row and column range, with the second matrix argument's values, starting from specified row and column of the second matrix.
        Parameters:
        srcMatrix - A matrix of longs, used as the destination.
        srcRowStart - An int specifying the starting row of the source.
        srcColStart - An int specifying the starting column of the source.
        destMatrix - A matrix of longs, used as the destination.
        destRowStart - An int specifying the starting row of the dest.
        destColStart - An int specifying the starting column of the dest.
        rowSpan - An int specifying how many rows to copy.
        colSpan - An int specifying how many columns to copy.
      • modulo

        public static final long[][] modulo​(long[][] matrix,
                                            long z)
        Return a new matrix that is constructed by computing the remainders between each element in the matrix and z.
      • modulo

        public static final long[][] modulo​(long[][] matrix1,
                                            long[][] matrix2)
        Return a new matrix that is constructed by computing the remainders between each element in the first matrix argument and the corresponding element in the second matrix argument. If the two matrices are not the same size, throw an IllegalArgumentException.
      • multiply

        public static final long[][] multiply​(long[][] matrix,
                                              long scaleFactor)
        Return a new matrix that is constructed by multiplying the matrix by a scaleFactor.
      • multiply

        public static final long[] multiply​(long[][] matrix,
                                            long[] array)
        Return a new array that is constructed from the argument by pre-multiplying the array (treated as a row vector) by a matrix. The number of rows of the matrix must equal the number of elements in the array. The returned array will have a length equal to the number of columns of the matrix.
      • multiply

        public static final long[] multiply​(long[] array,
                                            long[][] matrix)
        Return a new array that is constructed from the argument by post-multiplying the matrix by an array (treated as a row vector). The number of columns of the matrix must equal the number of elements in the array. The returned array will have a length equal to the number of rows of the matrix.
      • multiply

        public static final long[][] multiply​(long[][] matrix1,
                                              long[][] matrix2)
        Return a new matrix that is constructed from the argument by multiplying the first matrix by the second one. Note this operation is not commutative, so care must be taken in the ordering of the arguments. The number of columns of matrix1 must equal the number of rows of matrix2. If matrix1 is of size m x n, and matrix2 is of size n x p, the returned matrix will have size m x p.

        Note that this method is different from the other multiply() methods in that this method does not do pointwise multiplication.

        Parameters:
        matrix1 - The first matrix of longs.
        matrix2 - The second matrix of longs.
        Returns:
        A new matrix of longs.
        See Also:
        multiplyElements(long[][], long[][])
      • multiplyElements

        public static final long[][] multiplyElements​(long[][] matrix1,
                                                      long[][] matrix2)
        Return a new matrix that is constructed by element by element multiplication of the two matrix arguments. If the two matrices are not the same size, throw an IllegalArgumentException.

        Note that this method does pointwise matrix multiplication. See multiply(long[][], long[][]) for standard matrix multiplication.

      • negative

        public static final long[][] negative​(long[][] matrix)
        Return a new matrix that is the additive inverse of the argument matrix.
      • shiftArithmetic

        public static final long[][] shiftArithmetic​(long[][] matrix,
                                                     int shiftAmount)
        Return a new matrix that is constructed from the argument by arithmetically shifting the elements in the matrix by the second argument. If the second argument is positive, the elements are shifted left by the second argument. If the second argument is negative, the elements are shifted right (arithmetically, with the >>> operator) by the absolute value of the second argument. If the second argument is 0, no operation is performed (the matrix is just copied).
        Parameters:
        matrix - A first matrix of longs.
        shiftAmount - The amount to shift by, positive for left shift, negative for right shift.
        Returns:
        A new matrix of longs.
      • shiftLogical

        public static final long[][] shiftLogical​(long[][] matrix,
                                                  int shiftAmount)
        Return a new matrix that is constructed from the argument by logically shifting the elements in the matrix by the second argument. If the second argument is positive, the elements are shifted left by the second argument. If the second argument is negative, the elements are shifted right (logically, with the >> operator) by the absolute value of the second argument. If the second argument is 0, no operation is performed (the matrix is just copied).
        Parameters:
        matrix - A first matrix of longs.
        shiftAmount - The amount to shift by, positive for left shift, negative for right shift.
        Returns:
        A new matrix of longs.
      • subtract

        public static final long[][] subtract​(long[][] matrix1,
                                              long[][] matrix2)
        Return a new matrix that is constructed from the argument by subtracting the second matrix from the first one. If the two matrices are not the same size, throw an IllegalArgumentException.
      • sum

        public static final long sum​(long[][] matrix)
        Return the sum of the elements of a matrix.
        Returns:
        The sum of the elements of the matrix.
      • toComplexMatrix

        public static final Complex[][] toComplexMatrix​(long[][] matrix)
        Return a new matrix that is formed by converting the long values in the argument matrix to complex numbers. Each complex number has a real part equal to the value in the argument matrix and a zero imaginary part.
        Parameters:
        matrix - A matrix of long values.
        Returns:
        A new matrix of complex numbers.
      • toDoubleMatrix

        public static final double[][] toDoubleMatrix​(long[][] matrix)
        Return a new matrix that is formed by converting the longs in the argument matrix to doubles.
        Parameters:
        matrix - An matrix of long.
        Returns:
        A new matrix of doubles.
      • toFloatMatrix

        public static final float[][] toFloatMatrix​(long[][] matrix)
        Return a new matrix that is formed by converting the longs in the argument matrix to floats.
        Parameters:
        matrix - An matrix of long.
        Returns:
        A new matrix of floats.
      • toIntegerMatrix

        public static final int[][] toIntegerMatrix​(long[][] matrix)
        Return a new matrix that is formed by converting the longs in the argument matrix to integers.
        Parameters:
        matrix - An matrix of long.
        Returns:
        A new matrix of integers.
      • toMatrixFromArray

        public static final long[][] toMatrixFromArray​(long[] array,
                                                       int rows,
                                                       int cols)
        Return a new matrix of longs that is initialized from a 1-D array. The format of the array must be (0, 0), (0, 1), ..., (0, n-1), (1, 0), (1, 1), ..., (m-1, n-1) where the output matrix is to be m x n and entries are denoted by (row, column).
        Parameters:
        array - An array of longs.
        rows - An integer representing the number of rows of the new matrix.
        cols - An integer representing the number of columns of the new matrix.
        Returns:
        A new matrix of longs.
      • toString

        public static final java.lang.String toString​(long[][] matrix)
        Return a new String representing the matrix, formatted as in Java array initializers.
      • toString

        public static final java.lang.String toString​(long[][] matrix,
                                                      java.lang.String elementDelimiter,
                                                      java.lang.String matrixBegin,
                                                      java.lang.String matrixEnd,
                                                      java.lang.String vectorBegin,
                                                      java.lang.String vectorDelimiter,
                                                      java.lang.String vectorEnd)
        Return a new String representing the matrix, formatted as specified by the ArrayStringFormat argument. To get a String in the Ptolemy expression language format, call this method with ArrayStringFormat.exprASFormat as the format argument.
      • trace

        public static final long trace​(long[][] matrix)
        Return the trace of a square matrix, which is the sum of the diagonal entries A11 + A22 + ... + Ann Throw an IllegalArgumentException if the matrix is not square. Note that the trace of a matrix is equal to the sum of its eigenvalues.
      • transpose

        public static final long[][] transpose​(long[][] matrix)
        Return a new matrix that is constructed by transposing the input matrix. If the input matrix is m x n, the output matrix will be n x m.
      • within

        public static final boolean within​(long[][] matrix1,
                                           long[][] matrix2,
                                           long distance)
        Return true if the elements of the two matrices differ by no more than the specified distance. If distance is negative, return false.
        Parameters:
        matrix1 - The first matrix.
        matrix2 - The second matrix.
        distance - The distance to use for comparison.
        Returns:
        True if the elements of the two matrices are within the specified distance.
        Throws:
        java.lang.IllegalArgumentException - If the matrices do not have the same dimension. This is a run-time exception, so it need not be declared explicitly.
      • within

        public static final boolean within​(long[][] matrix1,
                                           long[][] matrix2,
                                           long[][] errorMatrix)
        Return true if the elements of the two matrices differ by no more than the specified distances. If any element of errorMatrix is negative, return false.
        Parameters:
        matrix1 - The first matrix.
        matrix2 - The second matrix.
        errorMatrix - The distance to use for comparison.
        Returns:
        True if the elements of the two matrices are within the specified distance.
        Throws:
        java.lang.IllegalArgumentException - If the matrices do not have the same dimension. This is a run-time exception, so it need not be declared explicitly.
      • _checkSameDimension

        protected static final void _checkSameDimension​(java.lang.String caller,
                                                        long[][] matrix1,
                                                        long[][] matrix2)
        Check that the two matrix arguments are of the same dimension. If they are not, an IllegalArgumentException is thrown.
        Parameters:
        caller - A string representing the caller method name.
        matrix1 - A matrix of longs.
        matrix2 - A matrix of longs.
      • _checkSquare

        protected static final int _checkSquare​(java.lang.String caller,
                                                long[][] matrix)
        Check that the argument matrix is a square matrix. If the matrix is not square, an IllegalArgumentException is thrown.
        Parameters:
        caller - A string representing the caller method name.
        matrix - A matrix of longs.
        Returns:
        The dimension of the square matrix.
      • _columns

        protected static final int _columns​(long[][] matrix)
        Return the number of columns of a matrix.
        Parameters:
        matrix - The matrix.
        Returns:
        The number of columns.
      • _dimensionString

        protected static final java.lang.String _dimensionString​(long[][] matrix)
        Return a string that describes the number of rows and columns.
        Parameters:
        matrix - The matrix that is to be described.
        Returns:
        a string describing the dimensions of this matrix.
      • _rows

        protected static final int _rows​(long[][] matrix)
        Return the number of rows of a matrix.