| [2615] | 1 | #include "sopnamsp.h" | 
|---|
| [764] | 2 | #include "spherethetaphi.h" | 
|---|
|  | 3 | #include "smathconst.h" | 
|---|
|  | 4 | #include <complex> | 
|---|
| [809] | 5 | #include "fiondblock.h" | 
|---|
| [2322] | 6 | #include <iostream> | 
|---|
| [764] | 7 |  | 
|---|
|  | 8 |  | 
|---|
| [2303] | 9 | /*! | 
|---|
|  | 10 | \class SOPHYA::SphereThetaPhi | 
|---|
|  | 11 | \ingroup SkyMap | 
|---|
| [2808] | 12 |  | 
|---|
|  | 13 | \brief Spherical map with equal latitude (iso-theta) rings | 
|---|
|  | 14 |  | 
|---|
|  | 15 |  | 
|---|
| [2303] | 16 | Class implementing spherical maps, with equal latitude (iso-theta) rings | 
|---|
|  | 17 | pixelisation scheme - with template data types (double, float, complex, ...) | 
|---|
|  | 18 |  | 
|---|
|  | 19 | sphere splitted with respect to theta, phi : each hemisphere is | 
|---|
|  | 20 | splitted into (m-1) parallels (equator does not enter into account). | 
|---|
|  | 21 | This operation defines m slices, each of which is splitted into | 
|---|
|  | 22 | equidistant meridians. This splitting is realized in such a way that | 
|---|
|  | 23 | all pixels have the same area and are as square as possible. | 
|---|
|  | 24 |  | 
|---|
|  | 25 | One begins with the hemisphere with positive z, starting from the pole | 
|---|
|  | 26 | toward the equator. The first pixel is the polar cap ; it is circular | 
|---|
|  | 27 | and centered on theta=0. | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
| [764] | 30 | //*************************************************************** | 
|---|
|  | 31 | //++ | 
|---|
|  | 32 | // Class        SphereThetaPhi | 
|---|
|  | 33 | // | 
|---|
|  | 34 | // | 
|---|
|  | 35 | // include      spherethetaphi.h | 
|---|
|  | 36 | //-- | 
|---|
|  | 37 | //++ | 
|---|
|  | 38 | // | 
|---|
|  | 39 | // Links        Parents | 
|---|
|  | 40 | // | 
|---|
|  | 41 | //    SphericalMap | 
|---|
|  | 42 | //-- | 
|---|
|  | 43 |  | 
|---|
|  | 44 | /* --Methode-- */ | 
|---|
|  | 45 | //++ | 
|---|
|  | 46 | // Titre        Constructors | 
|---|
|  | 47 | //-- | 
|---|
|  | 48 | //++ | 
|---|
|  | 49 |  | 
|---|
|  | 50 | template <class T> | 
|---|
|  | 51 | SphereThetaPhi<T>::SphereThetaPhi() | 
|---|
| [980] | 52 | : NPhi_(), TNphi_(), Theta_(), pixels_() | 
|---|
| [764] | 53 |  | 
|---|
|  | 54 | //-- | 
|---|
|  | 55 | { | 
|---|
|  | 56 | InitNul(); | 
|---|
|  | 57 | } | 
|---|
|  | 58 |  | 
|---|
|  | 59 |  | 
|---|
|  | 60 | /* --Methode-- */ | 
|---|
|  | 61 |  | 
|---|
| [2960] | 62 | /*! | 
|---|
|  | 63 | \brief Constructor with specification of number of slices (in a hemisphere) | 
|---|
|  | 64 | \param m is the number of slices in theta on an hemisphere (the polar cap | 
|---|
|  | 65 | forms the first slice). | 
|---|
|  | 66 | */ | 
|---|
| [764] | 67 | template <class T> | 
|---|
|  | 68 | SphereThetaPhi<T>::SphereThetaPhi(int_4 m) | 
|---|
|  | 69 | { | 
|---|
|  | 70 | InitNul(); | 
|---|
|  | 71 | Pixelize(m); | 
|---|
|  | 72 | } | 
|---|
|  | 73 |  | 
|---|
| [2960] | 74 | //! Copy constructor (shares the pixel data if share==true) | 
|---|
| [764] | 75 | template <class T> | 
|---|
|  | 76 | SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s, bool share) | 
|---|
| [908] | 77 | : NPhi_(s.NPhi_, share), TNphi_(s.TNphi_, share), Theta_(s.Theta_, share), | 
|---|
|  | 78 | pixels_(s.pixels_ , share) | 
|---|
| [764] | 79 | { | 
|---|
| [908] | 80 |  | 
|---|
| [764] | 81 | NTheta_= s.NTheta_; | 
|---|
|  | 82 | NPix_  = s.NPix_; | 
|---|
| [908] | 83 | Omega_ = s.Omega_; | 
|---|
| [2885] | 84 | if(s.mInfo_) this->mInfo_= new DVList(*s.mInfo_); | 
|---|
| [908] | 85 | } | 
|---|
| [764] | 86 |  | 
|---|
| [2960] | 87 | //! Copy constructor (shares the pixel data) | 
|---|
| [908] | 88 | template <class T> | 
|---|
|  | 89 | SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s) | 
|---|
|  | 90 | : NPhi_(s.NPhi_), TNphi_(s.TNphi_), Theta_(s.Theta_), pixels_(s.pixels_) | 
|---|
|  | 91 | { | 
|---|
|  | 92 |  | 
|---|
|  | 93 | NTheta_= s.NTheta_; | 
|---|
|  | 94 | NPix_  = s.NPix_; | 
|---|
| [764] | 95 | Omega_ = s.Omega_; | 
|---|
| [2885] | 96 | if(s.mInfo_) this->mInfo_= new DVList(*s.mInfo_); | 
|---|
| [764] | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 | //++ | 
|---|
|  | 100 | // Titre        Destructor | 
|---|
|  | 101 | //-- | 
|---|
|  | 102 | //++ | 
|---|
|  | 103 | template <class T> | 
|---|
|  | 104 | SphereThetaPhi<T>::~SphereThetaPhi() | 
|---|
|  | 105 |  | 
|---|
|  | 106 | //-- | 
|---|
|  | 107 | {} | 
|---|
|  | 108 |  | 
|---|
|  | 109 | template <class T> | 
|---|
|  | 110 | void SphereThetaPhi<T>::InitNul() | 
|---|
|  | 111 | // | 
|---|
|  | 112 | { | 
|---|
|  | 113 | NTheta_= 0; | 
|---|
|  | 114 | NPix_  = 0; | 
|---|
|  | 115 | //  pixels_.Reset();  Pas de reset par InitNul (en cas de share) - Reza 20/11/99 $CHECK$ | 
|---|
|  | 116 | } | 
|---|
|  | 117 |  | 
|---|
|  | 118 |  | 
|---|
| [2960] | 119 | //!   re-pixelize the sphere if (m > 0) | 
|---|
| [764] | 120 | template <class T> | 
|---|
|  | 121 | void SphereThetaPhi<T>::Resize(int_4 m) | 
|---|
|  | 122 | { | 
|---|
| [2960] | 123 | if ((m <= 0) && (NTheta_ > 0) ) { | 
|---|
|  | 124 | cout << "SphereThetaPhi<T>::Resize(m) with m<=0 - NOT resized" << endl; | 
|---|
|  | 125 | return; | 
|---|
|  | 126 | } | 
|---|
| [764] | 127 | InitNul(); | 
|---|
|  | 128 | Pixelize(m); | 
|---|
|  | 129 | } | 
|---|
|  | 130 |  | 
|---|
| [2960] | 131 | //! Clone or share the SphereThetaPhi object \b a | 
|---|
| [908] | 132 | template<class T> | 
|---|
|  | 133 | void  SphereThetaPhi<T>::CloneOrShare(const  SphereThetaPhi<T>& a) | 
|---|
|  | 134 | { | 
|---|
|  | 135 |  | 
|---|
| [980] | 136 | NTheta_= a.NTheta_; | 
|---|
|  | 137 | NPix_  = a.NPix_; | 
|---|
|  | 138 | Omega_ = a.Omega_; | 
|---|
|  | 139 | NPhi_.CloneOrShare(a.NPhi_); | 
|---|
|  | 140 | TNphi_.CloneOrShare(a.TNphi_); | 
|---|
|  | 141 | Theta_.CloneOrShare(a.Theta_); | 
|---|
|  | 142 | pixels_.CloneOrShare(a.pixels_); | 
|---|
| [2885] | 143 | if (this->mInfo_) {delete this->mInfo_; this->mInfo_ = NULL;} | 
|---|
|  | 144 | if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_)); | 
|---|
| [908] | 145 | } | 
|---|
| [2960] | 146 | //! Share the pixel data with object \b a | 
|---|
| [1419] | 147 | template<class T> | 
|---|
|  | 148 | void  SphereThetaPhi<T>::Share(const  SphereThetaPhi<T>& a) | 
|---|
|  | 149 | { | 
|---|
| [908] | 150 |  | 
|---|
| [1419] | 151 | NTheta_= a.NTheta_; | 
|---|
|  | 152 | NPix_  = a.NPix_; | 
|---|
|  | 153 | Omega_ = a.Omega_; | 
|---|
|  | 154 | NPhi_.Share(a.NPhi_); | 
|---|
|  | 155 | TNphi_.Share(a.TNphi_); | 
|---|
|  | 156 | Theta_.Share(a.Theta_); | 
|---|
|  | 157 | pixels_.Share(a.pixels_); | 
|---|
| [2885] | 158 | if (this->mInfo_) {delete this->mInfo_; this->mInfo_ = NULL;} | 
|---|
|  | 159 | if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_)); | 
|---|
| [1419] | 160 | } | 
|---|
|  | 161 |  | 
|---|
| [980] | 162 | ////////////////////////// methodes de copie/share | 
|---|
| [2960] | 163 | //! Perform data copy or shares the data | 
|---|
| [908] | 164 | template<class T> | 
|---|
|  | 165 | SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a) | 
|---|
| [980] | 166 | { | 
|---|
| [908] | 167 | if (this != &a) | 
|---|
|  | 168 | { | 
|---|
| [980] | 169 |  | 
|---|
|  | 170 |  | 
|---|
|  | 171 | if (a.NbPixels() < 1) | 
|---|
|  | 172 | throw RangeCheckError("SphereThetaPhi<T>::Set(a ) - Array a not allocated ! "); | 
|---|
|  | 173 | if (NbPixels() < 1) CloneOrShare(a); | 
|---|
|  | 174 | else CopyElt(a); | 
|---|
| [2885] | 175 | if (this->mInfo_) delete this->mInfo_; | 
|---|
|  | 176 | this->mInfo_ = NULL; | 
|---|
|  | 177 | if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_)); | 
|---|
| [908] | 178 | } | 
|---|
|  | 179 | return(*this); | 
|---|
| [980] | 180 | } | 
|---|
| [908] | 181 |  | 
|---|
| [2960] | 182 | //! Perform data copy or shares the data | 
|---|
| [980] | 183 | template<class T> | 
|---|
|  | 184 | SphereThetaPhi<T>& SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& a) | 
|---|
|  | 185 | { | 
|---|
|  | 186 | if (NbPixels() < 1) | 
|---|
|  | 187 | throw RangeCheckError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& )  - Not Allocated Array ! "); | 
|---|
|  | 188 | if (NbPixels() != a.NbPixels()) | 
|---|
|  | 189 | throw(SzMismatchError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>&) SizeMismatch")) ; | 
|---|
| [908] | 190 |  | 
|---|
| [980] | 191 | NTheta_= a.NTheta_; | 
|---|
|  | 192 | NPix_  = a.NPix_; | 
|---|
|  | 193 | Omega_ = a.Omega_; | 
|---|
|  | 194 | int k; | 
|---|
|  | 195 | for (k=0; k< NPix_; k++) pixels_(k) = a.pixels_(k); | 
|---|
|  | 196 | for (k=0; k< a.NPhi_.Size(); k++) NPhi_(k) = a.NPhi_(k); | 
|---|
|  | 197 | for (k=0; k< a.TNphi_.Size(); k++) TNphi_(k) = a.TNphi_(k); | 
|---|
|  | 198 | for (k=0; k< a.Theta_.Size(); k++) Theta_(k) = a.Theta_(k); | 
|---|
|  | 199 | return(*this); | 
|---|
| [908] | 200 |  | 
|---|
| [980] | 201 | } | 
|---|
|  | 202 |  | 
|---|
| [764] | 203 | /* --Methode-- */ | 
|---|
| [2960] | 204 | //!    Return total number of pixels | 
|---|
| [764] | 205 | template <class T> | 
|---|
|  | 206 | int_4 SphereThetaPhi<T>::NbPixels() const | 
|---|
|  | 207 | { | 
|---|
|  | 208 | return(NPix_); | 
|---|
|  | 209 | } | 
|---|
|  | 210 |  | 
|---|
|  | 211 | /* --Methode-- */ | 
|---|
| [2960] | 212 | //!    Return value of pixel with index k | 
|---|
| [764] | 213 | template <class T> | 
|---|
|  | 214 | T& SphereThetaPhi<T>::PixVal(int_4 k) | 
|---|
|  | 215 | { | 
|---|
|  | 216 | if((k < 0) || (k >= NPix_)) | 
|---|
|  | 217 | { | 
|---|
|  | 218 | throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); | 
|---|
|  | 219 | } | 
|---|
|  | 220 | return pixels_(k); | 
|---|
|  | 221 | } | 
|---|
|  | 222 |  | 
|---|
| [2960] | 223 | //!    Return value of pixel with index k | 
|---|
| [764] | 224 | template <class T> | 
|---|
|  | 225 | T const& SphereThetaPhi<T>::PixVal(int_4 k) const | 
|---|
|  | 226 | { | 
|---|
|  | 227 | if((k < 0) || (k >= NPix_)) | 
|---|
|  | 228 | { | 
|---|
|  | 229 | throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); | 
|---|
|  | 230 | } | 
|---|
|  | 231 | return *(pixels_.Data()+k); | 
|---|
|  | 232 | } | 
|---|
|  | 233 |  | 
|---|
|  | 234 | /* --Methode-- */ | 
|---|
| [2960] | 235 | //! Return true if teta,phi in map | 
|---|
| [764] | 236 | template <class T> | 
|---|
|  | 237 | bool SphereThetaPhi<T>::ContainsSph(double /*theta*/, double /*phi*/) const | 
|---|
|  | 238 | { | 
|---|
|  | 239 | return(true); | 
|---|
|  | 240 | } | 
|---|
|  | 241 |  | 
|---|
|  | 242 | /* --Methode-- */ | 
|---|
| [2960] | 243 | //!    Return index of the pixel corresponding to direction (theta, phi). | 
|---|
| [764] | 244 | template <class T> | 
|---|
|  | 245 | int_4 SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const | 
|---|
|  | 246 | { | 
|---|
|  | 247 | double dphi; | 
|---|
|  | 248 | int i,k; | 
|---|
|  | 249 | bool fgzn = false; | 
|---|
|  | 250 |  | 
|---|
|  | 251 | if((theta > Pi) || (theta < 0.)) return(-1); | 
|---|
|  | 252 | if((phi < 0.) || (phi > DeuxPi)) return(-1); | 
|---|
|  | 253 | if(theta > Pi*0.5) {fgzn = true; theta = Pi-theta;} | 
|---|
|  | 254 |  | 
|---|
|  | 255 | // La bande d'indice kt est limitée par les valeurs de theta contenues dans | 
|---|
|  | 256 | // Theta_[kt] et Theta_[kt+1] | 
|---|
|  | 257 | for( i=1; i< NTheta_; i++ ) | 
|---|
|  | 258 | if( theta < Theta_(i) ) break; | 
|---|
|  | 259 |  | 
|---|
|  | 260 | dphi= DeuxPi/(double)NPhi_(i-1); | 
|---|
|  | 261 |  | 
|---|
|  | 262 | if (fgzn)  k= NPix_-TNphi_(i)+(int_4)(phi/dphi); | 
|---|
|  | 263 | else k= TNphi_(i-1)+(int_4)(phi/dphi); | 
|---|
|  | 264 | return(k); | 
|---|
|  | 265 | } | 
|---|
|  | 266 |  | 
|---|
|  | 267 | /* --Methode-- */ | 
|---|
| [2960] | 268 | //!   Return (theta,phi) coordinates of middle of  pixel with  index k | 
|---|
| [764] | 269 | template <class T> | 
|---|
|  | 270 | void SphereThetaPhi<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const | 
|---|
|  | 271 | { | 
|---|
|  | 272 | int i; | 
|---|
|  | 273 | bool fgzn = false; | 
|---|
|  | 274 |  | 
|---|
|  | 275 | if((k < 0) || (k >= NPix_)) {theta = -99999.; phi = -99999.; return; } | 
|---|
|  | 276 | if( k >= NPix_/2)  {fgzn = true; k = NPix_-1-k;} | 
|---|
|  | 277 |  | 
|---|
|  | 278 | // recupère l'indice i de la tranche qui contient le pixel k | 
|---|
|  | 279 | for( i=0; i< NTheta_; i++ ) | 
|---|
|  | 280 | if( k < TNphi_(i+1) ) break; | 
|---|
|  | 281 |  | 
|---|
|  | 282 | // angle theta | 
|---|
|  | 283 | theta= 0.5*(Theta_(i)+Theta_(i+1)); | 
|---|
|  | 284 | if (fgzn) theta= Pi-theta; | 
|---|
|  | 285 |  | 
|---|
|  | 286 | // angle phi | 
|---|
|  | 287 | k -= TNphi_(i); | 
|---|
|  | 288 | phi= DeuxPi/(double)NPhi_(i)*(double)(k+.5); | 
|---|
|  | 289 | if (fgzn) phi= DeuxPi-phi; | 
|---|
|  | 290 | } | 
|---|
|  | 291 |  | 
|---|
| [2960] | 292 | //! Setting pixel values to a constant | 
|---|
| [764] | 293 | template <class T> | 
|---|
|  | 294 | T SphereThetaPhi<T>::SetPixels(T v) | 
|---|
|  | 295 | { | 
|---|
|  | 296 | pixels_.Reset(v); | 
|---|
|  | 297 | return(v); | 
|---|
|  | 298 | } | 
|---|
|  | 299 |  | 
|---|
| [2960] | 300 | /*! | 
|---|
|  | 301 | \brief Pixel Solid angle  (steradians) | 
|---|
|  | 302 | All the pixels have the same solid angle. The dummy argument is | 
|---|
|  | 303 | for compatibility with eventual pixelizations which would not | 
|---|
|  | 304 | fulfil this requirement. | 
|---|
|  | 305 | */ | 
|---|
| [764] | 306 | template <class T> | 
|---|
|  | 307 | double SphereThetaPhi<T>::PixSolAngle(int_4 /*dummy*/) const | 
|---|
|  | 308 |  | 
|---|
|  | 309 | { | 
|---|
|  | 310 | return Omega_; | 
|---|
|  | 311 | } | 
|---|
|  | 312 |  | 
|---|
|  | 313 | /* --Methode-- */ | 
|---|
| [2960] | 314 | //!   Return values of theta,phi which limit the pixel with  index k | 
|---|
| [764] | 315 | template <class T> | 
|---|
|  | 316 | void SphereThetaPhi<T>::Limits(int_4 k,double& tetMin,double& tetMax,double& phiMin,double& phiMax) | 
|---|
|  | 317 | { | 
|---|
|  | 318 | int j; | 
|---|
|  | 319 | double dphi; | 
|---|
|  | 320 | bool fgzn= false; | 
|---|
|  | 321 |  | 
|---|
|  | 322 | if((k < 0) || (k >= NPix_)) { | 
|---|
|  | 323 | tetMin= -99999.; | 
|---|
|  | 324 | phiMin= -99999.; | 
|---|
|  | 325 | tetMax= -99999.; | 
|---|
|  | 326 | phiMax= -99999.; | 
|---|
|  | 327 | return; | 
|---|
|  | 328 | } | 
|---|
|  | 329 |  | 
|---|
|  | 330 | // si on se trouve dans l'hémisphère Sud | 
|---|
|  | 331 | if(k >= NPix_/2) { | 
|---|
|  | 332 | fgzn= true; | 
|---|
|  | 333 | k= NPix_-1-k; | 
|---|
|  | 334 | } | 
|---|
|  | 335 |  | 
|---|
|  | 336 | // on recupere l'indice i de la tranche qui contient le pixel k | 
|---|
|  | 337 | int i; | 
|---|
|  | 338 | for( i=0; i< NTheta_; i++ ) | 
|---|
|  | 339 | if(k < TNphi_(i+1)) break; | 
|---|
|  | 340 |  | 
|---|
|  | 341 | // valeurs limites de theta dans l'hemisphere Nord | 
|---|
|  | 342 | tetMin= Theta_(i); | 
|---|
|  | 343 | tetMax= Theta_(i+1); | 
|---|
|  | 344 | // valeurs limites de theta dans l'hemisphere Sud | 
|---|
|  | 345 | if (fgzn) { | 
|---|
|  | 346 | tetMin= Pi - Theta_(i+1); | 
|---|
|  | 347 | tetMax= Pi - Theta_(i); | 
|---|
|  | 348 | } | 
|---|
|  | 349 |  | 
|---|
|  | 350 | // pixel correspondant dans l'hemisphere Nord | 
|---|
|  | 351 | if (fgzn) k= TNphi_(i+1)-k+TNphi_(i)-1; | 
|---|
|  | 352 |  | 
|---|
|  | 353 | // indice j de discretisation ( phi= j*dphi ) | 
|---|
|  | 354 | j= k-TNphi_(i); | 
|---|
|  | 355 | dphi= DeuxPi/(double)NPhi_(i); | 
|---|
|  | 356 |  | 
|---|
|  | 357 | // valeurs limites de phi | 
|---|
|  | 358 | phiMin= dphi*(double)(j); | 
|---|
|  | 359 | phiMax= dphi*(double)(j+1); | 
|---|
|  | 360 | return; | 
|---|
|  | 361 | } | 
|---|
|  | 362 |  | 
|---|
|  | 363 | /* --Methode-- */ | 
|---|
| [2960] | 364 | //!    Return number of theta-slices on the sphere | 
|---|
| [764] | 365 | template <class T> | 
|---|
|  | 366 | uint_4 SphereThetaPhi<T>::NbThetaSlices() const | 
|---|
|  | 367 | { | 
|---|
|  | 368 | if (NTheta_<=0) | 
|---|
|  | 369 | { | 
|---|
|  | 370 | throw PException(" sphere not pixelized, NbSlice=0 "); | 
|---|
|  | 371 | } | 
|---|
|  | 372 | return( 2*NTheta_); | 
|---|
|  | 373 | } | 
|---|
|  | 374 |  | 
|---|
|  | 375 | /* --Methode-- */ | 
|---|
| [2960] | 376 | //!    Return number of pixels along the phi-direction of the kt-th slice | 
|---|
| [764] | 377 | template <class T> | 
|---|
|  | 378 | int_4 SphereThetaPhi<T>::NPhi(int_4 kt) const | 
|---|
|  | 379 | { | 
|---|
|  | 380 | int nbpix; | 
|---|
|  | 381 | // verification | 
|---|
|  | 382 | if((kt < 0) || (kt >= 2*NTheta_)) return(-1); | 
|---|
|  | 383 |  | 
|---|
|  | 384 | // si on se trouve dans l'hemisphere Sud | 
|---|
|  | 385 | if(kt >= NTheta_) { | 
|---|
|  | 386 | kt= 2*NTheta_-1-kt; | 
|---|
|  | 387 | } | 
|---|
|  | 388 |  | 
|---|
|  | 389 | // nombre de pixels | 
|---|
|  | 390 | nbpix= NPhi_(kt); | 
|---|
|  | 391 | return(nbpix); | 
|---|
|  | 392 | } | 
|---|
|  | 393 |  | 
|---|
|  | 394 |  | 
|---|
|  | 395 | /* --Methode-- */ | 
|---|
| [2960] | 396 | //!    Return  theta values which limit the slice kt | 
|---|
| [764] | 397 | template <class T> | 
|---|
|  | 398 | void SphereThetaPhi<T>::Theta(int_4 kt,double& tetMin,double& tetMax) | 
|---|
|  | 399 | { | 
|---|
|  | 400 | bool fgzn= false; | 
|---|
|  | 401 | // verification | 
|---|
|  | 402 | if( (kt< 0) || (kt>= 2*NTheta_) ) { | 
|---|
|  | 403 | tetMin= -99999.; | 
|---|
|  | 404 | tetMax= -99999.; | 
|---|
|  | 405 | return; | 
|---|
|  | 406 | } | 
|---|
|  | 407 |  | 
|---|
|  | 408 | // si on se trouve dans l'hemisphere Sud | 
|---|
|  | 409 | if( kt >= NTheta_ ) { | 
|---|
|  | 410 | fgzn= true; | 
|---|
|  | 411 | kt= 2*NTheta_-1-kt; | 
|---|
|  | 412 | } | 
|---|
|  | 413 |  | 
|---|
|  | 414 | // valeurs limites de theta dans l'hemisphere Nord | 
|---|
|  | 415 | tetMin= Theta_(kt); | 
|---|
|  | 416 | tetMax= Theta_(kt+1); | 
|---|
|  | 417 | // valeurs limites de theta dans l'hemisphere Sud | 
|---|
|  | 418 | if (fgzn) { | 
|---|
|  | 419 | tetMin= Pi - Theta_(kt+1); | 
|---|
|  | 420 | tetMax= Pi - Theta_(kt); | 
|---|
|  | 421 | } | 
|---|
|  | 422 | } | 
|---|
|  | 423 |  | 
|---|
|  | 424 | /* --Methode-- */ | 
|---|
| [2960] | 425 | //!   Return values of phi which limit the jp-th pixel of the kt-th slice | 
|---|
| [764] | 426 | template <class T> | 
|---|
|  | 427 | void SphereThetaPhi<T>::Phi(int_4 kt,int_4 jp,double& phiMin,double& phiMax) | 
|---|
|  | 428 | { | 
|---|
|  | 429 | // verification | 
|---|
|  | 430 | if((kt < 0) || (kt >= 2*NTheta_)) { | 
|---|
|  | 431 | phiMin= -99999.; | 
|---|
|  | 432 | phiMax= -99999.; | 
|---|
|  | 433 | return; | 
|---|
|  | 434 | } | 
|---|
|  | 435 |  | 
|---|
|  | 436 | // si on se trouve dans l'hemisphere Sud | 
|---|
|  | 437 | if(kt >= NTheta_) kt= 2*NTheta_-1-kt; | 
|---|
|  | 438 |  | 
|---|
|  | 439 | // verifie si la tranche kt contient au moins jp pixels | 
|---|
|  | 440 | if( (jp< 0) || (jp >= NPhi_(kt)) ) { | 
|---|
|  | 441 | phiMin= -88888.; | 
|---|
|  | 442 | phiMax= -88888.; | 
|---|
|  | 443 | return; | 
|---|
|  | 444 | } | 
|---|
|  | 445 |  | 
|---|
|  | 446 | double dphi= DeuxPi/(double)NPhi_(kt); | 
|---|
|  | 447 | phiMin= dphi*(double)(jp); | 
|---|
|  | 448 | phiMax= dphi*(double)(jp+1); | 
|---|
|  | 449 | return; | 
|---|
|  | 450 | } | 
|---|
|  | 451 |  | 
|---|
|  | 452 | /* --Methode-- */ | 
|---|
| [2960] | 453 | //!    Return pixel index  with sequence index jp in the slice kt | 
|---|
| [764] | 454 | template <class T> | 
|---|
|  | 455 | int_4 SphereThetaPhi<T>::Index(int_4 kt,int_4 jp) const | 
|---|
|  | 456 | { | 
|---|
|  | 457 | int k; | 
|---|
|  | 458 | bool fgzn= false; | 
|---|
|  | 459 |  | 
|---|
|  | 460 | // si on se trouve dans l'hemisphere Sud | 
|---|
|  | 461 | if(kt >= NTheta_) { | 
|---|
|  | 462 | fgzn= true; | 
|---|
|  | 463 | kt= 2*NTheta_-1-kt; | 
|---|
|  | 464 | } | 
|---|
|  | 465 |  | 
|---|
|  | 466 | // si la tranche kt contient au moins i pixels | 
|---|
|  | 467 | if( (jp>=0) && (jp<NPhi_(kt)) ) | 
|---|
|  | 468 | { | 
|---|
|  | 469 | // dans l'hemisphere Sud | 
|---|
|  | 470 | if (fgzn) k= NPix_-TNphi_(kt+1)+jp; | 
|---|
|  | 471 | // dans l'hemisphere Nord | 
|---|
|  | 472 | else k= TNphi_(kt)+jp; | 
|---|
|  | 473 | } | 
|---|
|  | 474 | else | 
|---|
|  | 475 | { | 
|---|
|  | 476 | k= 9999; | 
|---|
|  | 477 | printf("\n la tranche %d ne contient pas un pixel de rang %d",kt,jp); | 
|---|
|  | 478 | } | 
|---|
|  | 479 | return(k); | 
|---|
|  | 480 | } | 
|---|
|  | 481 |  | 
|---|
|  | 482 | /* --Methode-- */ | 
|---|
| [2960] | 483 | //!    Return indices kt (theta) and jp (phi) of  pixel with index k | 
|---|
| [764] | 484 | template <class T> | 
|---|
|  | 485 | void SphereThetaPhi<T>::ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp) | 
|---|
|  | 486 | { | 
|---|
|  | 487 | bool fgzn= false; | 
|---|
|  | 488 | // si on se trouve dans l'hemisphere Sud | 
|---|
|  | 489 | if(k >= NPix_/2) | 
|---|
|  | 490 | { | 
|---|
|  | 491 | fgzn= true; | 
|---|
|  | 492 | k= NPix_-1-k; | 
|---|
|  | 493 | } | 
|---|
|  | 494 |  | 
|---|
|  | 495 | // on recupere l'indice kt de la tranche qui contient le pixel k | 
|---|
|  | 496 | int i; | 
|---|
|  | 497 | for(i = 0; i < NTheta_; i++) | 
|---|
|  | 498 | if(k < TNphi_(i+1)) break; | 
|---|
|  | 499 |  | 
|---|
|  | 500 | // indice  kt de tranche | 
|---|
|  | 501 | if (fgzn) kt= 2*NTheta_-1-i; | 
|---|
|  | 502 | else kt= i; | 
|---|
|  | 503 |  | 
|---|
|  | 504 | // indice jp de pixel | 
|---|
|  | 505 | if (fgzn) jp= TNphi_(i+1)-k-1; | 
|---|
|  | 506 | else jp= k-TNphi_(i); | 
|---|
|  | 507 | } | 
|---|
| [2960] | 508 | /*! | 
|---|
|  | 509 | \brief achieve the splitting into pixels | 
|---|
|  | 510 | m has the same signification as for the constructor | 
|---|
|  | 511 |  | 
|---|
|  | 512 | Each theta-slice of the north hemisphere will be spitted starting f | 
|---|
|  | 513 | from  phi=0 ... | 
|---|
|  | 514 |  | 
|---|
|  | 515 | South hemisphere is scanned in the same direction according to phi | 
|---|
|  | 516 | and from equator to the pole (the pixel following the last one of | 
|---|
|  | 517 | the slice closest to the equator with z>0, is the pixel with lowest | 
|---|
|  | 518 | phi of the slice closest of the equator with z<0). | 
|---|
|  | 519 | */ | 
|---|
| [764] | 520 | template <class T> | 
|---|
|  | 521 | void  SphereThetaPhi<T>::Pixelize(int_4 m) | 
|---|
|  | 522 |  | 
|---|
|  | 523 | //-- | 
|---|
|  | 524 | { | 
|---|
|  | 525 | int ntotpix,j; | 
|---|
|  | 526 |  | 
|---|
|  | 527 | // Decodage et controle des arguments d'appel : | 
|---|
| [2960] | 528 | // au moins 2 et au plus 524288 bandes d'un hemisphere en theta | 
|---|
| [764] | 529 | if (m < 2) m = 2; | 
|---|
| [2960] | 530 | if (m > 524288) m = 524288; | 
|---|
| [764] | 531 |  | 
|---|
|  | 532 | // On memorise les arguments d'appel | 
|---|
|  | 533 | NTheta_ = m; | 
|---|
|  | 534 |  | 
|---|
|  | 535 | // On commence par decouper l'hemisphere z>0. | 
|---|
|  | 536 | // Creation des vecteurs contenant : | 
|---|
|  | 537 | // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...) | 
|---|
|  | 538 | //  Theta_= new double[m+1]; | 
|---|
|  | 539 | Theta_.ReSize(m+1); | 
|---|
|  | 540 |  | 
|---|
|  | 541 | // Le nombre de pixels en phi de chacune des bandes en theta | 
|---|
|  | 542 | //  NPhi_ = new int_4[m]; | 
|---|
| [980] | 543 | // une taille de m suffit, mais je mets m+1 pour que les 3 tableaux aient | 
|---|
|  | 544 | // la meme taille pour une manipulation plus faciles par la librairie | 
|---|
|  | 545 | // cfitsio -- GLM (13-04-00) | 
|---|
|  | 546 | NPhi_.ReSize(m+1); | 
|---|
| [764] | 547 |  | 
|---|
|  | 548 | // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une | 
|---|
|  | 549 | // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere) | 
|---|
|  | 550 | //  TNphi_= new int_4[m+1]; | 
|---|
|  | 551 | TNphi_.ReSize(m+1); | 
|---|
|  | 552 |  | 
|---|
|  | 553 | // Calcul du nombre total de pixels dans chaque bande pour optimiser | 
|---|
|  | 554 | // le rapport largeur/hauteur des pixels | 
|---|
|  | 555 |  | 
|---|
|  | 556 | //calotte polaire | 
|---|
|  | 557 | TNphi_(0)= 0; | 
|---|
|  | 558 | NPhi_(0) = 1; | 
|---|
|  | 559 |  | 
|---|
|  | 560 | //bandes jusqu'a l'equateur | 
|---|
|  | 561 | for(j = 1; j < m; j++) | 
|---|
|  | 562 | { | 
|---|
|  | 563 | TNphi_(j)= TNphi_(j-1)+NPhi_(j-1); | 
|---|
|  | 564 | NPhi_(j) = (int_4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ; | 
|---|
|  | 565 | } | 
|---|
|  | 566 |  | 
|---|
|  | 567 | // Nombre total de pixels sur l'hemisphere | 
|---|
|  | 568 | ntotpix  = TNphi_(m-1)+NPhi_(m-1); | 
|---|
|  | 569 | TNphi_(m)= ntotpix; | 
|---|
|  | 570 | // et sur la sphere entiere | 
|---|
|  | 571 | NPix_= 2*ntotpix; | 
|---|
|  | 572 |  | 
|---|
|  | 573 | // Creation et initialisation du vecteur des contenus des pixels | 
|---|
|  | 574 | pixels_.ReSize(NPix_); | 
|---|
|  | 575 | pixels_.Reset(); | 
|---|
|  | 576 |  | 
|---|
|  | 577 | // Determination des limites des bandes en theta : | 
|---|
|  | 578 | // omeg est l'angle solide couvert par chaque pixel, | 
|---|
|  | 579 | // une bande donnee kt couvre un angle solide NPhi_[kt]*omeg | 
|---|
|  | 580 | // egal a 2* Pi*(cos Theta_[kt]-cos Theta_[kt+1]). De meme, l'angle solide | 
|---|
|  | 581 | //de la | 
|---|
|  | 582 | // calotte allant du pole a la limite haute de la bande kt vaut | 
|---|
|  | 583 | // 2* Pi*(1.-cos Theta_[kt+1])= TNphi_[kt]*omeg... | 
|---|
|  | 584 |  | 
|---|
|  | 585 | double omeg2pi= 1./(double)ntotpix; | 
|---|
|  | 586 | Omega_ = omeg2pi*DeuxPi; | 
|---|
|  | 587 |  | 
|---|
|  | 588 | for(j=0; j <= m; j++) | 
|---|
|  | 589 | { | 
|---|
|  | 590 | Theta_(j)= acos(1.-(double)TNphi_(j)*omeg2pi); | 
|---|
|  | 591 | } | 
|---|
|  | 592 | } | 
|---|
|  | 593 |  | 
|---|
| [2960] | 594 |  | 
|---|
|  | 595 | /*! | 
|---|
|  | 596 | \brief return a Theta slice information | 
|---|
|  | 597 | For a theta-slice with index 'index', return : | 
|---|
|  | 598 | the corresponding "theta" | 
|---|
|  | 599 | a vector containing the phi's of the pixels of the slice | 
|---|
|  | 600 | a vector containing the corresponding values of pixels | 
|---|
|  | 601 | */ | 
|---|
| [764] | 602 | template <class T> | 
|---|
|  | 603 | void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, TVector<r_8>& phi, TVector<T>& value) const | 
|---|
|  | 604 |  | 
|---|
|  | 605 | { | 
|---|
|  | 606 |  | 
|---|
|  | 607 | if(index < 0 || index >= NbThetaSlices()) | 
|---|
|  | 608 | { | 
|---|
|  | 609 | throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); | 
|---|
|  | 610 | } | 
|---|
|  | 611 |  | 
|---|
|  | 612 | int iring= Index(index,0); | 
|---|
|  | 613 | int lring  = NPhi(index); | 
|---|
|  | 614 |  | 
|---|
|  | 615 | phi.ReSize(lring); | 
|---|
|  | 616 | value.ReSize(lring); | 
|---|
|  | 617 | double Te= 0.; | 
|---|
|  | 618 | double Fi= 0.; | 
|---|
|  | 619 | for(int kk = 0; kk < lring; kk++) | 
|---|
|  | 620 | { | 
|---|
|  | 621 | PixThetaPhi(kk+iring,Te,Fi); | 
|---|
|  | 622 | phi(kk)= Fi; | 
|---|
|  | 623 | value(kk)= PixVal(kk+iring); | 
|---|
|  | 624 | } | 
|---|
|  | 625 | theta= Te; | 
|---|
|  | 626 | } | 
|---|
|  | 627 |  | 
|---|
| [2960] | 628 | /* | 
|---|
|  | 629 | \brief return information on a theta slice | 
|---|
|  | 630 | For a theta-slice with index 'index', return : | 
|---|
|  | 631 | the corresponding "theta" | 
|---|
|  | 632 | the corresponding "phi" for first pixel of the slice | 
|---|
|  | 633 | a vector containing the indices of the pixels of the slice | 
|---|
|  | 634 | (equally distributed in phi) | 
|---|
|  | 635 | a vector containing the corresponding values of pixels | 
|---|
|  | 636 | */ | 
|---|
| [764] | 637 | template <class T> | 
|---|
|  | 638 | void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const | 
|---|
|  | 639 |  | 
|---|
|  | 640 | { | 
|---|
|  | 641 |  | 
|---|
|  | 642 | if(index < 0 || index >= NbThetaSlices()) | 
|---|
|  | 643 | { | 
|---|
|  | 644 | throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); | 
|---|
|  | 645 |  | 
|---|
|  | 646 | } | 
|---|
|  | 647 |  | 
|---|
|  | 648 | int iring= Index(index,0); | 
|---|
|  | 649 | int lring  = NPhi(index); | 
|---|
|  | 650 |  | 
|---|
|  | 651 | pixelIndices.ReSize(lring); | 
|---|
|  | 652 | value.ReSize(lring); | 
|---|
|  | 653 | double Te= 0.; | 
|---|
|  | 654 | double Fi= 0.; | 
|---|
|  | 655 | for(int kk = 0; kk < lring; kk++) | 
|---|
|  | 656 | { | 
|---|
|  | 657 | pixelIndices(kk)=kk+iring ; | 
|---|
|  | 658 | value(kk)= PixVal(kk+iring); | 
|---|
|  | 659 | } | 
|---|
|  | 660 | PixThetaPhi(iring,theta,phi0); | 
|---|
|  | 661 | } | 
|---|
|  | 662 |  | 
|---|
|  | 663 |  | 
|---|
|  | 664 |  | 
|---|
|  | 665 |  | 
|---|
|  | 666 | template <class T> | 
|---|
|  | 667 | void SphereThetaPhi<T>::print(ostream& os) const | 
|---|
|  | 668 | { | 
|---|
| [2885] | 669 | if(this->mInfo_) os << "  DVList Info= " << *(this->mInfo_) << endl; | 
|---|
| [764] | 670 | // | 
|---|
|  | 671 | os << " NTheta_= " << NTheta_ << endl; | 
|---|
|  | 672 | os << " NPix_    = " << NPix_   << endl; | 
|---|
|  | 673 | os << " Omega_  =  " << Omega_   << endl; | 
|---|
|  | 674 |  | 
|---|
|  | 675 | os << " contenu de NPhi_ : "; | 
|---|
|  | 676 | int i; | 
|---|
|  | 677 | for(i=0; i < NTheta_; i++) | 
|---|
|  | 678 | { | 
|---|
|  | 679 | if(i%5 == 0) os << endl; | 
|---|
|  | 680 | os << NPhi_(i) <<", "; | 
|---|
|  | 681 | } | 
|---|
|  | 682 | os << endl; | 
|---|
|  | 683 |  | 
|---|
|  | 684 | os << " contenu de Theta_ : "; | 
|---|
|  | 685 | for(i=0; i < NTheta_+1; i++) | 
|---|
|  | 686 | { | 
|---|
|  | 687 | if(i%5 == 0) os << endl; | 
|---|
|  | 688 | os << Theta_(i) <<", "; | 
|---|
|  | 689 | } | 
|---|
|  | 690 | os << endl; | 
|---|
|  | 691 |  | 
|---|
|  | 692 | os << " contenu de TNphi_ : "; | 
|---|
|  | 693 | for(i=0; i < NTheta_+1; i++) | 
|---|
|  | 694 | { | 
|---|
|  | 695 | if(i%5 == 0) os << endl; | 
|---|
|  | 696 | os << TNphi_(i) <<", "; | 
|---|
|  | 697 | } | 
|---|
|  | 698 | os << endl; | 
|---|
|  | 699 |  | 
|---|
|  | 700 | os << " contenu de pixels : "; | 
|---|
|  | 701 | for(i=0; i < NPix_; i++) | 
|---|
|  | 702 | { | 
|---|
|  | 703 | if(i%5 == 0) os << endl; | 
|---|
|  | 704 | os <<  pixels_(i) <<", "; | 
|---|
|  | 705 | } | 
|---|
|  | 706 | os << endl; | 
|---|
|  | 707 | } | 
|---|
|  | 708 |  | 
|---|
| [1419] | 709 | //   ...... Operations de calcul  ...... | 
|---|
| [764] | 710 |  | 
|---|
| [1419] | 711 |  | 
|---|
|  | 712 | //! Fill a SphereThetaPhi with a constant value \b a | 
|---|
|  | 713 | template <class T> | 
|---|
|  | 714 | SphereThetaPhi<T>& SphereThetaPhi<T>::SetT(T a) | 
|---|
|  | 715 | { | 
|---|
|  | 716 | if (NbPixels() < 1) | 
|---|
|  | 717 | throw RangeCheckError("SphereThetaPhi<T>::SetT(T )  - SphereThetaPhi not dimensionned ! "); | 
|---|
|  | 718 | pixels_ = a; | 
|---|
|  | 719 | return (*this); | 
|---|
|  | 720 | } | 
|---|
|  | 721 |  | 
|---|
|  | 722 | /*! Add a constant value \b x to a SphereThetaPhi */ | 
|---|
|  | 723 | template <class T> | 
|---|
|  | 724 | SphereThetaPhi<T>& SphereThetaPhi<T>::Add(T a) | 
|---|
|  | 725 | { | 
|---|
|  | 726 | if (NbPixels()< 1) | 
|---|
|  | 727 | throw RangeCheckError("SphereThetaPhi<T>::Add(T )  - SphereThetaPhi not dimensionned ! "); | 
|---|
|  | 728 | pixels_ += a; | 
|---|
|  | 729 | return (*this); | 
|---|
|  | 730 | } | 
|---|
|  | 731 |  | 
|---|
|  | 732 | /*! Substract a constant value \b a to a SphereThetaPhi */ | 
|---|
|  | 733 | template <class T> | 
|---|
| [1624] | 734 | SphereThetaPhi<T>& SphereThetaPhi<T>::Sub(T a,bool fginv) | 
|---|
| [1419] | 735 | { | 
|---|
|  | 736 | if (NbPixels()< 1) | 
|---|
|  | 737 | throw RangeCheckError("SphereThetaPhi<T>::Sub(T )  - SphereThetaPhi not dimensionned ! "); | 
|---|
| [1624] | 738 | pixels_.Sub(a,fginv); | 
|---|
| [1419] | 739 | return (*this); | 
|---|
|  | 740 | } | 
|---|
|  | 741 |  | 
|---|
|  | 742 | /*! multiply a SphereThetaPhi by a constant value \b a */ | 
|---|
|  | 743 | template <class T> | 
|---|
|  | 744 | SphereThetaPhi<T>& SphereThetaPhi<T>::Mul(T a) | 
|---|
|  | 745 | { | 
|---|
|  | 746 | if (NbPixels()< 1) | 
|---|
|  | 747 | throw RangeCheckError("SphereThetaPhi<T>::Mul(T )  - SphereThetaPhi not dimensionned ! "); | 
|---|
|  | 748 | pixels_ *= a; | 
|---|
|  | 749 | return (*this); | 
|---|
|  | 750 | } | 
|---|
|  | 751 |  | 
|---|
|  | 752 | /*! divide a SphereThetaPhi by a constant value \b a */ | 
|---|
|  | 753 | template <class T> | 
|---|
|  | 754 | SphereThetaPhi<T>& SphereThetaPhi<T>::Div(T a) | 
|---|
|  | 755 | { | 
|---|
|  | 756 | if (NbPixels()< 1) | 
|---|
|  | 757 | throw RangeCheckError("SphereThetaPhi<T>::Div(T )  - SphereThetaPhi not dimensionned ! "); | 
|---|
|  | 758 | pixels_ /= a; | 
|---|
|  | 759 | return (*this); | 
|---|
|  | 760 | } | 
|---|
|  | 761 |  | 
|---|
|  | 762 | //  >>>> Operations avec 2nd membre de type SphereThetaPhi | 
|---|
|  | 763 | //! Add two SphereThetaPhi | 
|---|
|  | 764 |  | 
|---|
|  | 765 | template <class T> | 
|---|
|  | 766 | SphereThetaPhi<T>& SphereThetaPhi<T>::AddElt(const SphereThetaPhi<T>& a) | 
|---|
|  | 767 | { | 
|---|
|  | 768 | if (NbPixels()!= a.NbPixels()) | 
|---|
|  | 769 | { | 
|---|
|  | 770 | throw(SzMismatchError("SphereThetaPhi<T>::AddElt(const SphereThetaPhi<T>&) SizeMismatch")) ; | 
|---|
|  | 771 | } | 
|---|
|  | 772 | pixels_ += a.pixels_; | 
|---|
|  | 773 | return (*this); | 
|---|
|  | 774 | } | 
|---|
|  | 775 |  | 
|---|
|  | 776 | //! Substract two SphereThetaPhi | 
|---|
|  | 777 | template <class T> | 
|---|
|  | 778 | SphereThetaPhi<T>& SphereThetaPhi<T>::SubElt(const SphereThetaPhi<T>& a) | 
|---|
|  | 779 | { | 
|---|
|  | 780 | if (NbPixels()!= a.NbPixels()) | 
|---|
|  | 781 | { | 
|---|
|  | 782 | throw(SzMismatchError("SphereThetaPhi<T>::SubElt(const SphereThetaPhi<T>&) SizeMismatch")) ; | 
|---|
|  | 783 | } | 
|---|
|  | 784 | pixels_ -= a.pixels_; | 
|---|
|  | 785 | return (*this); | 
|---|
|  | 786 | } | 
|---|
|  | 787 |  | 
|---|
|  | 788 | //! Multiply two SphereThetaPhi (elements by elements) | 
|---|
|  | 789 | template <class T> | 
|---|
|  | 790 | SphereThetaPhi<T>& SphereThetaPhi<T>::MulElt(const SphereThetaPhi<T>& a) | 
|---|
|  | 791 | { | 
|---|
|  | 792 | if (NbPixels()!= a.NbPixels()) | 
|---|
|  | 793 | { | 
|---|
| [1551] | 794 | throw(SzMismatchError("SphereThetaPhi<T>::MulElt(const SphereThetaPhi<T>&) SizeMismatch")) ; | 
|---|
| [1419] | 795 | } | 
|---|
|  | 796 | pixels_ *= a.pixels_; | 
|---|
|  | 797 | return (*this); | 
|---|
|  | 798 | } | 
|---|
|  | 799 |  | 
|---|
| [1551] | 800 | //! Divide two SphereThetaPhi (elements by elements) - No protection for divide by 0 | 
|---|
|  | 801 | template <class T> | 
|---|
|  | 802 | SphereThetaPhi<T>& SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>& a) | 
|---|
|  | 803 | { | 
|---|
|  | 804 | if (NbPixels()!= a.NbPixels()) | 
|---|
|  | 805 | { | 
|---|
|  | 806 | throw(SzMismatchError("SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>&) SizeMismatch")) ; | 
|---|
|  | 807 | } | 
|---|
|  | 808 | pixels_ /= a.pixels_; | 
|---|
|  | 809 | return (*this); | 
|---|
|  | 810 | } | 
|---|
| [1419] | 811 |  | 
|---|
|  | 812 |  | 
|---|
| [1551] | 813 |  | 
|---|
| [764] | 814 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
| [2082] | 815 | #pragma define_template SphereThetaPhi<int_4> | 
|---|
| [764] | 816 | #pragma define_template SphereThetaPhi<r_8> | 
|---|
|  | 817 | #pragma define_template SphereThetaPhi<r_4> | 
|---|
|  | 818 | #pragma define_template SphereThetaPhi< complex<r_4> > | 
|---|
|  | 819 | #pragma define_template SphereThetaPhi< complex<r_8> > | 
|---|
|  | 820 | #endif | 
|---|
|  | 821 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) | 
|---|
| [2869] | 822 | namespace SOPHYA { | 
|---|
| [2082] | 823 | template class SphereThetaPhi<int_4>; | 
|---|
| [764] | 824 | template class SphereThetaPhi<r_8>; | 
|---|
|  | 825 | template class SphereThetaPhi<r_4>; | 
|---|
|  | 826 | template class SphereThetaPhi< complex<r_4> >; | 
|---|
|  | 827 | template class SphereThetaPhi< complex<r_8> >; | 
|---|
| [2869] | 828 | } | 
|---|
| [764] | 829 | #endif | 
|---|