PLaSK library
Loading...
Searching...
No Matches
tnt_sparse_matrix_csr.h
Go to the documentation of this file.
1/*
2*
3* Template Numerical Toolkit (TNT)
4*
5* Mathematical and Computational Sciences Division
6* National Institute of Technology,
7* Gaithersburg, MD USA
8*
9*
10* This software was developed at the National Institute of Standards and
11* Technology (NIST) by employees of the Federal Government in the course
12* of their official duties. Pursuant to title 17 Section 105 of the
13* United States Code, this software is not subject to copyright protection
14* and is in the public domain. NIST assumes no responsibility whatsoever for
15* its use by other parties, and makes no guarantees, expressed or implied,
16* about its quality, reliability, or any other characteristic.
17*
18*/
19
20
21#ifndef TNT_SPARSE_MATRIX_CSR_H
22#define TNT_SPARSE_MATRIX_CSR_H
23
24#include "tnt_array1d.h"
25
26namespace TNT
27{
28
29
47template <class T>
49
50private:
51 Array1D<T> val_; // data values (nz_ elements)
52 Array1D<int> rowptr_; // row_ptr (dim_[0]+1 elements)
53 Array1D<int> colind_; // col_ind (nz_ elements)
54
55 int dim1_; // number of rows
56 int dim2_; // number of cols
57
58public:
59
61 Sparse_Matrix_CompRow(int M, int N, int nz, const T *val,
62 const int *r, const int *c);
63
64
65
66 inline const T& val(int i) const { return val_[i]; }
67 inline const int& row_ptr(int i) const { return rowptr_[i]; }
68 inline const int& col_ind(int i) const { return colind_[i];}
69
70 inline int dim1() const {return dim1_;}
71 inline int dim2() const {return dim2_;}
72 int NumNonzeros() const {return val_.dim1();}
73
74
76 const Sparse_Matrix_CompRow &R);
77
78
79
80};
81
94template <class T>
96 const T *val, const int *r, const int *c) : val_(nz,val),
97 rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
98
99
100}
101// namespace TNT
102
103#endif