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
Public Member Functions | Private Attributes | List of all members
lsst::meas::algorithms::shapelet::CrudeSolver Class Reference
Inheritance diagram for lsst::meas::algorithms::shapelet::CrudeSolver:
lsst::meas::algorithms::shapelet::NLSolver

Public Member Functions

 CrudeSolver (const PixelList &pix, double sigma, double I1, DVector &xinit)
 
 ~CrudeSolver ()
 
void calculateF (const DVector &x, DVector &f) const
 
void calculateJ (const DVector &x, const DVector &f, DMatrix &df) const
 
- Public Member Functions inherited from lsst::meas::algorithms::shapelet::NLSolver
 NLSolver ()
 
virtual ~NLSolver ()
 
virtual bool solve (DVector &x, DVector &f) const
 
virtual void getCovariance (DMatrix &cov) const
 
virtual void getInverseCovariance (DMatrix &invcov) const
 
virtual bool testJ (const DVector &, DVector &, std::ostream *os=0, double relerr=0.) const
 
virtual void useHybrid ()
 
virtual void useDogleg ()
 
virtual void setFTol (double fTol)
 
virtual void setGTol (double gTol)
 
virtual void setTol (double fTol, double gTol)
 
virtual void setMinStep (double minStep)
 
virtual void setMaxIter (int maxIter)
 
virtual void setTau (double tau)
 
virtual void setDelta0 (double delta0)
 
virtual double getFTol ()
 
virtual double getGTol ()
 
virtual double getMinStep ()
 
virtual int getMaxIter ()
 
virtual double getTau ()
 
virtual double getDelta0 ()
 
virtual void setOutput (std::ostream &os)
 
virtual void useVerboseOutput ()
 
virtual void useExtraVerboseOutput ()
 
virtual void noUseVerboseOutput ()
 
virtual void useDirectH ()
 
virtual void useSVD ()
 
virtual void useCholesky ()
 
virtual void noUseDirectH ()
 
virtual void noUseSVD ()
 
virtual void noUseCholesky ()
 

Private Attributes

double _sigma
 
DVector _I
 
CDVector _Z
 
DDiagMatrix _W
 
CDVector _Z1
 
DVector _E
 
DVector _Rsq
 
DVector _f1
 
double _I1
 
DVector_xInit
 

Detailed Description

Definition at line 36 of file CrudeMeasure.cc.

Constructor & Destructor Documentation

lsst::meas::algorithms::shapelet::CrudeSolver::CrudeSolver ( const PixelList pix,
double  sigma,
double  I1,
DVector xinit 
)

Definition at line 62 of file CrudeMeasure.cc.

64  :
65  _sigma(sigma), _I(pix.size()), _Z(pix.size()), _W(pix.size()),
66  _Z1(pix.size()), _E(pix.size()), _Rsq(pix.size()), _f1(pix.size()),
67  _I1(I1), _xInit(xInit)
68  {
69  const int nPix = pix.size();
70  for(int i=0;i<nPix;++i) {
71  _Z(i) = pix[i].getPos();
72  _I(i) = pix[i].getFlux();
73  double mask = exp(-std::norm(pix[i].getPos()/_sigma)/2.);
74  _W(i) = pix[i].getInverseSigma()*mask;
75  }
76  }
T norm(const T &x)
Definition: Integrate.h:191
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:43
lsst::meas::algorithms::shapelet::CrudeSolver::~CrudeSolver ( )
inline

Definition at line 42 of file CrudeMeasure.cc.

42 {}

Member Function Documentation

void lsst::meas::algorithms::shapelet::CrudeSolver::calculateF ( const DVector x,
DVector f 
) const
virtual

Implements lsst::meas::algorithms::shapelet::NLSolver.

Definition at line 78 of file CrudeMeasure.cc.

