source: Sophya/trunk/SophyaLib/SkyMap/spherethetaphi.cc@ 1551

Last change on this file since 1551 was 1551, checked in by ansari, 24 years ago

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

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