Ignore:
Timestamp:
Feb 23, 2001, 12:26:48 PM (25 years ago)
Author:
lemeur
Message:

surcharge d'operateurs =, +=, *= etc...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r1304 r1419  
    127127}
    128128
     129//! Clone if \b a is not temporary, share if temporary
     130/*! \sa NDataBlock::CloneOrShare(const NDataBlock<T>&) */
    129131template<class T>
    130132void SphereHEALPix<T>::CloneOrShare(const SphereHEALPix<T>& a)
     
    136138  sliceBeginIndex_.CloneOrShare(a.sliceBeginIndex_);
    137139  sliceLenght_.CloneOrShare(a.sliceLenght_);
    138 
    139   // pas forcement a conserver, pas forcement a cet endroit (GLM)
    140   //  if (a.IsTemp() ) SetTemp(true);
     140  if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
     141  if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
     142}
     143
     144//! Share data with a
     145template<class T>
     146void SphereHEALPix<T>::Share(const SphereHEALPix<T>& a)
     147{
     148  nSide_= a.nSide_;
     149  nPix_ = a.nPix_;
     150  omeg_ = a.omeg_;
     151  pixels_.Share(a.pixels_);
     152  sliceBeginIndex_.Share(a.sliceBeginIndex_);
     153  sliceLenght_.Share(a.sliceLenght_);
     154  if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
     155  if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
    141156}
    142157
     
    149164     
    150165      if (a.NbPixels() < 1)
    151         throw RangeCheckError("SphereHEALPix<T>::Set(a ) - Array a not allocated ! ");
     166        throw RangeCheckError("SphereHEALPix<T>::Set(a ) - SphereHEALPix a not allocated ! ");
    152167      if (NbPixels() < 1) CloneOrShare(a);
    153168      else CopyElt(a);
     
    165180{
    166181  if (NbPixels() < 1)
    167     throw RangeCheckError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& )  - Not Allocated Array ! ");
     182    throw RangeCheckError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& )  - Not Allocated SphereHEALPix ! ");
    168183  if (NbPixels() != a.NbPixels())
    169184    throw(SzMismatchError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     
    177192  return(*this);
    178193}
     194
     195
     196
    179197//++
    180198// Titre        Destructor
     
    542560  return  ring2nest(nSide_,k);
    543561}
     562
     563//   ...... Operations de calcul  ......
     564
     565//! Fill a SphereHEALPix with a constant value \b a
     566template <class T>
     567SphereHEALPix<T>& SphereHEALPix<T>::SetT(T a)
     568{
     569  if (NbPixels() < 1)
     570    throw RangeCheckError("SphereHEALPix<T>::SetT(T )  - SphereHEALPix not dimensionned ! ");
     571  pixels_ = a;
     572  return (*this);
     573}
     574
     575/*! Add a constant value \b x to a SphereHEALPix */
     576template <class T>
     577SphereHEALPix<T>& SphereHEALPix<T>::Add(T a)
     578 {
     579  if (NbPixels() < 1)
     580    throw RangeCheckError("SphereHEALPix<T>::Add(T )  - SphereHEALPix not dimensionned ! ");
     581  pixels_ += a;
     582  return (*this);
     583}
     584
     585/*! Substract a constant value \b a to a SphereHEALPix */
     586template <class T>
     587SphereHEALPix<T>& SphereHEALPix<T>::Sub(T a)
     588{
     589  if (NbPixels() < 1)
     590    throw RangeCheckError("SphereHEALPix<T>::Sub(T )  - SphereHEALPix not dimensionned ! ");
     591  pixels_ -= a;
     592  return (*this);
     593}
     594
     595/*! multiply a SphereHEALPix by a constant value \b a */
     596template <class T>
     597SphereHEALPix<T>& SphereHEALPix<T>::Mul(T a)
     598{
     599  if (NbPixels() < 1)
     600    throw RangeCheckError("SphereHEALPix<T>::Mul(T )  - SphereHEALPix not dimensionned ! ");
     601  pixels_ *= a;
     602  return (*this);
     603}
     604
     605/*! divide a SphereHEALPix by a constant value \b a */
     606template <class T>
     607SphereHEALPix<T>& SphereHEALPix<T>::Div(T a)
     608{
     609  if (NbPixels() < 1)
     610    throw RangeCheckError("SphereHEALPix<T>::Div(T )  - SphereHEALPix not dimensionned ! ");
     611  pixels_ /= a;
     612  return (*this);
     613}
     614
     615//  >>>> Operations avec 2nd membre de type SphereHEALPix
     616//! Add two SphereHEALPix
     617
     618template <class T>
     619SphereHEALPix<T>& SphereHEALPix<T>::AddElt(const SphereHEALPix<T>& a)
     620{
     621  if (NbPixels() != a.NbPixels() )
     622    {
     623    throw(SzMismatchError("SphereHEALPix<T>::AddElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     624    }
     625  pixels_ += a.pixels_;
     626  return (*this);
     627}
     628
     629//! Substract two SphereHEALPix
     630template <class T>
     631SphereHEALPix<T>& SphereHEALPix<T>::SubElt(const SphereHEALPix<T>& a)
     632{
     633  if (NbPixels() != a.NbPixels() )
     634    {
     635    throw(SzMismatchError("SphereHEALPix<T>::SubElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     636    }
     637  pixels_ -= a.pixels_;
     638  return (*this);
     639}
     640
     641//! Multiply two SphereHEALPix (elements by elements)
     642template <class T>
     643SphereHEALPix<T>& SphereHEALPix<T>::MulElt(const SphereHEALPix<T>& a)
     644{
     645  if (NbPixels() != a.NbPixels() )
     646    {
     647    throw(SzMismatchError("SphereHEALPix<T>::SubElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     648    }
     649  pixels_ *= a.pixels_;
     650  return (*this);
     651}
     652
     653
    544654
    545655
Note: See TracChangeset for help on using the changeset viewer.