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 class RefSCDimension;
00048 class SCBlockInfo: public SavableState {
00049   protected:
00050     int n_;
00051     int nblocks_;
00052     int *start_;
00053     int *size_;
00054     RefSCDimension *subdims_;
00055     void init_start();
00056   public:
00058     SCBlockInfo(int n, int nblocks = 0, const int *blocksizes = 0);
00059     SCBlockInfo(StateIn&);
00072     SCBlockInfo(const Ref<KeyVal>& keyval);
00073 
00074     ~SCBlockInfo();
00075     void save_data_state(StateOut&);
00076 
00078     int equiv(SCBlockInfo *bi);
00080     int nelem() const { return n_; }
00082     int nblock() const { return nblocks_; }
00084     int start(int i) const { return start_[i]; }
00086     int size(int i) const { return size_[i]; }
00088     int fence(int i) const { return start_[i] + size_[i]; }
00089 
00090     void elem_to_block(int i, int &block, int &offset);
00091 
00093     RefSCDimension subdim(int i);
00097     void set_subdim(int i, const RefSCDimension &dim);
00098 
00100     void print(std::ostream&o=ExEnv::out()) const;
00101 };
00102 
00103 
00107 class SCDimension: public SavableState {
00108   protected:
00109     char *name_;
00110     int n_;
00111     Ref<SCBlockInfo> blocks_;
00112     SCDimension(const char* name = 0);
00113   public:
00116     SCDimension(int n, const char* name = 0);
00117     SCDimension(const Ref<SCBlockInfo>&, const char *name = 0);
00118     SCDimension(int n, int nblocks, const int *blocksizes = 0,
00119                 const char* name = 0);
00130     SCDimension(const Ref<KeyVal>&);
00131     SCDimension(StateIn&s);
00132 
00133     ~SCDimension();
00134     void save_data_state(StateOut&);
00135 
00137     int equiv(const SCDimension*) const;
00138     
00140     int n() const { return n_; }
00143     const char* name() const { return name_; }
00144 
00146     Ref<SCBlockInfo> blocks() { return blocks_; }
00147 
00149     void print(std::ostream&o=ExEnv::out()) const;
00150 };
00151 
00154 class RefSCDimension: public Ref<SCDimension> {
00155     // standard overrides
00156   public:
00159     RefSCDimension();
00161     RefSCDimension(const RefSCDimension& d);
00163     RefSCDimension(SCDimension *d);
00164 
00165     ~RefSCDimension();
00167     RefSCDimension& operator=(SCDimension* d);
00168 
00169     RefSCDimension& operator<<(RefCount*);
00170     RefSCDimension& operator<<(const RefBase &);
00172     RefSCDimension& operator=(const RefSCDimension & d);
00173 
00174     // dimension specific functions
00175   public:
00177     operator int() const;
00178     int n() const;
00179 
00180     void print(std::ostream&o=ExEnv::out()) const;
00181 };
00182 
00183 #endif
00184 
00185 // Local Variables:
00186 // mode: c++
00187 // c-file-style: "CLJ"
00188 // End:

Generated at Thu Oct 4 18:08:43 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.