lsst.afw  13.0-73-gb2a4e38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Function.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 /*
24  * Support routines for
25  */
27 
28 namespace lsst {
29 namespace afw {
30 namespace math {
31 
32 template <typename ReturnT>
33 std::vector<double> PolynomialFunction2<ReturnT>::getDFuncDParameters(double x, double y) const {
34  std::vector<double> coeffs(this->getNParameters());
35 
36  //
37  // Go through params order by order, evaluating x^r y^s; we do this by first evaluating
38  // y^s for a complete order, then going through again multiplying by x^r
39  //
40  int i0 = 0; // starting index for this order's coefficients
41  for (int order = 0; order <= this->_order; ++order) {
42  coeffs[i0] = 1;
43  double zn = y; // y^s
44  for (int i = 1; i <= order; ++i) {
45  coeffs[i0 + i] = zn;
46  zn *= y;
47  }
48 
49  zn = x; // x^r
50  for (int i = order - 1; i >= 0; --i) {
51  coeffs[i0 + i] *= zn;
52  zn *= x;
53  }
54 
55  i0 += order + 1;
56  }
57 
58  assert(i0 == static_cast<int>(coeffs.size()));
59 
60  return coeffs;
61 }
62 
64 #define INSTANTIATE(TYPE) \
65  template std::vector<double> PolynomialFunction2<TYPE>::getDFuncDParameters(double x, double y) const
66 
67 INSTANTIATE(double);
68 INSTANTIATE(float);
70 }
71 }
72 } // end lsst::afw::math
#define INSTANTIATE(TYPE)
virtual std::vector< double > getDFuncDParameters(double x, double y) const
Return the coefficients of the Function&#39;s parameters, evaluated at (x, y) I.e.
Definition: Function.cc:33
double x