v2DM-DOCI  1.0
BlockStructure.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Copyright (C) 2014-2015 Ward Poelmans
5  *
6  * This file is part of v2DM-DOCI.
7  *
8  * v2DM-DOCI is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Foobar is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * @END LICENSE
22  */
23 
24 #ifndef BLOCKSTRUCTURE_H
25 #define BLOCKSTRUCTURE_H
26 
27 #include <iostream>
28 #include <memory>
29 #include <vector>
30 
31 #include "Matrix.h"
32 #include "Vector.h"
33 
34 namespace doci2DM
35 {
36 
44 template<class BlockType>
46 {
57  template<class MyBlockType>
58  friend std::ostream &operator<< (std::ostream &output,const doci2DM::BlockStructure<MyBlockType> &blocks_p);
59 
60  public:
61 
62  BlockStructure(int);
63 
64  //construct with as input a BlockMatrixType
65  // BlockStructure(BlockType &);
66 
67  //copy constructor
69 
71 
72  //destructor
73  virtual ~BlockStructure() = default;
74 
75  void setDim(int,int,int);
76 
77  //overload equality operator
79 
81 
82  BlockStructure &operator=(double);
83 
84  //overload += operator
86 
87  //overload -= operator
89 
90  BlockStructure &daxpy(double alpha,const BlockStructure<BlockType> &);
91 
92  BlockStructure &operator*=(double);
93 
94  BlockStructure &operator/=(double);
95 
96  BlockType &operator[](int block);
97 
98  //const version
99  const BlockType &operator[](int block) const;
100 
101  double &operator()(int block,int i, int j);
102 
103  //easy to access the numbers
104  double operator()(int block,int i, int j) const;
105 
106  //easy to change the numbers
107  double &operator()(int block,int index);
108 
109  //easy to access the numbers
110  double operator()(int block,int index) const;
111 
112 // virtual void diagonalize(BlockStructure<Matrix> &);
113 
114  int gnr() const;
115 
116  int gdim(int) const;
117 
118  int gdeg(int) const;
119 
120  double trace() const;
121 
122  double ddot(const BlockStructure<BlockType> &) const;
123 
124  void dscal(double alpha);
125 
126  double min() const;
127 
128  double max() const;
129 
130  void fill_Random();
131 
132  void fill_Random(int);
133 
134  virtual void invert();
135 
136  virtual void sqrt(int);
137 
138  virtual void L_map(const BlockStructure<BlockType> &,const BlockStructure<BlockType> &);
139 
141 
142  void symmetrize();
143 
144  void sort();
145 
147 
148  private:
149 
150  std::vector< std::unique_ptr<BlockType> > blocks;
151 
153  std::vector<int> degen;
154 };
155 
158 
159 }
160 
161 #endif
162 
163 /* vim: set ts=3 sw=3 expandtab :*/
BlockStructure & operator*=(double)
virtual void sqrt(int)
std::vector< int > degen
degeneracy of the blocks
BlockStructure< Matrix > BlockMatrix
virtual ~BlockStructure()=default
double max() const
double ddot(const BlockStructure< BlockType > &) const
BlockStructure & operator-=(const BlockStructure< BlockType > &)
virtual BlockStructure< BlockType > & mprod(const BlockStructure< BlockType > &, const BlockStructure< BlockType > &)
double & operator()(int block, int i, int j)
BlockType & operator[](int block)
void setDim(int, int, int)
void dscal(double alpha)
std::vector< std::unique_ptr< BlockType > > blocks
BlockStructure & operator=(const BlockStructure< BlockType > &)
BlockStructure< Vector > BlockVector
BlockStructure & operator/=(double)
virtual void L_map(const BlockStructure< BlockType > &, const BlockStructure< BlockType > &)
virtual void sep_pm(BlockStructure< BlockType > &, BlockStructure< BlockType > &)
BlockStructure & operator+=(const BlockStructure< BlockType > &)
BlockStructure & daxpy(double alpha, const BlockStructure< BlockType > &)
double min() const