-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsparse_rect.h
More file actions
48 lines (39 loc) · 1.24 KB
/
Copy pathsparse_rect.h
File metadata and controls
48 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* sparse_rect.h - sparse rectangular matrix interface
*
* Jun Korenaga, MIT/WHOI
* January 1999
*/
#ifndef _TOMO_SPARSE_RECT_H_
#define _TOMO_SPARSE_RECT_H_
#include <map>
#include <array.h> // from mconv
struct SparseMatAux {
SparseMatAux(double d=1.0, const Array1d<int> *r=0,
const Array1d<int> *c=0)
: scale_factor(d), p_row(r), p_col(c) {}
double scale_factor;
const Array1d<int> *p_row;
const Array1d<int> *p_col;
};
class SparseRectangular {
public:
typedef Array1d< map<int,double> > sparseMap;
SparseRectangular(){};
SparseRectangular(const sparseMap& A, int ncol=0);
SparseRectangular(const sparseMap& A, const Array1d<int>& r,
const Array1d<int>& c, int ncol=0);
SparseRectangular(const Array1d<const sparseMap*>& As,
const Array1d<SparseMatAux>& spec, int ncol=0);
int nRow() const { return nrow; }
int nCol() const { return ncol; }
void Ax(const Array1d<double>&, Array1d<double>&, bool init=true) const;
void Atx(const Array1d<double>&, Array1d<double>&, bool init=true) const;
void dump(const char*) const;
private:
int nrow, ncol;
Array1d<double> val;
Array1d<int> index_j;
Array1d<int> first_k;
};
#endif /* _TOMO_SPARSE_RECT_H_ */