gastro  0.1.0
 All Classes Files Functions Variables Pages
tripletlist.h
1 #ifndef TRIPLETLIST__H
2 #define TRIPLETLIST__H
3 
4 #include "Eigen/Sparse"
5 
6 #include <vector>
7 
8 typedef Eigen::Triplet<double> Trip;
9 
10 // at the moment this class implements the eigen format.
11 // it would be wise to implement it differently if talking to cholmod
12 class TripletList : public std::vector<Trip>
13 {
14  unsigned nextFreeIndex;
15  public :
16  TripletList(int Count) {nextFreeIndex = 0; reserve(Count);};
17 
18  void AddTriplet(const unsigned i, const unsigned j, double val)
19  {
20  push_back(Trip(i,j,val));
21  }
22 
23  unsigned NextFreeIndex() const
24  {
25  return nextFreeIndex;
26  }
27 
28  void SetNextFreeIndex(unsigned Index)
29  {
30  nextFreeIndex = Index;
31  }
32 
33 };
34 
35 
36 
37 
38 
39 
40 
41 
42 #endif /* SPARSEALGEBRA__H */