cuLite v0.3.1
A lite CUDA C++ Interface
Loading...
Searching...
No Matches
Dense (cuSOLVER Based)

This section demonstrates how to solve dense systems of linear equations on GPU using standard factorization methods.

LU Decomposition (General Matrices)

Performs LU factorization with partial pivoting for general matrices on GPU.

Source CodeConsole Output
#include <iostream>
#include <cla3p/dense.hpp>
#include <cla3p/algebra.hpp>
#include <culite/dense.hpp>
#include <culite/linsol.hpp>
int main()
{
/*
* Create a random dense objects on host
*/
/*
* Transfer to device
*/
HostA >> A;
HostBv >> b;
HostBm >> B;
/*
* Instantiate LU solver
*/
/*
* Decompose A into LU product
*/
luSolver.decompose(A);
{
/*
* Single column (vector) rhs
* Overwrite x with the solution (A^{-1} * Bv)
*/
luSolver.solve(x);
// Check error norm on host
x >> HostX;
std::cout << "Dense Vector rhs::Absolute Error: "
<< (HostBv - HostA * HostX).evaluate().normOne() << std::endl;
}
{
/*
* Multiple column (matrix) rhs
* Overwrite X with the solution (A^{-1} * B)
*/
luSolver.solve(X);
// Check error norm on host
X >> HostX;
std::cout << "Dense Matrix rhs::Absolute Error: "
<< (HostBm - HostA * HostX).evaluate().normOne() << std::endl;
}
return 0;
}
static XxMatrix< T_Scalar > random(int_t nr, int_t nc, const Property &pr=Property::General(), T_RScalar lo=T_RScalar(0), T_RScalar hi=T_RScalar(1))
T_RScalar normOne() const
T_RScalar normOne() const
static XxVector< T_Scalar > random(int_t n, T_RScalar lo=T_RScalar(0), T_RScalar hi=T_RScalar(1))
void decompose(const T_Matrix &mat)
Performs matrix decomposition.
void solve(T_Matrix &rhs) const
Performs in-place matrix solution.
The partial pivoting LU linear solver for dense device matrices.
Definition lapack_lu.hpp:40
XxMatrix< real_t > RdMatrix
XxVector< real_t > RdVector
XxMatrix< real_t > RdMatrix
Double precision real matrix.
Definition dense.hpp:55
XxVector< real_t > RdVector
Double precision real device vector.
Definition dense.hpp:31
Dense Vector rhs::Absolute Error: 1.7656e-16
Dense Matrix rhs::Absolute Error: 6.66134e-16