Interface DenseMatrix

    • Method Detail

      • data

        double[] data()
        Returns the array of storing the matrix.
      • ld

        int ld()
        The LDA (and LDB, LDC, etc.) parameter in BLAS is effectively the stride of the matrix as it is laid out in linear memory. It is perfectly valid to have an LDA value which is larger than the leading dimension of the matrix which is being operated on. Typical cases where it is either useful or necessary to use a larger LDA value are when you are operating on a sub matrix from a larger dense matrix, and when hardware or algorithms offer performance advantages when storage is padded to round multiples of some optimal size (cache lines or GPU memory transaction size, or load balance in multiprocessor implementations, for example).
        Returns:
        the leading dimension
      • set

        double set​(int i,
                   int j,
                   double x)
        Set the entry value at row i and column j.
      • update

        default double update​(int i,
                              int j,
                              double x)
        Set the entry value at row i and column j. For Scala users.
      • lu

        LU lu()
        Returns the LU decomposition. This input matrix will be overwritten with the decomposition.
      • lu

        default LU lu​(boolean inPlace)
        Returns the LU decomposition.
        Parameters:
        inPlace - if true, this matrix will be used for matrix decomposition.
      • cholesky

        Cholesky cholesky()
        Returns the Cholesky decomposition. This input matrix will be overwritten with the decomposition.
        Throws:
        java.lang.IllegalArgumentException - if the matrix is not positive definite.
      • cholesky

        default Cholesky cholesky​(boolean inPlace)
        Returns the Cholesky decomposition.
        Parameters:
        inPlace - if true, this matrix will be used for matrix decomposition.
        Throws:
        java.lang.IllegalArgumentException - if the matrix is not positive definite.
      • qr

        QR qr()
        Returns the QR decomposition. This input matrix will be overwritten with the decomposition.
      • qr

        default QR qr​(boolean inPlace)
        Returns the QR decomposition.
        Parameters:
        inPlace - if true, this matrix will be used for matrix decomposition.
      • svd

        SVD svd()
        Returns the singular value decomposition. Note that the input matrix will hold U on output.
      • svd

        default SVD svd​(boolean inPlace)
        Returns the singular value decomposition.
        Parameters:
        inPlace - if true, this matrix will hold U on output.
      • eigen

        EVD eigen()
        Returns the eigen value decomposition. Note that the input matrix will be overwritten on output.
      • eigen

        default EVD eigen​(boolean inPlace)
        Returns the eigen value decomposition.
        Parameters:
        inPlace - if true, this matrix will be overwritten U on output.
      • eig

        double[] eig()
        Returns the eigen values in an array of size 2N. The first half and second half of returned array contain the real and imaginary parts, respectively, of the computed eigenvalues.
      • eig

        default double[] eig​(boolean inPlace)
        Returns the eigen values in an array of size 2N. The first half and second half of returned array contain the real and imaginary parts, respectively, of the computed eigenvalues.
        Parameters:
        inPlace - if true, this matrix will be overwritten U on output.
      • inverse

        default DenseMatrix inverse()
        Returns the inverse matrix.
      • inverse

        default DenseMatrix inverse​(boolean inPlace)
        Returns the inverse matrix.
        Parameters:
        inPlace - if true, this matrix will be used for matrix decomposition.
      • norm1

        default double norm1()
        L1 matrix norm. Maximum column sum.
      • norm2

        default double norm2()
        L2 matrix norm. Maximum singular value.
      • norm

        default double norm()
        L2 matrix norm. Maximum singular value.
      • normInf

        default double normInf()
        Infinity matrix norm. Maximum row sum.
      • normFro

        default double normFro()
        Frobenius matrix norm. Sqrt of sum of squares of all elements.
      • xax

        default double xax​(double[] x)
        Returns x' * A * x. The left upper submatrix of A is used in the computation based on the size of x.
      • rowSums

        default double[] rowSums()
        Returns the sum of each row for a matrix.
      • rowMeans

        default double[] rowMeans()
        Returns the mean of each row for a matrix.
      • colSums

        default double[] colSums()
        Returns the sum of each column for a matrix.
      • colMeans

        default double[] colMeans()
        Returns the mean of each column for a matrix.
      • copy

        DenseMatrix copy()
        Returns a copy of this matrix.
      • add

        double add​(int i,
                   int j,
                   double x)
        A[i][j] += x
      • sub

        double sub​(int i,
                   int j,
                   double x)
        A[i][j] -= x
      • mul

        double mul​(int i,
                   int j,
                   double x)
        A[i][j] *= x
      • div

        double div​(int i,
                   int j,
                   double x)
        A[i][j] /= x
      • mul

        default DenseMatrix mul​(DenseMatrix b)
        In place element-wise multiplication A = A * B
        Returns:
        this matrix
      • div

        default DenseMatrix div​(DenseMatrix b)
        In place element-wise division A = A / B A = A - B
        Returns:
        this matrix
      • add

        default DenseMatrix add​(double x)
        In place element-wise addition A = A + x
      • sub

        default DenseMatrix sub​(double x)
        In place element-wise subtraction A = A - x
      • mul

        default DenseMatrix mul​(double x)
        In place element-wise multiplication A = A * x
      • div

        default DenseMatrix div​(double x)
        In place element-wise division A = A / x
      • replaceNaN

        default DenseMatrix replaceNaN​(double x)
        Replaces NaN's with given value.
      • sum

        default double sum()
        Returns the sum of all elements in the matrix.
        Returns:
        the sum of all elements.
      • array

        default double[][] array()
        Return the two-dimensional array of matrix.
        Returns:
        the two-dimensional array of matrix.