ReFRACtor
gsl_sm_lsp.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <fp_gsl_matrix.h>
3 #include <gsl_sm_lsp.h>
4 
5 
6 using namespace FullPhysics;
7 
8 
9 int gsl_sm_lsp_f(const gsl_vector *x, void *data, gsl_vector *f)
10 {
12  blitz::Array<double, 1> b_x(GslVector(const_cast<gsl_vector*>(x), false).blitz_array());
13  blitz::Array<double, 1> b_f(lsp->residual_x(b_x));
14  gsl_vector_memcpy(f, GslVector(b_f).gsl());
15 
16  return GSL_SUCCESS;
17 }
18 
19 int gsl_sm_lsp_j(const gsl_vector *x, void *data, gsl_matrix *j)
20 {
22  blitz::Array<double, 1> b_x(GslVector(const_cast<gsl_vector*>(x), false).blitz_array());
23  blitz::Array<double, 2> b_j(lsp->jacobian_x(b_x));
24  gsl_matrix_memcpy(j, GslMatrix(b_j).gsl());
25 
26  return GSL_SUCCESS;
27 }
28 
29 gsl_multifit_nlinear_fdf gsl_sm_get_lsp_fdf(const FullPhysics::NLLSProblem *lsp)
30 {
31  gsl_multifit_nlinear_fdf fdf;
32  fdf.f = gsl_sm_lsp_f;
33  fdf.df = gsl_sm_lsp_j; /* set to NULL for finite-difference Jacobian */
34  fdf.fvv = NULL; /* no geodesic acceleration */
35  fdf.n = lsp->residual_size();
36  fdf.p = lsp->expected_parameter_size();
37  fdf.params = (void *) lsp;
38  return fdf;
39 }
gsl_multifit_nlinear_fdf gsl_sm_get_lsp_fdf(const FullPhysics::NLLSProblem *lsp)
Definition: gsl_sm_lsp.cc:29
This provides thin wrapper around the GNU Scientific Library gsl_matrix.
Definition: fp_gsl_matrix.h:20
int gsl_sm_lsp_f(const gsl_vector *x, void *data, gsl_vector *f)
Definition: gsl_sm_lsp.cc:9
virtual blitz::Array< double, 1 > residual_x(const blitz::Array< double, 1 > &x)
The residual function with parameters.
Definition: nlls_problem.h:132
The base class for the Non-Linear Least Squares problem.
Definition: nlls_problem.h:54
int gsl_sm_lsp_j(const gsl_vector *x, void *data, gsl_matrix *j)
Definition: gsl_sm_lsp.cc:19
virtual blitz::Array< double, 2 > jacobian_x(const blitz::Array< double, 1 > &x)
The Jacobian function with parameters.
Definition: nlls_problem.h:186
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
This provides thin wrapper around the GNU Scientific Library gsl_vector.
Definition: fp_gsl_matrix.h:96
virtual int residual_size() const =0
The size of the residual returned by residual()
virtual int expected_parameter_size() const
Returns the expected size of the parameters.

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:08