ReFRACtor
gsl_lsp.cc
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <fp_gsl_matrix.h>
3 #include <gsl/gsl_vector.h>
4 #include <gsl/gsl_matrix.h>
5 #include <gsl/gsl_multifit_nlin.h>
6 
7 #include <nlls_problem.h>
8 
9 using namespace FullPhysics;
10 
11 
12 int gsl_lsp_f(const gsl_vector *x, void *data, gsl_vector *f)
13 {
14  FullPhysics::NLLSProblem *lsp_standard = (FullPhysics::NLLSProblem *) data;
15  blitz::Array<double, 1> b_x(GslVector(const_cast<gsl_vector*>(x), false).blitz_array());
16  blitz::Array<double, 1> b_f(lsp_standard->residual_x(b_x));
17  gsl_vector_memcpy(f, GslVector(b_f).gsl());
18 
19  return GSL_SUCCESS;
20 }
21 
22 int gsl_lsp_j(const gsl_vector *x, void *data, gsl_matrix *j)
23 {
24  FullPhysics::NLLSProblem *lsp_standard = (FullPhysics::NLLSProblem *) data;
25  blitz::Array<double, 1> b_x(GslVector(const_cast<gsl_vector*>(x), false).blitz_array());
26  blitz::Array<double, 2> b_j(lsp_standard->jacobian_x(b_x));
27  gsl_matrix_memcpy(j, GslMatrix(b_j).gsl());
28 
29  return GSL_SUCCESS;
30 }
31 
32 int gsl_lsp_fj(const gsl_vector *x, void *data, gsl_vector *f, gsl_matrix *j)
33 {
34  (void) gsl_lsp_f(x, data, f);
35  (void) gsl_lsp_j(x, data, j);
36  return GSL_SUCCESS;
37 }
38 
39 gsl_multifit_function_fdf gsl_get_lsp_fdf(const FullPhysics::NLLSProblem *lsp_standard)
40 {
41  gsl_multifit_function_fdf f;
42  f.p = lsp_standard->expected_parameter_size();
43  f.n = lsp_standard->residual_size();
44  f.f = &gsl_lsp_f;
45  f.df = &gsl_lsp_j;
46  f.fdf = &gsl_lsp_fj;
47  f.params = (void *) lsp_standard;
48  return f;
49 }
int gsl_lsp_fj(const gsl_vector *x, void *data, gsl_vector *f, gsl_matrix *j)
Definition: gsl_lsp.cc:32
This provides thin wrapper around the GNU Scientific Library gsl_matrix.
Definition: fp_gsl_matrix.h:20
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_lsp_j(const gsl_vector *x, void *data, gsl_matrix *j)
Definition: gsl_lsp.cc:22
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
gsl_multifit_function_fdf gsl_get_lsp_fdf(const FullPhysics::NLLSProblem *lsp_standard)
Definition: gsl_lsp.cc:39
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.
int gsl_lsp_f(const gsl_vector *x, void *data, gsl_vector *f)
Definition: gsl_lsp.cc:12

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