Changeset 890 in Sophya for trunk/SophyaLib/TArray
- Timestamp:
- Apr 11, 2000, 7:59:04 PM (25 years ago)
- Location:
- trunk/SophyaLib/TArray
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/basarr.cc
r850 r890 8 8 #include "basarr.h" 9 9 10 11 12 10 // Variables statiques globales 13 11 char * BaseArray::ck_op_msg_[6] = {"???", "Size(int )", "IsPacked(int )", 14 12 "Stride(int )", "ElemCheckBound()", "operator()" }; 15 13 uint_4 BaseArray::max_nprt_ = 50; 16 14 uint_4 BaseArray::prt_lev_ = 0; … … 22 20 23 21 // 1/ Gestion des impressions 22 //! Set maximum number of printed elements and print level 23 /*! 24 \param nprt : maximum number of print 25 \param lev : print level 26 */ 24 27 void BaseArray::SetMaxPrint(uint_4 nprt, uint_4 lev) 25 28 { … … 28 31 } 29 32 33 //! Set Size threshold for parallel routine call 34 /*! 35 \param thr : thresold value 36 */ 30 37 void BaseArray::SetOpenMPSizeThreshold(uint_8 thr) 31 38 { … … 150 157 // ------------------------------------------------------- 151 158 152 // Les constructeurs159 //! Default constructor 153 160 BaseArray::BaseArray() 154 161 : mInfo(NULL) 155 // Default constructor156 162 { 157 163 ndim_ = 0; … … 172 178 } 173 179 174 // Destructeur180 //! Destructor 175 181 BaseArray::~BaseArray() 176 182 { … … 178 184 179 185 186 //! Returns true if \b ndim and \b sizes are equal 187 /*! 188 \param a : array to be compared 189 \return true if ndim and sizes are equal, false if not 190 */ 180 191 bool BaseArray::CompareSizes(const BaseArray& a) 181 192 { -
trunk/SophyaLib/TArray/basarr.h
r813 r890 13 13 14 14 15 // Maximum number of dimensions forarray15 //! Maximum number of dimensions for an array 16 16 #define BASEARRAY_MAXNDIMS 5 17 17 … … 19 19 20 20 // ------------ classe template Array ----------- 21 //! Base class for template arrays 22 /*! 23 Define base methods, enum and defaults for TArray , TMatrix and TVector 24 */ 21 25 class BaseArray : public AnyDataObj { 22 26 public: 23 // To define Array / Matrix memory mapping 24 enum MemoryMapping { AutoMemoryMapping = -1, SameMemoryMapping = 0, 25 CMemoryMapping = 1, FortranMemoryMapping = 2 }; 26 // Vector type 27 enum VectorType {AutoVectorType = -1, SameVectorType = 0, 28 ColumnVector = 1, RowVector = 2}; 29 30 // Size threshold for parallel routine call 27 //! To define Array or Matrix memory mapping 28 enum MemoryMapping { 29 AutoMemoryMapping = -1, //!< define Auto Memory Mapping 30 SameMemoryMapping = 0, //!< define Same Memory Mapping 31 CMemoryMapping = 1, //!< define C Memory Mapping 32 FortranMemoryMapping = 2 //!< define Fortran Memory Mapping 33 }; 34 //! To define Vector type 35 enum VectorType { 36 AutoVectorType = -1, //!< define Auto Vector Type 37 SameVectorType = 0, //!< define Same Vector Type 38 ColumnVector = 1, //!< define Column Vector Type 39 RowVector = 2 //!< define Row Vector Type 40 }; 41 42 // threshold for parallel routine call 31 43 static void SetOpenMPSizeThreshold(uint_8 thr=200000); 44 //! Get Size threshold for parallel routine call 32 45 static inline uint_8 GetOpenMPSizeThreshold() { return openmp_size_threshold; } 33 // Max Nb of printed elements and print level 46 34 47 static void SetMaxPrint(uint_4 nprt=50, uint_4 lev=0); 48 //! Get maximum number of printed elements 35 49 static inline uint_4 GetMaxPrint() { return max_nprt_; } 50 //! Maximum number of printed elements arint level 36 51 static inline uint_4 GetPrintLevel() { return prt_lev_; } 37 52 38 // Memory organisation (for matrices) and vector type53 //! Set Default Memory Mapping 39 54 static short SetDefaultMemoryMapping(short mm=CMemoryMapping); 55 //! Get Default Memory Mapping 40 56 static inline short GetDefaultMemoryMapping() { return default_memory_mapping; } 57 //! Set Default Vector Type 41 58 static short SetDefaultVectorType(short vt=ColumnVector); 59 //! Get Default Vector Type 42 60 static inline short GetDefaultVectorType() { return default_vector_type; } 43 61 44 // Creat ion / destruction62 // Creator / destructor 45 63 BaseArray(); 46 64 virtual ~BaseArray(); … … 49 67 virtual bool CompareSizes(const BaseArray& a); 50 68 51 // Compacts size=1 array dimensions52 virtual void CompactAllDim(); 53 virtual void CompactTrailingDim(); 69 // Compacts \b size=1 array dimensions 70 virtual void CompactAllDim(); // suppresses all size==1 dimensions 71 virtual void CompactTrailingDim(); // suppresses size==1 dimensions after the last size>1 dimension 54 72 55 73 // Array dimensions 74 //! Return number of dimensions 56 75 inline uint_4 NbDimensions() const { return( ndim_ ); } 57 76 77 //! Return total size of the array 58 78 inline uint_8 Size() const { return(totsize_); } 79 //! Return size along the first dimension 59 80 inline uint_4 SizeX() const { return(size_[0]); } 81 //! Return size along the second dimension 60 82 inline uint_4 SizeY() const { return(size_[1]); } 83 //! Return size along the third dimension 61 84 inline uint_4 SizeZ() const { return(size_[2]); } 85 //! Return size along the \b ka th dimension 62 86 inline uint_4 Size(int ka) const { return(size_[CheckDI(ka,1)]); } 63 87 64 88 uint_4 MaxSizeKA() const ; 65 89 66 // memory organisation 67 inline short GetMemoryMapping() const 68 { return ( (marowi_ == 1) ? CMemoryMapping : FortranMemoryMapping) ; } 69 70 inline uint_4 RowsKA() const {return marowi_; } // Dimension des index de lignes 71 inline uint_4 ColsKA() const {return macoli_; } // Dimension des index de colonnes 72 inline uint_4 VectKA() const {return veceli_; } // Dimension des index des elts d'un vecteur 90 //! Get memory organization 91 inline short GetMemoryMapping() const 92 { return ( (marowi_ == 1) ? CMemoryMapping : FortranMemoryMapping) ; } 93 //! line index dimension 94 inline uint_4 RowsKA() const {return marowi_; } 95 //! line column dimension 96 inline uint_4 ColsKA() const {return macoli_; } 97 //! Index dimension of the elements of a vector 98 inline uint_4 VectKA() const {return veceli_; } 73 99 void SetMemoryMapping(short mm=AutoMemoryMapping); 74 100 75 // Vector type Line or Column vector101 //! Get Vector type ( \b Line or \b Column vector ) 76 102 inline short GetVectorType() const 77 103 { return((marowi_ == veceli_) ? ColumnVector : RowVector); } 78 void SetVectorType(short vt=AutoVectorType); 79 80 // memory organisation - packing information 104 void SetVectorType(short vt=AutoVectorType); 105 106 // memory organisation - packing information 107 //! return true if array is packed in memory 81 108 inline bool IsPacked() const { return(moystep_ == 1); } 109 //! return true if array is packed along the first dimension 82 110 inline bool IsPackedX() const { return(step_[0] == 1); } 111 //! return true if array is packed along the second dimension 83 112 inline bool IsPackedY() const { return(step_[1] == 1); } 113 //! return true if array is packed along the third dimension 84 114 inline bool IsPackedZ() const { return(step_[2] == 1); } 115 //! return true if array is packed along the \b ka th dimension 85 116 inline bool IsPacked(int ka) const { return(step_[CheckDI(ka,2)] == 1); } 86 117 118 //! return the minimum step value along all the dimensions 87 119 inline uint_4 MinStep() const { return(minstep_); } 120 //! return the average step value along all the dimensions 88 121 inline uint_4 AvgStep() const { return(moystep_); } 122 //! return the step along the first dimension 89 123 inline uint_4 StepX() const { return(step_[0]); } 124 //! return the step along the second dimension 90 125 inline uint_4 StepY() const { return(step_[1]); } 126 //! return the step along the third dimension 91 127 inline uint_4 StepZ() const { return(step_[2]); } 128 //! return the step along the \b ka th dimension 92 129 inline uint_4 Step(int ka) const { return(step_[CheckDI(ka,3)]); } 93 130 … … 100 137 inline uint_8 Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const; 101 138 102 // aabstract element acces methode139 // an abstract element acces methode 103 140 virtual double ValueAtPosition(uint_8 ip) const = 0; 104 141 105 // Impression, I/O, ...142 // Impression, I/O, ... 106 143 void Show(ostream& os, bool si=false) const; 144 //! Show information on \b cout 107 145 inline void Show() const { Show(cout); } 108 146 virtual string InfoString() const; 109 147 110 // Objet DVList info148 // Objet DVList info 111 149 DVList& Info(); 112 150 113 151 protected: 114 // Verifie la compatibilite de l'index de dimension115 152 inline int CheckDI(int ka, int msg) const ; 116 // Verifie la compatibilite des bornes d'index117 153 inline void CheckBound(int ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu, int msg) const ; 118 154 // Changing Sizes/NDim ... return true if OK … … 130 166 virtual void UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const; 131 167 132 uint_4 ndim_; // nb of dimensions 133 uint_4 size_[BASEARRAY_MAXNDIMS]; // array size in each dimension 134 uint_8 totsize_; // Total number of elements 135 uint_4 step_[BASEARRAY_MAXNDIMS]; // two consecutive elements distance in a given dimension 136 uint_4 minstep_; // minimal step (in any axes) 137 uint_4 moystep_; // mean step if == 0 --> non regular steps 138 uint_8 offset_; // global offset -> position of elem[0] in DataBlock 139 uint_4 marowi_, macoli_; // For matrices, Row index and column index in dimensions 140 uint_4 veceli_; // For vectors, dimension index = marowi_/macoli_ (Row/Col vectors) 141 bool ck_memo_vt_; // if true, check MemoryOrg./VectorType for CompareSize 142 DVList* mInfo; // Infos (variables) attachees au tableau 143 144 static char * ck_op_msg_[6]; // Operation messages for CheckDI() CheckBound() 145 static uint_4 max_nprt_; // Nb maxi d'elements imprimes 146 static uint_4 prt_lev_; // Niveau de print 0 ou 1 147 static short default_memory_mapping; // Default memory mapping 148 static short default_vector_type; // Default vector type Row/Column 149 static uint_8 openmp_size_threshold; // Size limit for parallel routine calls 168 uint_4 ndim_; //! number of dimensions of array 169 uint_4 size_[BASEARRAY_MAXNDIMS]; //! array of the size in each dimension 170 uint_8 totsize_; //! Total number of elements 171 //! two consecutive elements distance in a given dimension 172 uint_4 step_[BASEARRAY_MAXNDIMS]; 173 uint_4 minstep_; //! minimal step (in any axes) 174 uint_4 moystep_; //! mean step, if == 0 --\> non regular steps 175 uint_8 offset_; //! global offset -\> position of elem[0] in DataBlock 176 uint_4 marowi_; //! For matrices, Row index in dimensions 177 uint_4 macoli_; //! For matrices, Column index in dimensions 178 uint_4 veceli_; //! For vectors, dimension index = marowi_/macoli_ (Row/Col vectors) 179 bool ck_memo_vt_; //! if true, check MemoryOrg./VectorType for CompareSize 180 DVList* mInfo; //! Infos (variables) attached to the array 181 182 static char * ck_op_msg_[6]; //! Operation messages for CheckDI() CheckBound() 183 static uint_4 max_nprt_; //! Nb maximum number of printed elements 184 static uint_4 prt_lev_; //! Print level 185 static short default_memory_mapping; //! Default memory mapping 186 static short default_vector_type; //! Default vector type Row/Column 187 static uint_8 openmp_size_threshold; //! Size limit for parallel routine calls 150 188 }; 151 189 … … 153 191 // Methodes inline de verification 154 192 // -------------------------------------------------- 193 //! to verify the compatibility of the dimension index 155 194 inline int BaseArray::CheckDI(int ka, int msg) const 156 195 { … … 162 201 } 163 202 203 //! to verify the compatibility of the indexes in all dimensions 164 204 inline void BaseArray::CheckBound(int ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu, int msg) const 165 205 { … … 177 217 // Position d'un element 178 218 // -------------------------------------------------- 219 //! Offset of element (ix,iy,iz,it,iu) 179 220 inline uint_8 BaseArray::Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const 180 221 {
Note:
See TracChangeset
for help on using the changeset viewer.