Changeset 890 in Sophya


Ignore:
Timestamp:
Apr 11, 2000, 7:59:04 PM (25 years ago)
Author:
ansari
Message:

debut de doc pour verif par rz (cmv 11/4/00

Location:
trunk/SophyaLib/TArray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/basarr.cc

    r850 r890  
    88#include "basarr.h"
    99
    10 
    11 
    1210// Variables statiques globales
    1311char * BaseArray::ck_op_msg_[6] = {"???", "Size(int )", "IsPacked(int )",
    14                                 "Stride(int )", "ElemCheckBound()", "operator()" };
     12                      "Stride(int )", "ElemCheckBound()", "operator()" };
    1513uint_4 BaseArray::max_nprt_ = 50;
    1614uint_4 BaseArray::prt_lev_ = 0;
     
    2220
    2321//  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*/
    2427void BaseArray::SetMaxPrint(uint_4 nprt, uint_4 lev)
    2528{
     
    2831}
    2932
     33//! Set Size threshold for parallel routine call
     34/*!
     35  \param thr : thresold value
     36*/
    3037void BaseArray::SetOpenMPSizeThreshold(uint_8 thr)
    3138{
     
    150157// -------------------------------------------------------
    151158
    152 // Les constructeurs
     159//! Default constructor
    153160BaseArray::BaseArray()
    154161  : mInfo(NULL)
    155 // Default constructor
    156162{
    157163  ndim_ = 0;
     
    172178}
    173179
    174 // Destructeur
     180//! Destructor
    175181BaseArray::~BaseArray()
    176182{
     
    178184
    179185
     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*/
    180191bool BaseArray::CompareSizes(const BaseArray& a)
    181192{
  • trunk/SophyaLib/TArray/basarr.h

    r813 r890  
    1313
    1414
    15 //  Maximum number of dimensions for array
     15//! Maximum number of dimensions for an array
    1616#define BASEARRAY_MAXNDIMS  5
    1717
     
    1919
    2020//   ------------ classe template Array -----------
     21//! Base class for template arrays
     22/*!
     23  Define base methods, enum and defaults for TArray , TMatrix and TVector
     24*/
    2125class BaseArray : public AnyDataObj {
    2226public:
    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
    3143  static void    SetOpenMPSizeThreshold(uint_8 thr=200000);
     44  //! Get Size threshold for parallel routine call
    3245  static inline uint_8 GetOpenMPSizeThreshold() { return openmp_size_threshold; }
    33   //    Max Nb of printed elements and print level
     46
    3447  static void    SetMaxPrint(uint_4 nprt=50, uint_4 lev=0);   
     48  //! Get maximum number of printed elements
    3549  static inline uint_4 GetMaxPrint() { return max_nprt_; }
     50  //! Maximum number of printed elements arint level
    3651  static inline uint_4 GetPrintLevel() { return prt_lev_; }
    3752
    38   //   Memory organisation (for matrices) and vector type
     53  //! Set Default Memory Mapping
    3954  static short   SetDefaultMemoryMapping(short mm=CMemoryMapping);
     55  //! Get Default Memory Mapping
    4056  static inline short GetDefaultMemoryMapping() { return default_memory_mapping; }
     57  //! Set Default Vector Type
    4158  static short   SetDefaultVectorType(short vt=ColumnVector);
     59  //! Get Default Vector Type
    4260  static inline short GetDefaultVectorType() { return default_vector_type; }
    4361 
    44   // Creation / destruction
     62  // Creator / destructor
    4563  BaseArray();
    4664  virtual ~BaseArray();
     
    4967  virtual bool CompareSizes(const BaseArray& a);
    5068
    51   // Compacts size=1 array dimensions
    52   virtual void CompactAllDim();         // suppresses all size==1 dimensions
    53   virtual void CompactTrailingDim();    // suppresses size==1 dimensions after the last size>1 dimension
     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
    5472
    5573  // Array dimensions
     74  //! Return number of dimensions
    5675  inline uint_4 NbDimensions() const { return( ndim_ ); }
    5776
     77  //! Return total size of the array
    5878  inline uint_8 Size() const { return(totsize_); }
     79  //! Return size along the first dimension
    5980  inline uint_4 SizeX() const { return(size_[0]); }
     81  //! Return size along the second dimension
    6082  inline uint_4 SizeY() const { return(size_[1]); }
     83  //! Return size along the third dimension
    6184  inline uint_4 SizeZ() const { return(size_[2]); }
     85  //! Return size along the \b ka th dimension
    6286  inline uint_4 Size(int ka) const { return(size_[CheckDI(ka,1)]); }
    6387
    6488  uint_4 MaxSizeKA() const ;
    6589
    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_; }
    7399  void          SetMemoryMapping(short mm=AutoMemoryMapping);
    74100
    75   // Vector type   Line or Column vector
     101  //! Get Vector type ( \b Line or \b Column vector )
    76102  inline short  GetVectorType() const
    77103                { 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
    81108  inline bool   IsPacked() const { return(moystep_ == 1); }
     109  //! return true if array is packed along the first dimension
    82110  inline bool   IsPackedX() const { return(step_[0] == 1); }
     111  //! return true if array is packed along the second dimension
    83112  inline bool   IsPackedY() const { return(step_[1] == 1); }
     113  //! return true if array is packed along the third dimension
    84114  inline bool   IsPackedZ() const { return(step_[2] == 1); }
     115  //! return true if array is packed along the \b ka th dimension
    85116  inline bool   IsPacked(int ka) const { return(step_[CheckDI(ka,2)] == 1); }
    86117
     118  //! return the minimum step value along all the dimensions
    87119  inline uint_4 MinStep() const  { return(minstep_); }
     120  //! return the average step value along all the dimensions
    88121  inline uint_4 AvgStep() const  { return(moystep_); }
     122  //! return the step along the first dimension
    89123  inline uint_4 StepX() const { return(step_[0]); }
     124  //! return the step along the second dimension
    90125  inline uint_4 StepY() const { return(step_[1]); }
     126  //! return the step along the third dimension
    91127  inline uint_4 StepZ() const { return(step_[2]); }
     128  //! return the step along the \b ka th dimension
    92129  inline uint_4 Step(int ka) const { return(step_[CheckDI(ka,3)]); }
    93130
     
    100137  inline uint_8  Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const; 
    101138
    102 //  a abstract element acces methode
     139  // an abstract element acces methode
    103140  virtual double ValueAtPosition(uint_8 ip) const = 0;
    104141
    105 // Impression, I/O, ...
     142 // Impression, I/O, ...
    106143  void           Show(ostream& os, bool si=false) const;
     144  //! Show information on \b cout
    107145  inline void    Show() const { Show(cout); }
    108146  virtual string InfoString() const;
    109147
    110 //  Objet DVList info
     148  //  Objet DVList info
    111149  DVList&       Info();
    112150
    113151protected:
    114   // Verifie la compatibilite de l'index de dimension
    115152  inline int CheckDI(int ka, int msg) const ;
    116   // Verifie la compatibilite des bornes d'index
    117153  inline void CheckBound(int ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu, int msg) const ;
    118154  // Changing Sizes/NDim ... return true if OK
     
    130166  virtual void UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const;
    131167
    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
    150188};
    151189
     
    153191//        Methodes inline de verification
    154192// --------------------------------------------------
     193//! to verify the compatibility of the dimension index
    155194inline int BaseArray::CheckDI(int ka, int msg)  const
    156195{
     
    162201}
    163202
     203//! to verify the compatibility of the indexes in all dimensions
    164204inline void BaseArray::CheckBound(int ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu, int msg)  const
    165205{
     
    177217//        Position d'un element
    178218// --------------------------------------------------
     219//! Offset of element (ix,iy,iz,it,iu)
    179220inline uint_8 BaseArray::Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
    180221{
Note: See TracChangeset for help on using the changeset viewer.