10 template<
class Device>
13 using exspace =
typename Device::execution_space;
27 View<double**,CLayout, Device>
value;
35 View<double*,CLayout, Device>
csr_v;
42 Matrix(
int m_in,
int n_in,
int w_in);
46 Matrix(
int m_in,
int n_in,
int w_in,
int nnz_in,
bool is_csr_in,
int* csr_ridx_or_eindex,
int* csr_cidx_or_nelement,
double* values);
49 template<
class Device2>
91 DEVICE_PRINTF(
"\n Error: set_value is only allowed when matrix is not in csr format");
96 if(i>=
m || j>=
n || i<0 || j<0){
105 value(i,l) = value_in;
107 value(i,l) += value_in;
121 DEVICE_PRINTF(
"\nError in set_value: Not enough memory space for matrix.");
136 double fac = norm/sum;
144 int ein_min =
eindex(i,j);
145 double val_min =
value(i,j);
151 val_min =
value(i,k2);
160 value(i,j) = val_min;
168 void mult_org(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
170 void mult_csr(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
172 void mult_tensor_org(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const;
174 void mult_tensor_csr(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const;
176 void transpose_mult_org(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
178 void transpose_mult_csr(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
182 void mult(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
184 void mult_tensor(
const View<double**,CLayout,Device>& x,
const View<double**,Kokkos::LayoutRight,Device>& y)
const;
186 void transpose_mult(
const View<double*,CLayout,Device>& x,
const View<double*,Kokkos::LayoutRight,Device>& y)
const;
188 void write(
const std::string stream_name,
const std::string filename)
const;
Definition: matrix.hpp:11
View< int *, CLayout, Device > csr_ridx
row index for CSR - m+1
Definition: matrix.hpp:34
Matrix()
Definition: matrix.hpp:40
void mult_org(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:152
int m
Definition: matrix.hpp:24
void transpose_mult_org(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:189
KOKKOS_INLINE_FUNCTION void normalize_row(int irow, double norm) const
Definition: matrix.hpp:133
void transpose_mult_csr(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:208
void write(const std::string stream_name, const std::string filename) const
Definition: matrix.cpp:326
SetValueOpt
Definition: matrix.hpp:15
@ Replace
Definition: matrix.hpp:16
@ Add
Definition: matrix.hpp:17
void mult_tensor_csr(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:248
typename Device::execution_space exspace
Use execution space where matrix views are allocated.
Definition: matrix.hpp:13
bool is_csr
Whether the matrix is in CSR format.
Definition: matrix.hpp:32
View< double *, CLayout, Device > csr_v
value of CSR - nnz
Definition: matrix.hpp:35
void convert_org_to_csr()
Definition: matrix.cpp:94
KOKKOS_INLINE_FUNCTION void set_value(int i, int j, double value_in, SetValueOpt flag) const
Definition: matrix.hpp:89
void mult_tensor(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:301
View< int *, CLayout, Device > csr_cidx
columun index - nnz
Definition: matrix.hpp:36
void mult_csr(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:170
KOKKOS_INLINE_FUNCTION void sort_row(int i) const
Definition: matrix.hpp:141
View< int **, CLayout, Device > eindex
column index - 1-indexed!!
Definition: matrix.hpp:28
int nnz
if in CSR format, number of (nonzero) values
Definition: matrix.hpp:33
void transpose_mult(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:317
View< double **, CLayout, Device > value
matrix value
Definition: matrix.hpp:27
Matrix< Device2 > mirror() const
Definition: matrix.hpp:50
View< int *, CLayout, Device > nelement
Definition: matrix.hpp:29
void mult_tensor_org(const View< double **, CLayout, Device > &x, const View< double **, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:227
int width
Definition: matrix.hpp:26
Type
Definition: matrix.hpp:20
@ Identity
Definition: matrix.hpp:21
int n
Definition: matrix.hpp:25
void mult(const View< double *, CLayout, Device > &x, const View< double *, Kokkos::LayoutRight, Device > &y) const
Definition: matrix.cpp:270
void mirror_copy(T1 &view_dest, const T2 &view_src)
Definition: my_mirror_view.hpp:122
View< T *, CLayout, Device > my_mirror_view(const View< T *, CLayout, Device > &view, Device nd)
Definition: my_mirror_view.hpp:14
#define DEVICE_PRINTF(...)
Definition: space_settings.hpp:86