MPQC  3.0.0-alpha
dim.h
1 //
2 // dim.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit 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 Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _math_scmat_dim_h
29 #define _math_scmat_dim_h
30 
31 #include <util/keyval/keyval.h>
32 #include <util/state/state.h>
33 
34 namespace sc {
35 
36 class RefSCDimension;
46 class SCBlockInfo: public SavableState {
47  protected:
48  int n_;
49  int nblocks_;
50  int *start_;
51  int *size_;
52  RefSCDimension *subdims_;
53  void init_start();
54  public:
56  SCBlockInfo(int n, int nblocks = 0, const int *blocksizes = 0);
70  SCBlockInfo(const Ref<KeyVal>& keyval);
71 
72  ~SCBlockInfo();
74 
76  int equiv(SCBlockInfo *bi);
78  int nelem() const { return n_; }
80  int nblock() const { return nblocks_; }
82  int start(int i) const { return start_[i]; }
84  int size(int i) const { return size_[i]; }
86  int fence(int i) const { return start_[i] + size_[i]; }
87 
88  void elem_to_block(int i, int &block, int &offset);
89 
91  RefSCDimension subdim(int i);
95  void set_subdim(int i, const RefSCDimension &dim);
96 
98  void print(std::ostream&o=ExEnv::out0()) const;
99 };
100 
101 
105 class SCDimension: public SavableState {
106  protected:
107  std::string name_;
108  int n_;
109  Ref<SCBlockInfo> blocks_;
110  SCDimension(const char* name = 0);
111  public:
114  SCDimension(int n, const char* name = 0);
115  SCDimension(const Ref<SCBlockInfo>&, const char *name = 0);
116  SCDimension(int n, int nblocks, const int *blocksizes = 0,
117  const char* name = 0);
128  SCDimension(const Ref<KeyVal>&);
129  SCDimension(StateIn&s);
130 
131  ~SCDimension();
132  void save_data_state(StateOut&);
133 
135  int equiv(const SCDimension*) const;
136 
138  int n() const { return n_; }
141  const char* name() const { return name_.c_str(); }
142 
144  const Ref<SCBlockInfo>& blocks() const { return blocks_; }
145 
147  void print(std::ostream&o=ExEnv::out0()) const;
148 };
149 
152 class RefSCDimension: public Ref<SCDimension> {
153  // standard overrides
154  public:
157  RefSCDimension();
159  RefSCDimension(const RefSCDimension& d);
162 
163  ~RefSCDimension();
166 
167  RefSCDimension& operator<<(RefCount*);
171 
172  // dimension specific functions
173  public:
175  operator int() const;
176  int n() const;
177 
178  void print(std::ostream&o=ExEnv::out0()) const;
179 };
180 
181 }
182 
183 #endif
184 
185 // Local Variables:
186 // mode: c++
187 // c-file-style: "CLJ"
188 // End:
sc::SCDimension::equiv
int equiv(const SCDimension *) const
Test to see if two dimensions are equivalent.
sc::RefSCDimension::RefSCDimension
RefSCDimension()
Initializes the dimension pointer to 0.
sc::SCDimension
The SCDimension class is used to determine the size and blocking of matrices.
Definition: dim.h:105
sc::SCDimension::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::SCBlockInfo::nblock
int nblock() const
Return the number of blocks.
Definition: dim.h:80
sc::SCBlockInfo::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCBlockInfo::SCBlockInfo
SCBlockInfo(int n, int nblocks=0, const int *blocksizes=0)
Create a SCBlockInfo object.
sc::SCDimension::blocks
const Ref< SCBlockInfo > & blocks() const
Return the blocking information for this dimension.
Definition: dim.h:144
sc::SCBlockInfo::fence
int fence(int i) const
Return the last index + 1 for block i.
Definition: dim.h:86
sc::RefBase
Provides a few utility routines common to all Ref template instantiations.
Definition: ref.h:321
sc::StateIn
Definition: statein.h:79
sc::RefSCDimension
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition: dim.h:152
sc::SCBlockInfo::start
int start(int i) const
Return the starting index for block i.
Definition: dim.h:82
sc::SCBlockInfo::nelem
int nelem() const
Return the total number of elements.
Definition: dim.h:78
sc::operator<<
std::vector< unsigned int > operator<<(const GaussianBasisSet &B, const GaussianBasisSet &A)
computes a map from basis functions in A to the equivalent basis functions in B.
sc::RefSCDimension::operator=
RefSCDimension & operator=(SCDimension *d)
Make this refer to d.
sc::SCDimension::print
void print(std::ostream &o=ExEnv::out0()) const
Print information about this dimension to o.
sc::SCDimension::name
const char * name() const
Return the name of the dimension.
Definition: dim.h:141
sc::StateOut
Definition: stateout.h:71
sc::SCBlockInfo
SCBlockInfo contains blocking information for the SCDimension class.
Definition: dim.h:46
sc::SCDimension::n
int n() const
Return the dimension.
Definition: dim.h:138
sc::SCBlockInfo::equiv
int equiv(SCBlockInfo *bi)
Return nonzero if this is equivalent to bi.
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:45
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc::SCBlockInfo::set_subdim
void set_subdim(int i, const RefSCDimension &dim)
Set subdimension information.
sc::SCBlockInfo::print
void print(std::ostream &o=ExEnv::out0()) const
Print the object to the stream o.
sc::SCBlockInfo::subdim
RefSCDimension subdim(int i)
Retreive subdimension information.
sc::SCBlockInfo::size
int size(int i) const
Return the size of block i.
Definition: dim.h:84
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.