Changeset 1551 in Sophya


Ignore:
Timestamp:
Jun 27, 2001, 10:14:39 AM (24 years ago)
Author:
ansari
Message:

Operateurs arithmetiques corriges,completes sur les PixelMap (LocalMap et SphericalMaps) - Reza 27/6/2001

Location:
trunk/SophyaLib/SkyMap
Files:
6 edited

Legend:

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

    r1431 r1551  
    640640  if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
    641641    {
    642     throw(SzMismatchError("LocalMap<T>::AddElt(const LocalMap<T>&) SizeMismatch")) ;
     642    throw(SzMismatchError("LocalMap<T>::SubElt(const LocalMap<T>&) SizeMismatch")) ;
    643643    }
    644644  pixels_ -= a.pixels_;
     
    652652  if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
    653653    {
    654     throw(SzMismatchError("LocalMap<T>::AddElt(const LocalMap<T>&) SizeMismatch")) ;
     654    throw(SzMismatchError("LocalMap<T>::MulElt(const LocalMap<T>&) SizeMismatch")) ;
    655655    }
    656656  pixels_ *= a.pixels_;
     657  return (*this);
     658}
     659
     660//! Divide two LocalMaps (elements by elements) - No protection for divide by 0
     661template <class T>
     662LocalMap<T>& LocalMap<T>::DivElt(const LocalMap<T>& a)
     663{
     664  if (nSzX_ != a.nSzX_ || nSzY_ != a.nSzY_)
     665    {
     666    throw(SzMismatchError("LocalMap<T>::DivElt(const LocalMap<T>&) SizeMismatch")) ;
     667    }
     668  pixels_ /= a.pixels_;
    657669  return (*this);
    658670}
  • trunk/SophyaLib/SkyMap/localmap.h

    r1429 r1551  
    142142  virtual LocalMap<T>&  MulElt(const LocalMap<T>& a);
    143143  inline  LocalMap<T>&  operator *= (const LocalMap<T>& a)  { return MulElt(a); }
     144  virtual LocalMap<T>&  DivElt(const LocalMap<T>& a);
     145  inline  LocalMap<T>&  operator /= (const LocalMap<T>& a)  { return DivElt(a); }
    144146
    145147
     
    255257    return result; }
    256258
     259////////////////////////////////////////////////////////////////
     260// Surcharge d'operateurs C = A (*,/) B
     261
     262/*! \ingroup SkyMap \fn operator*(const LocalMap<T>&,const LocalMap<T>&)
     263  \brief Operator LocalMap = LocalMap * LocalMap (pixel by pixel multiply)*/
     264template <class T>
     265inline LocalMap<T> operator * (const LocalMap<T>& a,const LocalMap<T>& b)
     266    { LocalMap<T> result; result.SetTemp(true);
     267    if (b.IsTemp())  { result.Share(b); result.MulElt(a); }
     268    else { result.CloneOrShare(a); result.MulElt(b); }
     269    return result; }
     270
     271/*! \ingroup SkyMap \fn operator/(const LocalMap<T>&,const LocalMap<T>&)
     272  \brief Operator LocalMap = LocalMap / LocalMap (pixel by pixel divide)*/
     273template <class T>
     274inline LocalMap<T> operator / (const LocalMap<T>& a,const LocalMap<T>& b)
     275    { LocalMap<T> result; result.SetTemp(true);
     276    if (b.IsTemp())  { result.Share(b); result.DivElt(a); }
     277    else { result.CloneOrShare(a); result.DivElt(b); }
     278    return result; }
     279
     280
    257281
    258282} // Fin du namespace
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r1419 r1551  
    645645  if (NbPixels() != a.NbPixels() )
    646646    {
    647     throw(SzMismatchError("SphereHEALPix<T>::SubElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     647    throw(SzMismatchError("SphereHEALPix<T>::MulElt(const SphereHEALPix<T>&) SizeMismatch")) ;
    648648    }
    649649  pixels_ *= a.pixels_;
     650  return (*this);
     651}
     652
     653//! Divide two SphereHEALPix (elements by elements) - No protection for divide by 0
     654template <class T>
     655SphereHEALPix<T>& SphereHEALPix<T>::DivElt(const SphereHEALPix<T>& a)
     656{
     657  if (NbPixels() != a.NbPixels() )
     658    {
     659    throw(SzMismatchError("SphereHEALPix<T>::DivElt(const SphereHEALPix<T>&) SizeMismatch")) ;
     660    }
     661  pixels_ /= a.pixels_;
    650662  return (*this);
    651663}
  • trunk/SophyaLib/SkyMap/spherehealpix.h

    r1429 r1551  
    171171  virtual SphereHEALPix<T>&  MulElt(const SphereHEALPix<T>& a);
    172172  inline  SphereHEALPix<T>&  operator *= (const SphereHEALPix<T>& a)  { return MulElt(a); }
     173  virtual SphereHEALPix<T>&  DivElt(const SphereHEALPix<T>& a);
     174  inline  SphereHEALPix<T>&  operator /= (const SphereHEALPix<T>& a)  { return DivElt(a); }
    173175
    174176
     
    278280    return result; }
    279281
     282////////////////////////////////////////////////////////////////
     283// Surcharge d'operateurs C = A (*,/) B
     284
     285/*! \ingroup SkyMap \fn operator*(const SphereHEALPix<T>&,const SphereHEALPix<T>&)
     286  \brief Operator SphereHEALPix = SphereHEALPix * SphereHEALPix (pixel by pixel multiply) */
     287template <class T>
     288inline SphereHEALPix<T> operator * (const SphereHEALPix<T>& a,const SphereHEALPix<T>& b)
     289    { SphereHEALPix<T> result; result.SetTemp(true);
     290    if (b.IsTemp())  { result.Share(b); result.MulElt(a); }
     291    else { result.CloneOrShare(a); result.MulElt(b); }
     292    return result; }
     293
     294/*! \ingroup SkyMap \fn operator/(const SphereHEALPix<T>&,const SphereHEALPix<T>&)
     295  \brief Operator SphereHEALPix = SphereHEALPix / SphereHEALPix (pixel by pixel divide) */
     296template <class T>
     297inline SphereHEALPix<T> operator / (const SphereHEALPix<T>& a,const SphereHEALPix<T>& b)
     298    { SphereHEALPix<T> result; result.SetTemp(true);
     299    if (b.IsTemp())  { result.Share(b); result.DivElt(a); }
     300    else { result.CloneOrShare(a); result.DivElt(b); }
     301    return result; }
     302
    280303} // Fin du namespace
    281304
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r1419 r1551  
    811811  if (NbPixels()!= a.NbPixels())
    812812    {
    813     throw(SzMismatchError("SphereThetaPhi<T>::SubElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
     813    throw(SzMismatchError("SphereThetaPhi<T>::MulElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
    814814    }
    815815  pixels_ *= a.pixels_;
     816  return (*this);
     817}
     818
     819//! Divide two SphereThetaPhi (elements by elements) - No protection for divide by 0
     820template <class T>
     821SphereThetaPhi<T>& SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>& a)
     822{
     823  if (NbPixels()!= a.NbPixels())
     824    {
     825    throw(SzMismatchError("SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
     826    }
     827  pixels_ /= a.pixels_;
    816828  return (*this);
    817829}
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r1423 r1551  
    223223  virtual SphereThetaPhi<T>&  MulElt(const SphereThetaPhi<T>& a);
    224224  inline  SphereThetaPhi<T>&  operator *= (const SphereThetaPhi<T>& a)  { return MulElt(a); }
     225  virtual SphereThetaPhi<T>&  DivElt(const SphereThetaPhi<T>& a);
     226  inline  SphereThetaPhi<T>&  operator /= (const SphereThetaPhi<T>& a)  { return DivElt(a); }
    225227
    226228
     
    332334    return result; }
    333335
     336////////////////////////////////////////////////////////////////
     337// Surcharge d'operateurs C = A (*,/) B
     338
     339/*! \ingroup SkyMap \fn operator*(const SphereThetaPhi<T>&,const SphereThetaPhi<T>&)
     340  \brief Operator SphereThetaPhi = SphereThetaPhi * SphereThetaPhi (pixel by pixel multiply)*/
     341template <class T>
     342inline SphereThetaPhi<T> operator * (const SphereThetaPhi<T>& a,const SphereThetaPhi<T>& b)
     343    { SphereThetaPhi<T> result; result.SetTemp(true);
     344    if (b.IsTemp())  { result.Share(b); result.MulElt(a); }
     345    else { result.CloneOrShare(a); result.MulElt(b); }
     346    return result; }
     347
     348/*! \ingroup SkyMap \fn operator/(const SphereThetaPhi<T>&,const SphereThetaPhi<T>&)
     349  \brief Operator SphereThetaPhi = SphereThetaPhi / SphereThetaPhi (pixel by pixel divide) */
     350template <class T>
     351inline SphereThetaPhi<T> operator / (const SphereThetaPhi<T>& a,const SphereThetaPhi<T>& b)
     352    { SphereThetaPhi<T> result; result.SetTemp(true);
     353    if (b.IsTemp())  { result.Share(b); result.DivElt(a, true); }
     354    else { result.CloneOrShare(a); result.DivElt(b); }
     355    return result; }
     356
    334357
    335358} // Fin du namespace
Note: See TracChangeset for help on using the changeset viewer.