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

Last change on this file since 2885 was 2885, checked in by ansari, 20 years ago

Modifs (ajout this->) pour compilation avec g++ 4 (V >= 3.4) - Reza 4 Jan 2006

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