69 template<
typename T >
84 virtual unsigned long int m() = 0;
87 virtual unsigned long int n() = 0;
90 virtual unsigned long int nzs() {
101 virtual T*
mv(
const T* x ) = 0;
109 virtual void zax(
const T*__restrict__ x, T*__restrict__ z ) = 0;
124 virtual void zax(
const T*__restrict__ x, T*__restrict__ z,
const size_t k,
const clockid_t clock_id = 0,
double *elapsed_time = NULL ) {
125 struct timespec start, stop;
126 if( elapsed_time != NULL ) {
127 clock_gettime( clock_id, &start);
129 for(
size_t i = 0; i < k; ++i ) {
132 if( elapsed_time != NULL ) {
133 clock_gettime( clock_id, &stop);
134 double time = (stop.tv_sec-start.tv_sec)*1000;
135 time += (stop.tv_nsec-start.tv_nsec)/1000000.0;
136 *elapsed_time += time;
153 void ZaX(
const T*__restrict__
const *__restrict__
const X, T *__restrict__
const *__restrict__
const Z ) {
155 for(
size_t i = 0; i < k; ++i ) {
168 virtual void zxa(
const T*__restrict__ x, T*__restrict__ z ) = 0;
184 void ZXa(
const T *__restrict__
const *__restrict__
const X, T *__restrict__
const *__restrict__
const Z ) {
186 for(
size_t i = 0; i < k; ++i ) {
194 virtual void zxa(
const T*__restrict__ x, T*__restrict__ z,
const unsigned long int repeat,
const clockid_t clock_id = 0,
double *elapsed_time = NULL ) {
195 struct timespec start, stop;
196 if( elapsed_time != NULL ) clock_gettime( clock_id, &start);
197 for(
unsigned long int i=0; i<repeat; i++ )
199 if( elapsed_time != NULL ) {
200 clock_gettime( clock_id, &stop);
201 double time = (stop.tv_sec-start.tv_sec)*1000;
202 time += (stop.tv_nsec-start.tv_nsec)/1000000.0;
203 *elapsed_time += time;
virtual unsigned long int nzs()
Definition: Matrix.hpp:90
virtual void zax(const T *__restrict__ x, T *__restrict__ z)=0
In-place z=Ax function.
virtual unsigned long int n()=0
virtual void zax(const T *__restrict__ x, T *__restrict__ z, const size_t k, const clockid_t clock_id=0, double *elapsed_time=NULL)
Wrapper function to call the zax kernel multiple times successively, while timing the duration of the...
Definition: Matrix.hpp:124
void ZaX(const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
In-place Z=AX function, where A is m x n, Z = m x k, and X is n x k.
Definition: Matrix.hpp:153
virtual size_t bytesUsed()=0
Function to query the amount of storage required by this sparse matrix.
virtual T * mv(const T *x)=0
Calculates z=Ax (where A is this matrix).
Matrix()
Base constructor.
Definition: Matrix.hpp:78
virtual unsigned long int m()=0
void ZXa(const T *__restrict__ const *__restrict__ const X, T *__restrict__ const *__restrict__ const Z)
In-place Z=XA function, where A is m x n, Z = k x n, and X is k x m.
Definition: Matrix.hpp:184
Defines operations common to all matrices, which are implemented in this library. ...
Definition: Matrix.hpp:70
virtual void zxa(const T *__restrict__ x, T *__restrict__ z, const unsigned long int repeat, const clockid_t clock_id=0, double *elapsed_time=NULL)
Wrapper function to call the zxa kernel multiple times successively, while timing the operation durat...
Definition: Matrix.hpp:194
virtual void zxa(const T *__restrict__ x, T *__restrict__ z)=0
In-place z=xA function.
virtual ~Matrix()
Base deconstructor.
Definition: Matrix.hpp:81