| 188 |  | return; | 
| 189 |  | } | 
| 190 |  |  | 
| 191 | < | RealType CubicSpline::getValueAt(RealType t) { | 
| 191 | > | RealType CubicSpline::getValueAt(const RealType& t) { | 
| 192 |  | // Evaluate the spline at t using coefficients | 
| 193 |  | // | 
| 194 |  | // Input parameters | 
| 227 |  | } | 
| 228 |  |  | 
| 229 |  |  | 
| 230 | < | pair<RealType, RealType> CubicSpline::getValueAndDerivativeAt(RealType t) { | 
| 230 | > | void CubicSpline::getValueAt(const RealType& t, RealType& v) { | 
| 231 | > | // Evaluate the spline at t using coefficients | 
| 232 | > | // | 
| 233 | > | // Input parameters | 
| 234 | > | //   t = point where spline is to be evaluated. | 
| 235 | > | // Output: | 
| 236 | > | //   value of spline at t. | 
| 237 | > |  | 
| 238 | > | if (!generated) generate(); | 
| 239 | > |  | 
| 240 | > | assert(t > data_.front().first); | 
| 241 | > | assert(t < data_.back().first); | 
| 242 | > |  | 
| 243 | > | //  Find the interval ( x[j], x[j+1] ) that contains or is nearest | 
| 244 | > | //  to t. | 
| 245 | > |  | 
| 246 | > | if (isUniform) { | 
| 247 | > |  | 
| 248 | > | j = max(0, min(n-1, int((t - data_[0].first) * dx))); | 
| 249 | > |  | 
| 250 | > | } else { | 
| 251 | > |  | 
| 252 | > | j = n-1; | 
| 253 | > |  | 
| 254 | > | for (int i = 0; i < n; i++) { | 
| 255 | > | if ( t < data_[i].first ) { | 
| 256 | > | j = i-1; | 
| 257 | > | break; | 
| 258 | > | } | 
| 259 | > | } | 
| 260 | > | } | 
| 261 | > |  | 
| 262 | > | //  Evaluate the cubic polynomial. | 
| 263 | > |  | 
| 264 | > | dt = t - data_[j].first; | 
| 265 | > | v = data_[j].second + dt*(b[j] + dt*(c[j] + dt*d[j])); | 
| 266 | > | } | 
| 267 | > |  | 
| 268 | > |  | 
| 269 | > | pair<RealType, RealType> CubicSpline::getValueAndDerivativeAt(const RealType& t){ | 
| 270 |  | // Evaluate the spline and first derivative at t using coefficients | 
| 271 |  | // | 
| 272 |  | // Input parameters | 
| 303 |  | dt = t - data_[j].first; | 
| 304 |  |  | 
| 305 |  | yval = data_[j].second + dt*(b[j] + dt*(c[j] + dt*d[j])); | 
| 306 | < | dydx = b[j] + dt*(2.0 * c[j] + 3.0 * dt * d[j]); | 
| 307 | < |  | 
| 306 | > | dydx = b[j] + dt*(2.0 * c[j] + 3.0 * dt * d[j]); | 
| 307 | > |  | 
| 308 |  | return make_pair(yval, dydx); | 
| 309 |  | } | 
| 310 | + |  | 
| 311 | + | void CubicSpline::getValueAndDerivativeAt(const RealType& t, RealType& v, | 
| 312 | + | RealType &dv) { | 
| 313 | + | // Evaluate the spline and first derivative at t using coefficients | 
| 314 | + | // | 
| 315 | + | // Input parameters | 
| 316 | + | //   t = point where spline is to be evaluated. | 
| 317 | + |  | 
| 318 | + | if (!generated) generate(); | 
| 319 | + |  | 
| 320 | + | assert(t > data_.front().first); | 
| 321 | + | assert(t < data_.back().first); | 
| 322 | + |  | 
| 323 | + | //  Find the interval ( x[j], x[j+1] ) that contains or is nearest | 
| 324 | + | //  to t. | 
| 325 | + |  | 
| 326 | + | if (isUniform) { | 
| 327 | + |  | 
| 328 | + | j = max(0, min(n-1, int((t - data_[0].first) * dx))); | 
| 329 | + |  | 
| 330 | + | } else { | 
| 331 | + |  | 
| 332 | + | j = n-1; | 
| 333 | + |  | 
| 334 | + | for (int i = 0; i < n; i++) { | 
| 335 | + | if ( t < data_[i].first ) { | 
| 336 | + | j = i-1; | 
| 337 | + | break; | 
| 338 | + | } | 
| 339 | + | } | 
| 340 | + | } | 
| 341 | + |  | 
| 342 | + | //  Evaluate the cubic polynomial. | 
| 343 | + |  | 
| 344 | + | dt = t - data_[j].first; | 
| 345 | + |  | 
| 346 | + | v = data_[j].second + dt*(b[j] + dt*(c[j] + dt*d[j])); | 
| 347 | + | dv = b[j] + dt*(2.0 * c[j] + 3.0 * dt * d[j]); | 
| 348 | + | } |