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 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{ namespace mcscf{
39 
40 // Smart version of BlockMatrix
42 {
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);
50  block_matrix_ = 0;}
51 
52  // Manual allocation
53  void allocate(std::string label, int nirreps, size_t*& rows_size, size_t*& cols_size);
54  void allocate(std::string label, int nirreps, int*& rows_size, int*& cols_size);
55  void allocate(std::string label, int nirreps, vecint& rows_size, vecint& cols_size);
56 
58  if(block_matrix_){
60  block_matrix_ = 0;
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 }}
98 
99 #endif // _psi_src_lib_libmemtrix_sblock_matrix_h_
100 
101 /*
102  SBlockMatrix(std::string label_, int nirreps_, int*& block_size_);
103  ~SBlockMatrix();
104  void print();
105  int get_nirreps() {return(nirreps);}
106  int get_nirreps() const {return(nirreps);}
107  double*** get_matrix() {return(matrix);}
108  double** get_block(int h) {return(matrix[h]);}
109  const double** get_block(int h) const {return((const double**)matrix[h]);}
110  double get(int h, int i, int j) {return(matrix[h][i][j]);}
111  void set(int h, int i, int j, double value) {matrix[h][i][j] = value;}
112  void add(int h, int i, int j, double value) {matrix[h][i][j] += value;}
113  int get_block_size(int h) {return(block_size[h]);}
114  int get_block_size(int h) const {return(block_size[h]);}
115  void diagonalize(SBlockMatrix* eigenvectors, double* eigenvalues);
116  void DGEMM(bool transpose_A, bool transpose_B, SBlockMatrix* A, SBlockMatrix* B);
117  void minus(SBlockMatrix* B);
118  void zero();
119  void scale(double factor);
120  void transpose();
121  friend double operator^(const SBlockMatrix& rhs,const SBlockMatrix& lhs);
122  SBlockMatrix& operator=(const SBlockMatrix& rhs);
123  SBlockMatrix& operator+=(const SBlockMatrix& lhs);
124 private:
125  // Matrix label and pointer
126  std::string label;
127  double*** matrix;
128 
129  // Block sizes etc.
130  int nirreps;
131  int* block_size;
132  int* block_offset;
133 
134  // Private functions
135  void sort_eigensystem(int n,double*& eigenvalues,double**& eigenvectors);
136  void cleanup();
137 */
BlockMatrix * block_matrix_
Definition: sblock_matrix.h:94
SBlockMatrix & operator=(SBlockMatrix &src)
Definition: sblock_matrix.cc:110
void scale(double factor)
Definition: sblock_matrix.h:84
SBlockMatrix()
Definition: sblock_matrix.cc:40
Definition: sblock_matrix.h:41
friend double dot(SBlockMatrix &A, SBlockMatrix &B)
Definition: sblock_matrix.cc:144
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:73
void transpose()
Definition: mcscf/block_matrix.cc:204
void diagonalize(SBlockMatrix &eigenmatrix, SBlockVector &eigenvalues)
Definition: sblock_matrix.cc:138
SBlockMatrix & operator-=(SBlockMatrix &src)
Definition: sblock_matrix.cc:103
Definition: block_matrix.h:42
void check(const char *cstr)
Definition: sblock_matrix.cc:150
void subtract_reference()
Definition: sblock_matrix.h:57
bool subtract_reference()
Definition: block_matrix.h:80
bool is_allocated()
Definition: sblock_matrix.h:88
void multiply(bool transpose_A, bool transpose_B, SBlockMatrix &A, SBlockMatrix &B)
Definition: sblock_matrix.cc:132
BlockMatrix * getBlockMatrix()
Definition: sblock_matrix.h:78
Definition: sblock_vector.h:39
SBlockMatrix & operator+=(SBlockMatrix &src)
Definition: sblock_matrix.cc:96
double ** block_matrix(unsigned long int n, unsigned long int m, bool memlock)
Definition: libciomr/block_matrix.cc:76
Definition: PsiFileImpl.h:39
void allocate(std::string label, int nirreps, size_t *&rows_size, size_t *&cols_size)
Definition: sblock_matrix.cc:78
~SBlockMatrix()
Definition: sblock_matrix.h:48
void scale(double factor)
Definition: mcscf/block_matrix.cc:198