13 #include "alm_powspec_tools.h"
33 : lmax(lmax_), mmax(mmax_), tval(2*lmax+1) {}
39 planck_assert(m<=l,
"mmax must not be larger than lmax");
40 return ((m+1)*(m+2))/2 + (m+1)*(l-m);
44 void Set (
int lmax_,
int mmax_)
52 int Lmax()
const {
return lmax; }
59 {
return ((m*(tval-m))>>1); }
63 {
return index_l0(m) +
l; }
68 {
return ((lmax==other.
lmax) && (mmax==other.
mmax)); }
90 void Set (
int lmax_,
int mmax_)
92 Alm_Base::Set(lmax_, mmax_);
93 alm.alloc(Num_Alms(lmax,
mmax));
99 void Set (arr<T> &data,
int lmax_,
int mmax_)
101 planck_assert (Num_Alms(lmax_,mmax_)==data.size(),
"wrong array size");
102 Alm_Base::Set(lmax_, mmax_);
113 {
for (tsize
m=0;
m<alm.size(); ++
m) alm[
m]*=factor; }
118 planck_assert(factor.size()>tsize(lmax),
119 "alm.ScaleL: factor array too short");
121 for (
int l=
m;
l<=lmax; ++
l)
122 operator()(
l,
m)*=factor[
l];
127 planck_assert(factor.size()>tsize(
mmax),
128 "alm.ScaleM: factor array too short");
130 for (
int l=
m;
l<=lmax; ++
l)
131 operator()(
l,
m)*=factor[
m];
135 template<
typename T2>
void Add (
const T2 &
num)
139 T &operator() (
int l,
int m)
140 {
return alm[
index(l,m)]; }
142 const T &operator() (
int l,
int m)
const
143 {
return alm[
index(l,m)]; }
148 {
return &alm[index_l0(m)]; }
152 {
return &alm[index_l0(m)]; }
156 const arr<T> &
Alms ()
const {
return alm; }
162 Alm_Base::swap(other);
169 planck_assert (conformable(other),
"A_lm are not conformable");
170 for (tsize
m=0;
m<alm.size(); ++
m)
171 alm[
m] += other.
alm[
m];
178 Alm (
int lmax_=0,
int mmax_=0)
185 Alm(const ::Alm<xcomplex<double> >& alm) {*
this = alm;}
195 for(
int l=0;
l<=Lmax();
l++) {
196 int limit = TMath::Min(
l,Mmax());
197 for (
int m=0;
m<=limit;
m++)
198 alm(
l,
m)=complex<double>((*this)(
l,
m).real(),(*this)(
l,
m).imag());
201 ::smoothWithGauss(alm, fwhm);
216 for(
int l=0;
l<=Lmax();
l++) {
217 int limit = TMath::Min(
l,Mmax());
218 for (
int m=0;
m<=limit;
m++)
219 alm(
l,
m)=complex<double>((*this)(
l,
m).real(),(*this)(
l,
m).imag());
221 rotate_alm(alm, psi, theta, phi);
227 Set(alm.Lmax(),alm.Mmax());
228 for(
int l=0;
l<=Lmax();
l++) {
229 int limit = TMath::Min(
l,Mmax());
230 for (
int m=0;
m<=limit;
m++)
231 (*
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 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...
const arr< T > & Alms() const
Returns a constant reference to the a_lm data.
void Add(const Alm_Template &other)
Adds all coefficients from other to the own coefficients.
bool conformable(const Alm_Base &other) const
Returns true, if both objects have the same lmax and mmax, else false.
int Lmax() const
Returns the maximum l.
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 Mmax() const
Returns the maximum m.
Alm(const ::Alm< xcomplex< double > > &alm)
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...
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)
T * mstart(int m)
Returns a pointer for a given m, from which the address of a_lm can be obtained by adding l...
int index(int l, int m) const
Returns the array index of the specified coefficient.
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.
void Scale(const T2 &factor)
Multiplies all coefficients by factor.