79  {
80  Assert(x.size() == 4);
81  Assert(f.size() == _Z.size());
82 
83  if ((x-_xInit).TMV_subVector(0,3).TMV_normInf() > 2.) {
84  f = 2.e10*_f1;
85  f.TMV_addToAll(1.);
86  return;
87  }
88  if (x(3) < 0.) {
89  f = 2.e10*_f1;
90  f.TMV_addToAll(1.);
91  return;
92  }
93 
94  std::complex<double> zc(x[0],x[1]);
95  double mu = x[2];
96  double I0 = _I1 * x[3];
97 
98  double m0 = exp(-mu)/_sigma;
99  // z' = m*(z-zc)
100  // = m*z - m*zc
101  // x' = m x - m xc
102  // y' = m y - m yc
103  _Z1 = m0*_Z;
104  _Z1.TMV_addToAll(-m0*zc);
105 
106  const int nPix = _Z.size();
107  for(int i=0;i<nPix;++i) {
108  double rsq = std::norm(_Z1[i]);
109  _Rsq[i] = rsq;
110  _E[i] = exp(-rsq/2.);
111  }
112  _f1 = _I - I0*_E;
113 #ifdef USE_TMV
114  _f1 = _W * _f1;
115 #else
116  _f1.array() *= _W.array();
117 #endif
118  f = _f1;
119  }
T norm(const T &x)
Definition: Integrate.h:191
double x
#define Assert(x)
Definition: dbg.h:73
void lsst::meas::algorithms::shapelet::CrudeSolver::calculateJ ( const DVector x,
const DVector f,
DMatrix df 
) const
virtual

Reimplemented from lsst::meas::algorithms::shapelet::NLSolver.

Definition at line 121 of file CrudeMeasure.cc.

123  {
124  //xdbg<<"Start J\n";
125  Assert(x.size() == 4);
126  Assert(f.size() == _Z.size());
127  Assert(df.TMV_colsize() == _Z.size());
128  Assert(df.TMV_rowsize() == 4);
129 
130  double mu = x[2];
131  double I0 = _I1 * x[3];
132  double m0 = exp(-mu)/_sigma;
133 
134  // fi = Wi * (Ii - I0 Ei)
135  // dfi/dI0 = -Wi Ei
136  // dfi/dmu = Wi I0 Ei (x1 dx1/dxc + y1 dy1/dxc)
137  // likewise for the other 4
138  //
139  // dx1/dxc = -m dy1/dxc = 0
140  // dx1/dyc = 0 dy1/dyc = -m
141  // dx1/dmu = -x1 dy1/dmu = -y1
142  //
143 
144 #ifdef USE_TMV
145  df.col(0) = -m0 * _Z1.realPart();
146  df.col(1) = -m0 * _Z1.imagPart();
147  df.col(2) = -_Rsq;
148  df.colRange(0,3) = I0 * DiagMatrixViewOf(_E) * df.colRange(0,3);
149  df.col(3) = -_I1 * _E;
150  df = _W * df;
151 #else
152  df.col(0).array() = _W.array() * _Z1.real().array();
153  df.col(0).array() = _E.array() * df.col(0).array();
154  df.col(0) *= -m0 * I0;
155  df.col(1).array() = _W.array() * _Z1.imag().array();
156  df.col(1).array() = _E.array() * df.col(1).array();
157  df.col(1) *= -m0 * I0;
158  df.col(2).array() = _W.array() * _Rsq.array();
159  df.col(2).array() = _E.array() * df.col(2).array();
160  df.col(2) *= -I0;
161  df.col(3).array() = _W.array() * _E.array();
162  df.col(3) *= -_I1;
163 #endif
164  }
double x
#define Assert(x)
Definition: dbg.h:73

Member Data Documentation

DVector lsst::meas::algorithms::shapelet::CrudeSolver::_E
mutableprivate

Definition at line 55 of file CrudeMeasure.cc.

DVector lsst::meas::algorithms::shapelet::CrudeSolver::_f1
mutableprivate

Definition at line 57 of file CrudeMeasure.cc.

DVector lsst::meas::algorithms::shapelet::CrudeSolver::_I
private

Definition at line 51 of file CrudeMeasure.cc.

double lsst::meas::algorithms::shapelet::CrudeSolver::_I1
private

Definition at line 58 of file CrudeMeasure.cc.

DVector lsst::meas::algorithms::shapelet::CrudeSolver::_Rsq
mutableprivate

Definition at line 56 of file CrudeMeasure.cc.

double lsst::meas::algorithms::shapelet::CrudeSolver::_sigma
private

Definition at line 50 of file CrudeMeasure.cc.

DDiagMatrix lsst::meas::algorithms::shapelet::CrudeSolver::_W
private

Definition at line 53 of file CrudeMeasure.cc.

DVector& lsst::meas::algorithms::shapelet::CrudeSolver::_xInit
private

Definition at line 59 of file CrudeMeasure.cc.

CDVector lsst::meas::algorithms::shapelet::CrudeSolver::_Z
private

Definition at line 52 of file CrudeMeasure.cc.

CDVector lsst::meas::algorithms::shapelet::CrudeSolver::_Z1
mutableprivate

Definition at line 54 of file CrudeMeasure.cc.


The documentation for this class was generated from the following file: