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