31 #include "alm_powspec_tools.h" 51 : lmax(lmax_), mmax(mmax_), tval(2*lmax+1) {}
57 planck_assert(m<=l,
"mmax must not be larger than lmax");
58 return ((m+1)*(m+2))/2 + (m+1)*(l-m);
62 void Set (
int lmax_,
int mmax_)
70 int Lmax()
const {
return lmax; }
77 {
return ((m*(tval-m))>>1); }
81 {
return index_l0(m) +
l; }
86 {
return ((lmax==other.
lmax) && (mmax==other.
mmax)); }
108 void Set (
int lmax_,
int mmax_)
110 Alm_Base::Set(lmax_, mmax_);
111 alm.alloc(Num_Alms(lmax,
mmax));
117 void Set (arr<T> &data,
int lmax_,
int mmax_)
119 planck_assert (Num_Alms(lmax_,mmax_)==data.size(),
"wrong array size");
120 Alm_Base::Set(lmax_, mmax_);
131 {
for (tsize
m=0;
m<alm.size(); ++
m) alm[
m]*=factor; }
136 planck_assert(factor.size()>tsize(lmax),
137 "alm.ScaleL: factor array too short");
139 for (
int l=
m;
l<=lmax; ++
l)
140 operator()(
l,
m)*=factor[
l];
145 planck_assert(factor.size()>tsize(
mmax),
146 "alm.ScaleM: factor array too short");
148 for (
int l=
m;
l<=lmax; ++
l)
149 operator()(
l,
m)*=factor[
m];
153 template<
typename T2>
void Add (
const T2 &
num)
157 T &operator() (
int l,
int m)
158 {
return alm[
index(l,m)]; }
160 const T &operator() (
int l,
int m)
const 161 {
return alm[
index(l,m)]; }
166 {
return &alm[index_l0(m)]; }
170 {
return &alm[index_l0(m)]; }
174 const arr<T> &
Alms ()
const {
return alm; }
180 Alm_Base::swap(other);
187 planck_assert (conformable(other),
"A_lm are not conformable");
188 for (tsize
m=0;
m<alm.size(); ++
m)
189 alm[
m] += other.
alm[
m];
196 Alm (
int lmax_=0,
int mmax_=0)
203 Alm(const ::Alm<xcomplex<double> >& alm) {*
this = alm;}
213 for(
int l=0;
l<=Lmax();
l++) {
214 int limit = TMath::Min(
l,Mmax());
215 for (
int m=0;
m<=limit;
m++)
216 alm(
l,
m)=complex<double>((*this)(
l,
m).real(),(*this)(
l,
m).imag());
219 ::smoothWithGauss(alm, fwhm);
234 for(
int l=0;
l<=Lmax();
l++) {
235 int limit = TMath::Min(
l,Mmax());
236 for (
int m=0;
m<=limit;
m++)
237 alm(
l,
m)=complex<double>((*this)(
l,
m).real(),(*this)(
l,
m).imag());
239 rotate_alm(alm, psi, theta, phi);
245 Set(alm.Lmax(),alm.Mmax());
246 for(
int l=0;
l<=Lmax();
l++) {
247 int limit = TMath::Min(
l,Mmax());
248 for (
int m=0;
m<=limit;
m++)
249 (*
this)(
l,
m) = complex<double>( alm(
l,
m).real(), alm(
l,
m).imag());
void smoothWithGauss(double fwhm)
void ScaleM(const arr< T2 > &factor)
a(l,m) *= factor[m] for all l,m.
int Mmax() const
Returns the maximum m.
int index(int l, int m) const
Returns the array index of the specified coefficient.
void Add(const Alm_Template &other)
Adds all coefficients from other to the own coefficients.
void operator=(const ::Alm< xcomplex< double > > &alm)
void Set(int lmax_, int mmax_)
Deletes the old coefficients and allocates storage according to lmax and mmax.
void Set(arr< T > &data, int lmax_, int mmax_)
Deallocates the old coefficients and uses the content of data for storage.
void Set(int lmax_, int mmax_)
Changes the object's maximum quantum numbers to lmax and mmax.
void swap(Alm_Template &other)
Swaps the contents of two Alm_Template objects.
void Add(const T2 &num)
Adds num to a_00.
void SetToZero()
Sets all coefficients to zero.
int Lmax() const
Returns the maximum l.
Alm(const ::Alm< xcomplex< double > > &alm)
Alm_Template(int lmax_=0, int mmax_=0)
Constructs an Alm_Template object with given lmax and mmax.
Alm(int lmax_=0, int mmax_=0)
bool conformable(const Alm_Base &other) const
Returns true, if both objects have the same lmax and mmax, else false.
T * mstart(int m)
Returns a pointer for a given m, from which the address of a_lm can be obtained by adding l...
void ScaleL(const arr< T2 > &factor)
a(l,m) *= factor[l] for all l,m.
Alm_Base(int lmax_=0, int mmax_=0)
Constructs an Alm_Base object with given lmax and mmax.
Base class for calculating the storage layout of spherical harmonic coefficients. ...
void rotate(double psi, double theta, double phi)
int Num_Alms(int l, int m)
Returns the total number of coefficients for maximum quantum numbers l and m.
Class for storing spherical harmonic coefficients.
const T * mstart(int m) const
Returns a pointer for a given m, from which the address of a_lm can be obtained by adding l...
const arr< T > & Alms() const
Returns a constant reference to the a_lm data.
int index_l0(int m) const
Returns an array index for a given m, from which the index of a_lm can be obtained by adding l...
void Scale(const T2 &factor)
Multiplies all coefficients by factor.