HubbardGPU
Hubbard diagonalisation on the GPU (and CPU)
 All Classes Files Functions Variables Typedefs Friends Macros
SparseMatrix_CCS.h
Go to the documentation of this file.
1 /* Copyright (C) 2014 Ward Poelmans
2 
3  This file is part of Hubbard-GPU.
4 
5  Hubbard-GPU is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Hubbard-GPU is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Hubbard-GPU. If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef SPARSEMATRIX_CCS_H
19 #define SPARSEMATRIX_CCS_H
20 
21 #include <iostream>
22 #include <vector>
23 
24 class matrix;
25 
26 using std::ostream;
27 
36 {
46  friend ostream &operator<<(ostream &output,SparseMatrix_CCS &matrix_p);
47 
48  public:
49 
50  //constructor
51  SparseMatrix_CCS(unsigned int n, unsigned int m);
52 
53  //copy constructor
55 
56  //destructor
57  virtual ~SparseMatrix_CCS();
58 
59  //overload equality operator
61 
62  //easy to change the numbers
63  // double &operator()(unsigned int i,unsigned int j);
64 
65  //easy to access the numbers
66  double operator()(unsigned int i,unsigned int j) const;
67 
68  unsigned int gn() const;
69 
70  unsigned int gm() const;
71 
72  void ConvertFromMatrix(const matrix &dense);
73 
74  void ConvertToMatrix(matrix &dense) const;
75 
76  void PrintRaw() const;
77 
78  void PushToCol(unsigned int j, double value);
79 
80  void NewCol();
81 
82  void mvprod(const matrix &, matrix &) const;
83 
84  unsigned int NumOfElInCol(unsigned int idx) const;
85 
86  double GetElementInCol(unsigned int col_index, unsigned int element_index) const;
87 
88  unsigned int GetElementRowIndexInCol(unsigned int col_index, unsigned int element_index) const;
89 
90  void prod(const matrix &, const SparseMatrix_CCS &);
91 
92  private:
93 
95  std::vector<double> data;
97  std::vector<unsigned int> col;
99  std::vector<unsigned int> row;
100 
102  unsigned int n;
104  unsigned int m;
105 };
106 
107 #endif /* SPARSEMATRIX_CCS_H */
108 
109 /* vim: set ts=3 sw=3 expandtab :*/