Psi4
sblock_matrix.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _psi_src_lib_libmemtrix_sblock_matrix_h_
29 #define _psi_src_lib_libmemtrix_sblock_matrix_h_
30 
31 #include <string>
32 #include <vector>
33 
34 #include "block_matrix.h"
35 #include "sblock_vector.h"
36 
37 namespace psi{ namespace mcscf{
38 
39 // Smart version of BlockMatrix
41 {
42 public:
43  SBlockMatrix();
44  SBlockMatrix(std::string label, int nirreps, size_t*& rows_size, size_t*& cols_size);
45  SBlockMatrix(std::string label, int nirreps, int*& rows_size, int*& cols_size);
46  SBlockMatrix(std::string label, int nirreps, vecint& rows_size, vecint& cols_size);
49  block_matrix_ = 0;}
50 
51  // Manual allocation
52  void allocate(std::string label, int nirreps, size_t*& rows_size, size_t*& cols_size);
53  void allocate(std::string label, int nirreps, int*& rows_size, int*& cols_size);
54  void allocate(std::string label, int nirreps, vecint& rows_size, vecint& cols_size);
55 
57  if(block_matrix_){
59  block_matrix_ = 0;
60  }
61  }
62 
63  // Copy constructor and assignment operator
68 
69  // Allow access to the implementation object functions
70  const BlockMatrix* operator-> () const {return block_matrix_;}
72 
73  // Copy the implementation object
74 // void copy(SBlockMatrix& src);
75 
76  // Access the implementation object
78 
79  //Operations
80  void multiply(bool transpose_A, bool transpose_B, SBlockMatrix& A, SBlockMatrix& B);
81  void diagonalize(SBlockMatrix& eigenmatrix,SBlockVector& eigenvalues);
83  void scale(double factor) {block_matrix_->scale(factor);}
84  friend double dot(SBlockMatrix& A,SBlockMatrix& B);
85 
86  // Checking functions
87  bool is_allocated() {return (block_matrix_);}
88  void check(const char* cstr);
89 
90 private:
92 
94 };
95 
96 }}
97 
98 #endif // _psi_src_lib_libmemtrix_sblock_matrix_h_
99 
100 /*
101  SBlockMatrix(std::string label_, int nirreps_, int*& block_size_);
102  ~SBlockMatrix();
103  void print();
104  int get_nirreps() {return(nirreps);}
105  int get_nirreps() const {return(nirreps);}
106  double*** get_matrix() {return(matrix);}
107  double** get_block(int h) {return(matrix[h]);}
108  const double** get_block(int h) const {return((const double**)matrix[h]);}
109  double get(int h, int i, int j) {return(matrix[h][i][j]);}
110  void set(int h, int i, int j, double value) {matrix[h][i][j] = value;}
111  void add(int h, int i, int j, double value) {matrix[h][i][j] += value;}
112  int get_block_size(int h) {return(block_size[h]);}
113  int get_block_size(int h) const {return(block_size[h]);}
114  void diagonalize(SBlockMatrix* eigenvectors, double* eigenvalues);
115  void DGEMM(bool transpose_A, bool transpose_B, SBlockMatrix* A, SBlockMatrix* B);
116  void minus(SBlockMatrix* B);
117  void zero();
118  void scale(double factor);
119  void transpose();
120  friend double operator^(const SBlockMatrix& rhs,const SBlockMatrix& lhs);
121  SBlockMatrix& operator=(const SBlockMatrix& rhs);
122  SBlockMatrix& operator+=(const SBlockMatrix& lhs);
123 private:
124  // Matrix label and pointer
125  std::string label;
126  double*** matrix;
127 
128  // Block sizes etc.
129  int nirreps;
130  int* block_size;
131  int* block_offset;
132 
133  // Private functions
134  void sort_eigensystem(int n,double*& eigenvalues,double**& eigenvectors);
135  void cleanup();
136 */
BlockMatrix * block_matrix_
Definition: sblock_matrix.h:93
SBlockMatrix & operator=(SBlockMatrix &src)
Definition: sblock_matrix.cc:109
void scale(double factor)
Definition: sblock_matrix.h:83
SBlockMatrix()
Definition: sblock_matrix.cc:39
Definition: sblock_matrix.h:40
friend double dot(SBlockMatrix &A, SBlockMatrix &B)
Definition: sblock_matrix.cc:143
std::vector< int > vecint
Definition: block_matrix.h:35
const BlockMatrix * operator->() const
Definition: sblock_matrix.h:70
double ** block_matrix(unsigned long int n, unsigned long int m, bool memlock)
Definition: libciomr/block_matrix.cc:75
void transpose()
Definition: sblock_matrix.h:82
SharedWavefunction mcscf(SharedWavefunction, Options &)
Definition: mcscf.cc:72
void transpose()
Definition: mcscf/block_matrix.cc:203
void diagonalize(SBlockMatrix &eigenmatrix, SBlockVector &eigenvalues)
Definition: sblock_matrix.cc:137
SBlockMatrix & operator-=(SBlockMatrix &src)
Definition: sblock_matrix.cc:102
Definition: block_matrix.h:41
void check(const char *cstr)
Definition: sblock_matrix.cc:149
void subtract_reference()
Definition: sblock_matrix.h:56
bool subtract_reference()
Definition: block_matrix.h:79
bool is_allocated()
Definition: sblock_matrix.h:87
void multiply(bool transpose_A, bool transpose_B, SBlockMatrix &A, SBlockMatrix &B)
Definition: sblock_matrix.cc:131
BlockMatrix * getBlockMatrix()
Definition: sblock_matrix.h:77
Definition: sblock_vector.h:38
SBlockMatrix & operator+=(SBlockMatrix &src)
Definition: sblock_matrix.cc:95
Definition: PsiFileImpl.h:38
void allocate(std::string label, int nirreps, size_t *&rows_size, size_t *&cols_size)
Definition: sblock_matrix.cc:77
~SBlockMatrix()
Definition: sblock_matrix.h:47
void scale(double factor)
Definition: mcscf/block_matrix.cc:197