Changeset 2888 in Sophya


Ignore:
Timestamp:
Jan 4, 2006, 7:25:32 PM (20 years ago)
Author:
ansari
Message:

Ajout de la methode BaseArray::ValueAtPositionDB() pour corriger un gros bug au niveau de la conversion de type (r_4 r_8 ...) des tableaux - Reza 4 Jan 2006

Location:
trunk/SophyaLib/TArray
Files:
3 edited

Legend:

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

    r2583 r2888  
    146146  // an abstract element acces methode
    147147  virtual MuTyV & ValueAtPosition(sa_size_t ip) const = 0;
     148  virtual MuTyV & ValueAtPositionDB(sa_size_t ip) const = 0;
    148149
    149150  // Pour recuperer pas et numero d'axe pour operations sur deux arrays
  • trunk/SophyaLib/TArray/tarray.cc

    r2884 r2888  
    360360}
    361361
    362 //! Give value (in \b double) for element at position \b ip..
     362/*!
     363  \brief Return the value (as a MuTyV) for element at position \b ip in the array.
     364  This method is used for conversion between arrays of different types.
     365  \param ip : element position in the array
     366 */
    363367template <class T>
    364368MuTyV & TArray<T>::ValueAtPosition(sa_size_t ip) const
    365369{
    366370#ifdef SO_BOUNDCHECKING
    367   if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(sa_size_t ip) Out-of-bound Error") );
     371  if ( (ip >= totsize_) || (ip < 0) )   
     372    throw( ParmError("TArray<T>::ValueAtPosition(sa_size_t ip) Out-of-bound Error") );
    368373#endif
    369374  my_mtv = *(mNDBlock.Begin()+Offset(ip));
     375  return( my_mtv );
     376}
     377
     378/*!
     379  \brief Return the value (as a MuTyV) for element at position \b ip in the datablock.
     380  This method is used for conversion between arrays of different types.
     381  \param ip : element position in the array DataBlock, regardless of
     382   the array memory organisation
     383 */
     384template <class T>
     385MuTyV & TArray<T>::ValueAtPositionDB(sa_size_t ip) const
     386{
     387#ifdef SO_BOUNDCHECKING
     388  if ( (ip >= mNDBlock.Size() ) || (ip < 0) )   
     389    throw( ParmError("TArray<T>::ValueAtPositionDB(sa_size_t ip) Out-of-bound Error") );
     390#endif
     391  my_mtv = *(mNDBlock.Begin()+ip);
    370392  return( my_mtv );
    371393}
     
    11131135   --- Appel explicite de l'operateur de conversion sur l'objet MuTyV
    11141136*/
    1115     for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa) 
    1116       a.ValueAtPosition(offa+ka).Convert(pe[k]);
     1137    /*  ----- Janvier 2006 ------
     1138      Un bug important etait semble-t-il present depuis longtemps
     1139      On appelait a.ValueAtPosition(ip) qui renvoie l'element ip en tenant compte
     1140      de la structure du tableau , alors qu'on veut acceder l'element ip du datablock
     1141      Methode ValueAtPositionDB(ip) ajoute et utilisee a la place de  ValueAtPosition(ip)
     1142     */
     1143    for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)
     1144      a.ValueAtPositionDB(offa+ka).Convert(pe[k]);
    11171145      //REMPLACE Suite pb compil gcc4   pe[k] = a.ValueAtPosition(offa+ka).operator T();
    11181146  }
  • trunk/SophyaLib/TArray/tarray.h

    r2589 r2888  
    8989  // Definition of virtual element acces method inherited from BaseArray class
    9090  virtual MuTyV & ValueAtPosition(sa_size_t ip) const;
     91  virtual MuTyV & ValueAtPositionDB(sa_size_t ip) const;
    9192
    9293  // Data Access: operator overloaded inline acces methods
Note: See TracChangeset for help on using the changeset viewer.