Psi4
matrix_base.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_matrix_base_h_
30 #define _psi_src_lib_libmemtrix_matrix_base_h_
31 
32 #include <cstring> // for size_t
33 
35 #include "vector_base.h"
36 
37 namespace psi {
38 namespace mcscf {
39 
40 class MatrixBase {
41  public:
42  MatrixBase();
43  MatrixBase(size_t rows, size_t cols);
44  ~MatrixBase();
45 
46  // Inlines
47  size_t get_rows() { return (rows_); }
48  size_t get_cols() { return (cols_); }
49  size_t get_elements() { return (elements_); }
50  void set(size_t i, size_t j, double value) { matrix_[i][j] = value; }
51  void add(size_t i, size_t j, double value) { matrix_[i][j] += value; }
52  double get(size_t i, size_t j) { return (matrix_[i][j]); }
53  double** get_matrix() { return (matrix_); }
54 
55  void multiply(bool transpose_A, bool transpose_B, MatrixBase* A, MatrixBase* B);
56  void diagonalize(MatrixBase* eigenmatrix, VectorBase* eigenvalues);
57  void print();
58  void zero();
59  void zero_diagonal();
60  void scale(double factor);
61  void transpose();
62  MatrixBase& operator+=(const MatrixBase& rhs);
63  MatrixBase& operator-=(const MatrixBase& rhs);
64  friend double dot(MatrixBase* A, MatrixBase* B);
65 
66  private:
67  // Matrix size
68  size_t rows_;
69  size_t cols_;
70  size_t elements_;
71 
72  // Matrix data
73  double** matrix_;
74 };
75 
76 } // namespace mcscf
77 } // namespace psi
78 
79 #endif // _psi_src_lib_libmemtrix_matrix_base_h_
80 
81 /*
82 
83  int get_nirreps() {return(nirreps);}
84  int get_nirreps() const {return(nirreps);}
85  double*** get_matrix() {return(matrix);}
86  double** get_block(int h) {return(matrix[h]);}
87  const double** get_block(int h) const {return((const double**)matrix[h]);}
88  double get(int h, int i, int j) {return(matrix[h][i][j]);}
89  void set(int h, int i, int j, double value) {matrix[h][i][j] = value;}
90  void add(int h, int i, int j, double value) {matrix[h][i][j] += value;}
91  int get_block_size(int h) {return(block_size[h]);}
92  int get_block_size(int h) const {return(block_size[h]);}
93  void diagonalize(SBlockMatrix* eigenvectors, double* eigenvalues);
94  void DGEMM(bool transpose_A, bool transpose_B, SBlockMatrix* A, SBlockMatrix* B);
95  void minus(SBlockMatrix* B);
96 
97  friend double operator^(const SBlockMatrix& rhs,const SBlockMatrix& lhs);
98  SBlockMatrix& operator=(const SBlockMatrix& rhs);
99  SBlockMatrix& operator+=(const SBlockMatrix& lhs);
100 */
MatrixBase & operator+=(const MatrixBase &rhs)
Definition: matrix_base.cc:119
size_t get_elements()
Definition: matrix_base.h:49
void print()
Definition: matrix_base.cc:53
size_t elements_
Definition: matrix_base.h:70
size_t rows_
Definition: matrix_base.h:68
Definition: pointgrp.h:104
void set(size_t i, size_t j, double value)
Definition: matrix_base.h:50
MatrixBase & operator-=(const MatrixBase &rhs)
Definition: matrix_base.cc:127
size_t get_rows()
Definition: matrix_base.h:47
size_t get_cols()
Definition: matrix_base.h:48
void zero_diagonal()
Definition: matrix_base.cc:82
SharedWavefunction mcscf(SharedWavefunction, Options &)
Definition: mcscf.cc:69
void add(size_t i, size_t j, double value)
Definition: matrix_base.h:51
void diagonalize(MatrixBase *eigenmatrix, VectorBase *eigenvalues)
Definition: matrix_base.cc:103
friend double dot(MatrixBase *A, MatrixBase *B)
Definition: matrix_base.cc:110
void scale(double factor)
Definition: matrix_base.cc:61
Definition: vector_base.h:38
double ** get_matrix()
Definition: matrix_base.h:53
Definition: matrix_base.h:40
void zero()
Definition: matrix_base.cc:78
void transpose()
Definition: matrix_base.cc:65
void multiply(bool transpose_A, bool transpose_B, MatrixBase *A, MatrixBase *B)
Definition: matrix_base.cc:87
size_t cols_
Definition: matrix_base.h:69
~MatrixBase()
Definition: matrix_base.cc:51
double ** matrix_
Definition: matrix_base.h:73