ROOT logo
// $Id: THealAlm.h,v 1.5 2008/07/11 23:57:48 oxon Exp $
// Author: Akira Okumura 2008/06/26

/*****************************************************************************
   Copyright (C) 2008-, Akira Okumura
   All rights reserved.

   This is a port of HEALPix C++ package to ROOT system.
   Original code is available at <http://healpix.jpl.nasa.gov> under GPL.
******************************************************************************/

#ifndef T_HEAL_ALM
#define T_HEAL_ALM

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// THealAlm                                                             //
//                                                                      //
// Coefficients of spherical harmonics functions.                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include <complex>
#include <vector>

#include "TObject.h"

#include "THealFFT.h"

class THealPix;
template<typename T> class THealAlm;
template<typename T> THealAlm<T> operator*(Double_t c1, const THealAlm<T>& ha1);
template<typename T> THealAlm<T> operator*(const THealAlm<T>& ha1, Double_t c1);
template<typename T> THealAlm<T> operator+(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
template<typename T> THealAlm<T> operator-(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
template<typename T> THealAlm<T> operator*(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
template<typename T> THealAlm<T> operator/(const THealAlm<T>& ha1, const THealAlm<T>& ha2);

template<typename T> class THealAlm : public TObject {
private:
  std::vector<std::complex<T> > fAlm;
  static std::complex<T> fgAlmDummy; //!
  static const std::complex<T> fgAlmDummyConst; //!
  Int_t fLmax; // Maximum of l
  Int_t fMmax; // Maximum of m
  Int_t fTval; //!to be used for faster calculation

protected:
  virtual void Copy(TObject& hanew) const;
  
public:
  THealAlm(Int_t lmax = 0, Int_t mmax = 0);
  THealAlm(const THealAlm<T>& ha);
  virtual ~THealAlm();
  virtual void  Add(const THealAlm<T>* ha1, Double_t c1 = 1);
  virtual void  Add(const THealAlm<T>* ha1, const THealAlm<T>* ha2, Double_t c1, Double_t c2);
  virtual void  Alm2Map(THealPix& map) const;
  virtual Int_t GetLmax() const {return fLmax;}
  virtual Int_t GetMmax() const {return fMmax;}
  virtual std::complex<T>* GetMstart(Int_t m) {return &(fAlm[(m*(fTval - m))>>1]);}
  virtual void  Divide(const THealAlm<T>* ha1);
  virtual void  Multiply(const THealAlm<T>* ha1);
  virtual void  ResetLM(Int_t lmax, Int_t mmax);
  virtual void  Scale(Double_t c1);
  virtual void  SetAlm(Int_t l, Int_t m, std::complex<T> a) {(*this)(l, m) = a;}
  virtual void  SetToZero();

        std::complex<T>& operator()(Int_t l, Int_t m);
  const std::complex<T>& operator()(Int_t l, Int_t m) const;

  THealAlm<T>& operator=(const THealAlm<T>& ha1);
  friend THealAlm<T>  operator*<>(Double_t c1, const THealAlm<T>& ha1);
  friend THealAlm<T>  operator*<>(const THealAlm<T>& ha1, Double_t c1);
  friend THealAlm<T>  operator+<>(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
  friend THealAlm<T>  operator-<>(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
  friend THealAlm<T>  operator*<>(const THealAlm<T>& ha1, const THealAlm<T>& ha2);
  friend THealAlm<T>  operator/<>(const THealAlm<T>& ha1, const THealAlm<T>& ha2);

  // Operators for PyROOT
  virtual THealAlm<T>  __add__(const THealAlm<T>& ha1) const;
  virtual THealAlm<T>  __div__(const THealAlm<T>& ha1) const;
  virtual THealAlm<T>  __mul__(Double_t c1) const;
  virtual THealAlm<T>  __mul__(const THealAlm<T>& ha1) const;
  virtual THealAlm<T>  __rmul__(Double_t c1) const;
  virtual THealAlm<T>  __sub__(const THealAlm<T>& ha1) const;

  ClassDef(THealAlm, 1);
};

template<typename T> inline THealAlm<T> operator*(const THealAlm<T>& ha1, Double_t c1)
{
  return operator*(c1, ha1);
}

#endif // T_HEAL_ALM
 THealAlm.h:1
 THealAlm.h:2
 THealAlm.h:3
 THealAlm.h:4
 THealAlm.h:5
 THealAlm.h:6
 THealAlm.h:7
 THealAlm.h:8
 THealAlm.h:9
 THealAlm.h:10
 THealAlm.h:11
 THealAlm.h:12
 THealAlm.h:13
 THealAlm.h:14
 THealAlm.h:15
 THealAlm.h:16
 THealAlm.h:17
 THealAlm.h:18
 THealAlm.h:19
 THealAlm.h:20
 THealAlm.h:21
 THealAlm.h:22
 THealAlm.h:23
 THealAlm.h:24
 THealAlm.h:25
 THealAlm.h:26
 THealAlm.h:27
 THealAlm.h:28
 THealAlm.h:29
 THealAlm.h:30
 THealAlm.h:31
 THealAlm.h:32
 THealAlm.h:33
 THealAlm.h:34
 THealAlm.h:35
 THealAlm.h:36
 THealAlm.h:37
 THealAlm.h:38
 THealAlm.h:39
 THealAlm.h:40
 THealAlm.h:41
 THealAlm.h:42
 THealAlm.h:43
 THealAlm.h:44
 THealAlm.h:45
 THealAlm.h:46
 THealAlm.h:47
 THealAlm.h:48
 THealAlm.h:49
 THealAlm.h:50
 THealAlm.h:51
 THealAlm.h:52
 THealAlm.h:53
 THealAlm.h:54
 THealAlm.h:55
 THealAlm.h:56
 THealAlm.h:57
 THealAlm.h:58
 THealAlm.h:59
 THealAlm.h:60
 THealAlm.h:61
 THealAlm.h:62
 THealAlm.h:63
 THealAlm.h:64
 THealAlm.h:65
 THealAlm.h:66
 THealAlm.h:67
 THealAlm.h:68
 THealAlm.h:69
 THealAlm.h:70
 THealAlm.h:71
 THealAlm.h:72
 THealAlm.h:73
 THealAlm.h:74
 THealAlm.h:75
 THealAlm.h:76
 THealAlm.h:77
 THealAlm.h:78
 THealAlm.h:79
 THealAlm.h:80
 THealAlm.h:81
 THealAlm.h:82
 THealAlm.h:83
 THealAlm.h:84
 THealAlm.h:85
 THealAlm.h:86
 THealAlm.h:87
 THealAlm.h:88
 THealAlm.h:89
 THealAlm.h:90
 THealAlm.h:91
 THealAlm.h:92
 THealAlm.h:93
 THealAlm.h:94
 THealAlm.h:95