| 81 | } |
| 82 | |
| 83 | int df(const VectorType& uv, JacobianType& fjac) |
| 84 | { |
| 85 | int m = Base::values(); |
| 86 | int n = Base::inputs(); |
| 87 | eigen_assert(n == uv.size()); |
| 88 | eigen_assert(fjac.rows() == m); |
| 89 | eigen_assert(fjac.cols() == n); |
| 90 | int half = n/2; |
| 91 | VectorBlock<const VectorType> u(uv, 0, half); |
| 92 | VectorBlock<const VectorType> v(uv, half, half); |
| 93 | Scalar coeff; |
| 94 | |
| 95 | //Derivatives with respect to u |
| 96 | for (int col = 0; col < half; col++) |
| 97 | { |
| 98 | for (int row = 0; row < m; row++) |
| 99 | { |
| 100 | coeff = (m_x(row)-col)/v(col); |
| 101 | coeff = coeff*coeff; |
| 102 | if(coeff < 1. && coeff > 0.) |
| 103 | { |
| 104 | fjac.coeffRef(row,col) = -(1-coeff)*(1-coeff); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | //Derivatives with respect to v |
| 109 | for (int col = 0; col < half; col++) |
| 110 | { |
| 111 | for (int row = 0; row < m; row++) |
| 112 | { |
| 113 | coeff = (m_x(row)-col)/v(col); |
| 114 | coeff = coeff*coeff; |
| 115 | if(coeff < 1. && coeff > 0.) |
| 116 | { |
| 117 | fjac.coeffRef(row,col+half) = -4 * (u(col)/v(col))*coeff*(1-coeff); |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | VectorType m_x, m_y; //Data points |
| 125 | }; |