LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
BVec.h
Go to the documentation of this file.
1 #ifndef MeasAlgoShapeletBVec_H
2 #define MeasAlgoShapeletBVec_H
3 
5 #include <complex>
6 #include <vector>
8 
9 namespace lsst {
10 namespace meas {
11 namespace algorithms {
12 namespace shapelet {
13 
14  class BVec;
15 
17  {
18  public:
19  virtual void assignTo(BVec& bvec) const = 0;
20  virtual int getOrder() const = 0;
21  virtual double getSigma() const = 0;
22  virtual ~AssignableToBVec() {}
23  };
24 
25  class BVec : public AssignableToBVec
26  {
27 
28  public :
29 
30  BVec(int order, double sigma) :
31  _order(order), _sigma(sigma),
32  _b((_order+1)*(_order+2)/2)
33  { _b.setZero(); }
34 
35  BVec(int order, double sigma, double* bvec) :
36  _order(order), _sigma(sigma),
37 #ifdef USE_TMV
38  _b((_order+1)*(_order+2)/2,bvec)
39 #else
40  _b(DVector::Map(bvec,(_order+1)*(_order+1)/2))
41 #endif
42  {}
43 
44  BVec(int order, double sigma, const DVector& bvec) :
45  _order(order), _sigma(sigma), _b(bvec)
46  {}
47 
48  BVec(const BVec& rhs) :
49  _order(rhs._order), _sigma(rhs._sigma), _b(rhs._b)
50  {}
51 
52  ~BVec() {}
53 
54  BVec& operator=(const AssignableToBVec& rhs);
55  BVec& operator=(const BVec& rhs);
56 
57  void assignTo(BVec& bvec) const;
58 
59  DVector& vec() { return _b; }
60  const DVector& vec() const { return _b; }
61  double& operator()(int i) { return _b(i); }
62  double operator()(int i) const { return _b(i); }
63 
64  int getOrder() const { return _order; }
65  double getSigma() const { return _sigma; }
66  const DVector& getValues() const { return _b; }
67  size_t size() const { return _b.size(); }
68 
69  void setSigma(double sigma) { _sigma = sigma; }
70 
71  // For this one v is allowed to be smaller than size,
72  // and the rest of the values are filled in as 0's.
73  void setValues(const DVector& v);
74 
75  // For this one, the sizes must match.
76  // b.setValues(v) is equivalent to b.vec() = v.
77  template <typename V>
78  void setValues(const V& v)
79  {
80  Assert(v.size() == size());
81  _b = v;
82  }
83 
84  void normalize() { _b /= _b(0); }
85 
86  void conjugateSelf();
87 
88  private :
89 
90  int _order;
91  double _sigma;
93 
94  };
95 
96  inline std::ostream& operator<<(std::ostream& os, const BVec& b)
97  { os << b.getOrder()<<" "<<b.getSigma()<<" "<<b.vec(); return os; }
98 
99  // NB: All of the following calculate and augment functions assume that
100  // the input matrix has already been zeroed before calling the function.
101  // This is because the sparsity of the matrices maintains its structure
102  // for different values of mu, g, theta, and z. So it is faster to
103  // just overwrite the locations that need to be written and skip the zeroes
104  // each time you call these functions.
105  void calculateZTransform(
106  std::complex<double> z, int order1, int order2, DMatrix& T);
107  inline void calculateZTransform(std::complex<double> z, int order, DMatrix& T)
108  { calculateZTransform(z,order,order,T); }
109  void augmentZTransformCols(std::complex<double> z, int order, DMatrix& T);
110  void applyZ(std::complex<double> z, BVec& b);
111 
112  void calculateMuTransform(double mu, int order1, int order2, DMatrix& D);
113  inline void calculateMuTransform(double mu, int order, DMatrix& D)
114  { calculateMuTransform(mu,order,order,D); }
115  void augmentMuTransformRows(double mu, int order, DMatrix& D);
116  void augmentMuTransformCols(double mu, int order, DMatrix& D);
117  void applyMu(double mu, BVec& b);
118 
120  double theta, int order1, int order2, DBandMatrix& R);
121  inline void calculateThetaTransform(double theta, int order, DBandMatrix& R)
122  { calculateThetaTransform(theta,order,order,R); }
123  void applyTheta(double theta, BVec& b);
124 
125  void calculateGTransform(
126  std::complex<double> g, int order1, int order2, DMatrix& S);
127  inline void calculateGTransform(std::complex<double> g, int order, DMatrix& S)
128  { calculateGTransform(g,order,order,S); }
129  void augmentGTransformCols(std::complex<double> g, int order, DMatrix& S);
130  void applyG(std::complex<double> g, BVec& b);
131 
133  const BVec& bpsf, int order1, int order2, double sigma, DMatrix& C);
134  inline void calculatePsfConvolve(
135  const BVec& bpsf, int order, double sigma, DMatrix& C)
136  { calculatePsfConvolve(bpsf,order,order,sigma,C); }
137  void applyPsf(const BVec& bpsf, BVec& b);
138 
139 }}}}
140 
141 #endif
void augmentMuTransformCols(double mu, int order, DMatrix &D)
Definition: BVec.cc:316
void assignTo(BVec &bvec) const
Definition: BVec.cc:51
virtual void assignTo(BVec &bvec) const =0
void applyPsf(const BVec &bpsf, BVec &b)
Definition: BVec.cc:895
BVec(int order, double sigma)
Definition: BVec.h:30
BVec(int order, double sigma, const DVector &bvec)
Definition: BVec.h:44
BVec & operator=(const AssignableToBVec &rhs)
Definition: BVec.cc:39
void calculateGTransform(std::complex< double > g, int order1, int order2, DMatrix &S)
Definition: BVec.cc:468
double operator()(int i) const
Definition: BVec.h:62
std::ostream & operator<<(std::ostream &os, const Position &pos)
Definition: Bounds.h:78
void applyG(std::complex< double > g, BVec &b)
Definition: BVec.cc:666
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:43
void augmentZTransformCols(std::complex< double > z, int order, DMatrix &T)
Definition: BVec.cc:156
void calculateZTransform(std::complex< double > z, int order1, int order2, DMatrix &T)
Definition: BVec.cc:84
const DVector & vec() const
Definition: BVec.h:60
void setValues(const DVector &v)
Definition: BVec.cc:57
void setSigma(double sigma)
Definition: BVec.h:69
void applyZ(std::complex< double > z, BVec &b)
Definition: BVec.cc:218
const DVector & getValues() const
Definition: BVec.h:66
void calculateThetaTransform(double theta, int order1, int order2, DBandMatrix &R)
Definition: BVec.cc:419
void augmentMuTransformRows(double mu, int order, DMatrix &D)
Definition: BVec.cc:366
void augmentGTransformCols(std::complex< double > g, int order, DMatrix &S)
Definition: BVec.cc:577
void applyMu(double mu, BVec &b)
Definition: BVec.cc:410
afw::table::Key< double > b
BVec(int order, double sigma, double *bvec)
Definition: BVec.h:35
void calculatePsfConvolve(const BVec &bpsf, int order1, int order2, double sigma, DMatrix &C)
Definition: BVec.cc:675
#define Assert(x)
Definition: dbg.h:73
void calculateMuTransform(double mu, int order1, int order2, DMatrix &D)
Definition: BVec.cc:227
void applyTheta(double theta, BVec &b)
Definition: BVec.cc:455