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
26
namespace
TNT
27
{
28
29
47
template
<
class
T>
48
class
Sparse_Matrix_CompRow
{
49
50
private
:
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
58
public
:
59
60
Sparse_Matrix_CompRow
(
const
Sparse_Matrix_CompRow
&S);
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
75
Sparse_Matrix_CompRow
&
operator=
(
76
const
Sparse_Matrix_CompRow
&R);
77
78
79
80
};
81
94
template
<
class
T>
95
Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow
(
int
M,
int
N
,
int
nz,
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
solvers
gain
wasiak
wzmocnienie
tnt
tnt_sparse_matrix_csr.h
Generated by
1.9.8