Learn R Programming

HiPLARM (version 0.1)

solve: Solve a linear system Ax=b using GPU or multi-core architectures

Description

Solve, using a GPU or multi-core CPU, a linear system Ax=b where A is one of dgeMatrix, dpoMatrix, dtrMatrix or dtpMatrix.

Usage

"solve"(A, b, ...) "solve"(A, b, ...) "solve"(A, b, ...) "solve"(A, b, ...)

Arguments

A
Square dense matrix inheriting from dMatrix.
b
Matrix/vector inheriting from dMatrix or base::matrix.
...
potentially further arguments passed to methods.

Methods

solve
signature(A = "dgeMatrix", b = "missing"): Sets b as the identity matrix and calculates inverse of A; Uses PLASMA_dgetri or magma_dgetri for multi-core CPU and GPU respectively. Also uses some LAPACK dgetri to test singularity.
solve
signature(A = "dgeMatrix", b = "ddenseMatrix"): Solves a linear system where b inherits from ddenseMatrix. If the routine is calling MAGMA "magma_dgetrs_gpu" is called. If PLASMA is chosen "PLASMA_dgetrs" is called.
solve
signature(A = "dgeMatrix", b = "matrix"): Solves a linear system where b is of type matrix from the R base. If the routine is calling MAGMA "magma_dgetrs_gpu" is called. If PLASMA is chosen "PLASMA_dgetrs" is called.
solve
signature(A = "dgeMatrix", b = "sparseMatrix"): Solves a linear system where b is a sparseMatrix from the Matrix package. For this routine the sparse matrix is coerced to a real dense matrix. If the routine is calling MAGMA "magma_dgetrs_gpu" is called. If PLASMA is chosen "PLASMA_dgetrs" is called.
solve
signature(A = "dpoMatrix", b = "missing"): Sets b as the identity matrix and calculates inverse of A; Uses "PLASMA_dgetri" or "magma_dpotri_gpu" for multi-core CPU and GPU respectively.
solve
signature(A = "dpoMatrix", b = "dgeMatrix"): Solves a linear system where b is of type dgeMatrix. If the routine is calling MAGMA "magma_dpotrs_gpu" is called. If PLASMA is chosen "PLASMA_dpotrs" is called.
solve
signature(A = "dpoMatrix", b = "matrix"): Solves a linear system where b is of type matrix from the R base. If the routine is calling MAGMA "magma_dpotrs_gpu" is called. If PLASMA is chosen "PLASMA_dpotrs" is called.
solve
signature(A = "dtpMatrix", b = "missing"): Sets b as the identity matrix and calculates inverse of A; This is only supported on the GPU so there is no PLASMA call here. Also the CUBLAS library is called here using cublasDtpsv
.
solve
signature(A = "dtpMatrix", b = "ddenseMatrix"): Solves a linear system where b inherits from ddenseMatrix. Again there is no MAGMA or PLASMA support for the dtpMatrix type but for GPU capable systems we call cublasDtpsv.
solve
signature(A = "dtrMatrix", b = "missing"): Sets b as the identity matrix and calculates inverse of A; Uses "PLASMA_dtrtri" or "magma_dtrtri" for multi-core CPU and GPU respectively.
solve
signature(A = "dtrMatrix", b = "ddenseMatrix"): Solves a linear system where b inherits from ddenseMatrix. If the routine is calling MAGMA "magma_dtrsm" is called. If PLASMA is chosen "PLASMA_dtrsm" is called.
solve
signature(A = "dtrMatrix", b = "matrix"): Solves a linear system where b is of type matrix from the R base. If the routine is calling MAGMA "magma_dtrsm" is called. If PLASMA is chosen "PLASMA_dtrsm" is called.
solve
signature(A = "dtrMatrix", b = "Matrix"): Solves a linear system where b inherits from Matrix. If the routine is calling MAGMA "magma_dtrsm" is called. If PLASMA is chosen "PLASMA_dtrsm" is called.
solve
signature(A = "dtrMatrix", b = "dMatrix"): Solves a linear system where b inherits from Matrix. If the routine is calling MAGMA "magma_dtrsm" is called. If PLASMA is chosen "PLASMA_dtrsm" is called.

Details

For further details on classes and methods see the full Matrix package documentation.

References

Martin Maechler, Douglas Bates (Matrix package)

Examples

Run this code
 p <- 128
 A <- Matrix(rnorm(p*p), p, p) # random square matrix for large p
 x_init <- vector("numeric", p)
 b <- A 
 x <- solve(A, b)
 stopifnot(identical(x, x_init))

Run the code above in your browser using DataLab