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

Last change on this file since 2442 was 2442, checked in by ansari, 22 years ago

Suppression include piocmplx.h ds .cc , Reza 03/10/2003

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