Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

dim.h

00001 //
00002 // dim.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031 
00032 #ifndef _math_scmat_dim_h
00033 #define _math_scmat_dim_h
00034 
00035 #include <util/keyval/keyval.h>
00036 #include <util/state/state.h>
00037 
00038 namespace sc {
00039 
00040 class RefSCDimension;
00050 class SCBlockInfo: public SavableState {
00051   protected:
00052     int n_;
00053     int nblocks_;
00054     int *start_;
00055     int *size_;
00056     RefSCDimension *subdims_;
00057     void init_start();
00058   public:
00060     SCBlockInfo(int n, int nblocks = 0, const int *blocksizes = 0);
00061     SCBlockInfo(StateIn&);
00074     SCBlockInfo(const Ref<KeyVal>& keyval);
00075 
00076     ~SCBlockInfo();
00077     void save_data_state(StateOut&);
00078 
00080     int equiv(SCBlockInfo *bi);
00082     int nelem() const { return n_; }
00084     int nblock() const { return nblocks_; }
00086     int start(int i) const { return start_[i]; }
00088     int size(int i) const { return size_[i]; }
00090     int fence(int i) const { return start_[i] + size_[i]; }
00091 
00092     void elem_to_block(int i, int &block, int &offset);
00093 
00095     RefSCDimension subdim(int i);
00099     void set_subdim(int i, const RefSCDimension &dim);
00100 
00102     void print(std::ostream&o=ExEnv::out0()) const;
00103 };
00104 
00105 
00109 class SCDimension: public SavableState {
00110   protected:
00111     char *name_;
00112     int n_;
00113     Ref<SCBlockInfo> blocks_;
00114     SCDimension(const char* name = 0);
00115   public:
00118     SCDimension(int n, const char* name = 0);
00119     SCDimension(const Ref<SCBlockInfo>&, const char *name = 0);
00120     SCDimension(int n, int nblocks, const int *blocksizes = 0,
00121                 const char* name = 0);
00132     SCDimension(const Ref<KeyVal>&);
00133     SCDimension(StateIn&s);
00134 
00135     ~SCDimension();
00136     void save_data_state(StateOut&);
00137 
00139     int equiv(const SCDimension*) const;
00140     
00142     int n() const { return n_; }
00145     const char* name() const { return name_; }
00146 
00148     Ref<SCBlockInfo> blocks() { return blocks_; }
00149 
00151     void print(std::ostream&o=ExEnv::out0()) const;
00152 };
00153 
00156 class RefSCDimension: public Ref<SCDimension> {
00157     // standard overrides
00158   public:
00161     RefSCDimension();
00163     RefSCDimension(const RefSCDimension& d);
00165     RefSCDimension(SCDimension *d);
00166 
00167     ~RefSCDimension();
00169     RefSCDimension& operator=(SCDimension* d);
00170 
00171     RefSCDimension& operator<<(RefCount*);
00172     RefSCDimension& operator<<(const RefBase &);
00174     RefSCDimension& operator=(const RefSCDimension & d);
00175 
00176     // dimension specific functions
00177   public:
00179     operator int() const;
00180     int n() const;
00181 
00182     void print(std::ostream&o=ExEnv::out0()) const;
00183 };
00184 
00185 }
00186 
00187 #endif
00188 
00189 // Local Variables:
00190 // mode: c++
00191 // c-file-style: "CLJ"
00192 // End:

Generated at Fri Jan 10 08:14:08 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.