28 #include <cusp/array1d.h>
29 #include <cusp/array2d.h>
30 #include <cusp/linear_operator.h>
39 template <
typename IndexType,
typename ValueType,
typename MemorySpace,
typename OrientationA>
41 cusp::array1d<IndexType,MemorySpace>& pivot)
43 const int n = A.num_rows;
46 for (
int k = 0; k < n; k++)
52 for (
int j = k + 1;
j < n;
j++)
64 for (
int j = 0;
j < n;
j++)
65 std::swap(A(k,
j), A(pivot[k],
j));
72 for (
int i = k + 1; i < n; i++)
76 for (
int i = k + 1; i < n; i++)
77 for (
int j = k + 1;
j < n;
j++)
78 A(i,
j) -= A(i,k) * A(k,
j);
85 template <
typename IndexType,
typename ValueType,
typename MemorySpace,
86 typename OrientationA,
typename OrientationB>
88 const cusp::array1d<IndexType,MemorySpace>& pivot,
89 const cusp::array2d<ValueType,MemorySpace,OrientationB>& b,
90 cusp::array2d<ValueType,MemorySpace,OrientationB>& x,
93 const int n = A.num_rows;
94 const int numRHS = b.num_cols;
99 for (
int k = 0; k < n; k++)
102 for (
int j = 0;
j < numRHS;
j++)
103 std::swap(x(k,
j),x(pivot[k],
j));
106 for (
int i = 0; i < k; i++){
107 for (
int j = 0;
j< numRHS;
j++)
108 x(k,
j) -= A(k,i) * x(i,
j);
114 for (
int k = n - 1; k >= 0; k--)
116 for (
int j = 0;
j< numRHS;
j++){
117 for (
int i = k + 1; i < n; i++){
118 x(k,
j) -= A(k,i) * x(i,
j);
132 template <
typename ValueType,
typename MemorySpace>
135 cusp::array2d<ValueType,cusp::host_memory>
lu;
136 cusp::array1d<int,cusp::host_memory>
pivot;
141 template <
typename MatrixType>
143 linear_operator<ValueType,MemorySpace>(A.num_rows, A.num_cols, A.num_entries)
145 CUSP_PROFILE_SCOPED();
148 pivot.resize(A.num_rows);
152 template <
typename VectorType1,
typename VectorType2>
155 CUSP_PROFILE_SCOPED();
KOKKOS_INLINE_FUNCTION PCE< Storage > fabs(const PCE< Storage > &a)
int block_lu_solve(const cusp::array2d< ValueType, MemorySpace, OrientationA > &A, const cusp::array1d< IndexType, MemorySpace > &pivot, const cusp::array2d< ValueType, MemorySpace, OrientationB > &b, cusp::array2d< ValueType, MemorySpace, OrientationB > &x, cusp::array2d_format)
int block_lu_factor(cusp::array2d< ValueType, MemorySpace, OrientationA > &A, cusp::array1d< IndexType, MemorySpace > &pivot)
cusp::array2d< ValueType, cusp::host_memory > lu
KOKKOS_INLINE_FUNCTION PCE< Storage > max(const typename PCE< Storage >::value_type &a, const PCE< Storage > &b)
void operator()(const VectorType1 &b, VectorType2 &x) const
block_lu_solver(const MatrixType &A)
cusp::array1d< int, cusp::host_memory > pivot