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