00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "powspec.h"
00033
00034 using namespace std;
00035
00036 void PowSpec::dealloc()
00037 {
00038 tt_.dealloc();
00039 gg_.dealloc();
00040 cc_.dealloc();
00041 tg_.dealloc();
00042 tc_.dealloc();
00043 gc_.dealloc();
00044 }
00045
00046 void PowSpec::Set(arr<double> &tt_new)
00047 {
00048 dealloc();
00049 num_specs = 1;
00050 tt_.transfer(tt_new);
00051 for (int l=0; l<tt_.size(); ++l)
00052 planck_assert (tt_[l]>=0, "negative TT spectrum at l="+dataToString(l));
00053 }
00054
00055 void PowSpec::Set(arr<double> &tt_new, arr<double> &gg_new,
00056 arr<double> &cc_new, arr<double> &tg_new)
00057 {
00058 dealloc();
00059 num_specs = 4;
00060 tt_.transfer(tt_new);
00061 gg_.transfer(gg_new);
00062 cc_.transfer(cc_new);
00063 tg_.transfer(tg_new);
00064 planck_assert((tt_.size()==gg_.size()) && (tt_.size()==cc_.size())
00065 && (tt_.size()==tg_.size()), "PowSpec::Set: size mismatch");
00066 for (int l=0; l<tt_.size(); ++l)
00067 {
00068 planck_assert (tt_[l]>=0, "negative TT spectrum at l="+dataToString(l));
00069 planck_assert (gg_[l]>=0, "negative GG spectrum at l="+dataToString(l));
00070 planck_assert (cc_[l]>=0, "negative CC spectrum at l="+dataToString(l));
00071 planck_assert (abs(tg_[l]<=sqrt(tt_[l]*gg_[l])),
00072 "Inconsistent T, E and TxE terms at l="+dataToString(l));
00073 }
00074 }
00075
00076 void PowSpec::Smooth_with_Gauss (double fwhm)
00077 {
00078 planck_assert (num_specs<=4, "not yet implemented for num_specs>4");
00079 double sigma = fwhm*fwhm2sigma;
00080 double fact_pol = exp(2*sigma*sigma);
00081 for (int l=0; l<tt_.size(); ++l)
00082 {
00083 double f1 = exp(-.5*l*(l+1)*sigma*sigma);
00084 double f2 = f1*fact_pol;
00085 tt_[l] *= f1*f1;
00086 if (num_specs>1)
00087 {
00088 gg_[l] *= f2*f2;
00089 cc_[l] *= f2*f2;
00090 tg_[l] *= f1*f2;
00091 }
00092 }
00093 }