MPQC 2.3.1
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#ifdef __GNUC__
29#pragma interface
30#endif
31
32#ifndef _math_scmat_dim_h
33#define _math_scmat_dim_h
34
35#include <util/keyval/keyval.h>
36#include <util/state/state.h>
37
38namespace sc {
39
40class RefSCDimension;
51 protected:
52 int n_;
53 int nblocks_;
54 int *start_;
55 int *size_;
56 RefSCDimension *subdims_;
57 void init_start();
58 public:
60 SCBlockInfo(int n, int nblocks = 0, const int *blocksizes = 0);
74 SCBlockInfo(const Ref<KeyVal>& keyval);
75
78
82 int nelem() const { return n_; }
84 int nblock() const { return nblocks_; }
86 int start(int i) const { return start_[i]; }
88 int size(int i) const { return size_[i]; }
90 int fence(int i) const { return start_[i] + size_[i]; }
91
92 void elem_to_block(int i, int &block, int &offset);
93
99 void set_subdim(int i, const RefSCDimension &dim);
100
102 void print(std::ostream&o=ExEnv::out0()) const;
103};
104
105
110 protected:
111 char *name_;
112 int n_;
113 Ref<SCBlockInfo> blocks_;
114 SCDimension(const char* name = 0);
115 public:
118 SCDimension(int n, const char* name = 0);
119 SCDimension(const Ref<SCBlockInfo>&, const char *name = 0);
120 SCDimension(int n, int nblocks, const int *blocksizes = 0,
121 const char* name = 0);
134
135 ~SCDimension();
137
139 int equiv(const SCDimension*) const;
140
142 int n() const { return n_; }
145 const char* name() const { return name_; }
146
148 Ref<SCBlockInfo> blocks() { return blocks_; }
149
151 void print(std::ostream&o=ExEnv::out0()) const;
152};
153
156class RefSCDimension: public Ref<SCDimension> {
157 // standard overrides
158 public:
166
170
171 RefSCDimension& operator<<(RefCount*);
172 RefSCDimension& operator<<(const RefBase &);
175
176 // dimension specific functions
177 public:
179 operator int() const;
180 int n() const;
181
182 void print(std::ostream&o=ExEnv::out0()) const;
183};
184
185}
186
187#endif
188
189// Local Variables:
190// mode: c++
191// c-file-style: "CLJ"
192// End:
static std::ostream & out0()
Return an ostream that writes from node 0.
Provides a few utility routines common to all Ref template instantiations.
Definition ref.h:292
The base class for all reference counted objects.
Definition ref.h:194
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition dim.h:156
RefSCDimension()
Initializes the dimension pointer to 0.
RefSCDimension(SCDimension *d)
Make this refer to d.
RefSCDimension & operator=(SCDimension *d)
Make this refer to d.
RefSCDimension(const RefSCDimension &d)
Make this and d refer to the same SCDimension.
RefSCDimension & operator=(const RefSCDimension &d)
Make this and d refer to the same SCDimension.
A template class that maintains references counts.
Definition ref.h:332
SCBlockInfo contains blocking information for the SCDimension class.
Definition dim.h:50
int start(int i) const
Return the starting index for block i.
Definition dim.h:86
SCBlockInfo(const Ref< KeyVal > &keyval)
The KeyVal constructor.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void print(std::ostream &o=ExEnv::out0()) const
Print the object to the stream o.
int fence(int i) const
Return the last index + 1 for block i.
Definition dim.h:90
SCBlockInfo(int n, int nblocks=0, const int *blocksizes=0)
Create a SCBlockInfo object.
int size(int i) const
Return the size of block i.
Definition dim.h:88
int nelem() const
Return the total number of elements.
Definition dim.h:82
int nblock() const
Return the number of blocks.
Definition dim.h:84
int equiv(SCBlockInfo *bi)
Return nonzero if this is equivalent to bi.
RefSCDimension subdim(int i)
Retreive subdimension information.
void set_subdim(int i, const RefSCDimension &dim)
Set subdimension information.
The SCDimension class is used to determine the size and blocking of matrices.
Definition dim.h:109
int equiv(const SCDimension *) const
Test to see if two dimensions are equivalent.
int n() const
Return the dimension.
Definition dim.h:142
const char * name() const
Return the name of the dimension.
Definition dim.h:145
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Ref< SCBlockInfo > blocks()
Return the blocking information for this dimension.
Definition dim.h:148
SCDimension(const Ref< KeyVal > &)
The KeyVal constructor.
SCDimension(int n, const char *name=0)
Create a dimension with an optional name.
void print(std::ostream &o=ExEnv::out0()) const
Print information about this dimension to o.
Base class for objects that can save/restore state.
Definition state.h:46
Restores objects that derive from SavableState.
Definition statein.h:70
Serializes objects that derive from SavableState.
Definition stateout.h:61

Generated at Fri May 31 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.11.0.