Psi4
block_vector.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_block_vector_h_
29 #define _psi_src_lib_libmemtrix_block_vector_h_
30 
31 #include <string>
32 #include <vector>
33 
34 #include "vector_base.h"
36 
37 typedef std::vector<int> vecint;
38 
39 namespace psi{ namespace mcscf{
40 
42 {
43 public:
44  BlockVector();
45  BlockVector(std::string label, int nirreps, size_t*& rows_size);
46  BlockVector(std::string label, int nirreps, int*& rows_size);
47  BlockVector(std::string label, int nirreps, vecint& rows_size);
48  ~BlockVector();
49 
50  void print();
51  void copy(BlockVector& source);
52 
53  // Inlines
54  void set(int h, int i, double value) {vector_base_[h]->set(i,value);}
55  void add(int h, int i, double value) {vector_base_[h]->add(i,value);}
56  double get(int h, int i) {return(vector_base_[h]->get(i));}
57 
58  VectorBase* getVectorBase(int h) {return(vector_base_[h]);}
59 
60  // Reference counting related
61  unsigned int ref () const { return ref_;} // Number of references
62  void add_reference () { ref_++;}
63  bool subtract_reference () { if (--ref_ == 0){ delete this; return true;} return false;}
64  // Reference count
65  unsigned int ref_;
66 private:
67  // Vector label and pointer
68  std::string label_;
70 
71  // Block sizes etc.
72  size_t* rows_size_;
73  size_t* rows_offset_;
74  int nirreps_;
75 
76  void startup(std::string label, int nirreps, size_t*& rows_size);
77  void startup(std::string label, int nirreps, int*& rows_size);
78  void startup(std::string label, int nirreps, vecint& rows_size);
79  void cleanup();
80 };
81 
82 }}
83 
84 #endif // _psi_src_lib_libmemtrix_block_vector_h_
size_t * rows_offset_
Definition: block_vector.h:73
size_t * rows_size_
Definition: block_vector.h:72
void set(int h, int i, double value)
Definition: block_vector.h:54
int nirreps_
Definition: block_vector.h:74
VectorBase * getVectorBase(int h)
Definition: block_vector.h:58
void add_reference()
Definition: block_vector.h:62
BlockVector()
Definition: block_vector.cc:41
Definition: pointgrp.h:105
void print()
Definition: block_vector.cc:136
bool subtract_reference()
Definition: block_vector.h:63
std::vector< int > vecint
Definition: block_matrix.h:35
SharedWavefunction mcscf(SharedWavefunction, Options &)
Definition: mcscf.cc:72
Definition: block_vector.h:41
void copy(BlockVector &source)
Definition: block_vector.cc:146
~BlockVector()
Definition: block_vector.cc:65
void cleanup()
Definition: block_vector.cc:124
void add(int i, double value)
Definition: vector_base.h:46
Definition: vector_base.h:36
unsigned int ref_
Definition: block_vector.h:65
void set(int i, double value)
Definition: vector_base.h:45
void startup(std::string label, int nirreps, size_t *&rows_size)
Definition: block_vector.cc:70
void add(int h, int i, double value)
Definition: block_vector.h:55
VectorBase ** vector_base_
Definition: block_vector.h:69
std::string label_
Definition: block_vector.h:68
unsigned int ref() const
Definition: block_vector.h:61