20#ifndef CCGSL_MULTIFIT_HPP
21#define CCGSL_MULTIFIT_HPP
24#include<gsl/gsl_multifit.h>
56 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
106#ifdef __GXX_EXPERIMENTAL_CXX0X__
113 std::swap(
count, v.count );
114 v.ccgsl_pointer =
nullptr;
232#ifdef __GXX_EXPERIMENTAL_CXX0X__
251 double*
chisq, linear_workspace& work ){
252 return gsl_multifit_linear( X.
get(), y.
get(), c.
get(), cov.
get(),
chisq, work.get() ); }
276 return gsl_multifit_linear_svd( X.
get(), work.
get() ); }
293 double*
chisq, linear_workspace& work ){
335 return gsl_multifit_wlinear_svd( X.
get(), w.
get(), y.
get(), tol, rank, c.
get(), cov.
get(),
336 chisq, work.get() ); }
358 return gsl_multifit_wlinear_svd( X.
get(), w.
get(), y.
get(), tol, &rank, c.
get(), cov.
get(),
382 return gsl_multifit_wlinear_usvd( X.
get(), w.
get(), y.
get(), tol, rank, c.
get(),
405 return gsl_multifit_wlinear_usvd( X.
get(), w.
get(), y.
get(), tol, &rank, c.
get(),
419 double* y,
double* y_err ){
420 return gsl_multifit_linear_est( x.
get(), c.
get(), cov.
get(), y, y_err ); }
432 double& y,
double& y_err ){
433 return gsl_multifit_linear_est( x.
get(), c.
get(), cov.
get(), &y, &y_err ); }
445 return gsl_multifit_linear_residuals( X.
get(), y.
get(), c.
get(), r.
get() ); }
475 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
525#ifdef __GXX_EXPERIMENTAL_CXX0X__
532 std::swap(
count, v.count );
533 v.ccgsl_pointer =
nullptr;
651#ifdef __GXX_EXPERIMENTAL_CXX0X__
669 return gsl_multifit_robust_tune( tune, w.
get() ); }
677 return gsl_multifit_robust_name( w.
get() ); }
685 return gsl_multifit_robust_statistics( w.
get() ); }
698 return gsl_multifit_robust( X.
get(), y.
get(), c.
get(), cov.
get(), w.
get() ); }
711 double* y,
double* y_err ){
712 return gsl_multifit_robust_est( x.
get(), c.
get(), cov.
get(), y, y_err ); }
724 double& y,
double& y_err ){
725 return gsl_multifit_robust_est( x.
get(), c.
get(), cov.
get(), &y, &y_err ); }
734 return gsl_multifit_linear_bsvd( X.
get(), work.
get() ); }
742 return gsl_multifit_linear_rank( tol, work.
get() ); }
756 return gsl_multifit_linear_solve( lambda, X.
get(), y.
get(), c.
get(),
757 &rnorm, &snorm, work.
get() ); }
769 return gsl_multifit_linear_applyW( X.
get(), w.
get(), y.
get(), WX.
get(), Wy.
get() ); }
782 return gsl_multifit_linear_stdform1( L.
get(), X.
get(), y.
get(), Xs.
get(), ys.
get(),
798 return gsl_multifit_linear_wstdform1( L.
get(), X.
get(), w.
get(), y.
get(), Xs.
get(),
807 return gsl_multifit_linear_L_decomp( L.
get(), tau.
get() ); }
823 return gsl_multifit_linear_stdform2( LQR.
get(), Ltau.
get(), X.
get(), y.
get(), Xs.
get(),
841 return gsl_multifit_linear_wstdform2( LQR.
get(), Ltau.
get(), X.
get(), w.
get(), y.
get(),
853 return gsl_multifit_linear_genform1( L.
get(), cs.
get(), c.
get(), work.
get() ); }
869 return gsl_multifit_linear_genform2( LQR.
get(), Ltau.
get(), X.
get(), y.
get(), cs.
get(),
887 return gsl_multifit_linear_wgenform2( LQR.
get(), Ltau.
get(), X.
get(), w.
get(), y.
get(),
897 inline int linear_lreg(
double const smin,
double const smax,
vector& reg_param ){
898 return gsl_multifit_linear_lreg( smin, smax, reg_param.
get() ); }
911 return gsl_multifit_linear_lcurve( y.
get(), reg_param.
get(), rho.
get(),
eta.get(),
925 return gsl_multifit_linear_lcurvature( y.
get(), reg_param.
get(), rho.
get(),
935 return gsl_multifit_linear_lcorner( rho.
get(),
eta.get(), idx ); }
944 return gsl_multifit_linear_lcorner( rho.
get(),
eta.get(), &idx ); }
953 return gsl_multifit_linear_lcorner2( reg_param.
get(),
eta.get(), idx ); }
962 return gsl_multifit_linear_lcorner2( reg_param.
get(),
eta.get(), &idx ); }
971 return gsl_multifit_linear_Lk( p, k, L.
get() ); }
983 return gsl_multifit_linear_Lsobolev( p, kmax, alpha.
get(), L.
get(), work.
get() ); }
1000 return gsl_multifit_wlinear_tsvd( X.
get(), w.
get(), y.
get(), tol, c.
get(), cov.
get(),
1008 return gsl_multifit_linear_rcond( w.
get() ); }
1020 return gsl_multifit_linear_gcv_init( y.
get(), reg_param.
get(), UTy.
get(),
1021 &delta0, work.
get() ); }
1033 return gsl_multifit_linear_gcv_curve( reg_param.
get(), UTy.
get(), delta0, G.
get(),
1047 return gsl_multifit_linear_gcv_min( reg_param.
get(), UTy.
get(), G.
get(), delta0,
1048 &lambda, work.
get() ); }
1059 return gsl_multifit_linear_gcv_calc( lambda, UTy.
get(), delta0, work.
get() ); }
1072 return gsl_multifit_linear_gcv( y.
get(), reg_param.
get(), G.
get(), &lambda, &G_lambda,
1081 return gsl_multifit_robust_maxiter( maxiter, w.
get() ); }
1090 return gsl_multifit_robust_weights( r.
get(), wts.
get(), w.
get() ); }
1102 return gsl_multifit_robust_residuals( X.
get(), y.
get(), c.
get(), r.
get(), w.
get() ); }
This class handles matrix objects as shared handles.
gsl_matrix * get()
Get the gsl_matrix.
Workspace for general linear least squares with p parameters and n observations.
gsl_multifit_linear_workspace * get() const
Get the gsl_multifit_linear_workspace.
linear_workspace & operator=(linear_workspace &&v)
Move operator.
linear_workspace & operator=(linear_workspace const &v)
The assignment operator.
bool operator>(linear_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator<=(linear_workspace const &v) const
A container needs to define an ordering for sorting.
linear_workspace()
The default constructor is only really useful for assigning to.
linear_workspace(size_t const n, size_t const p)
The default constructor creates a new linear_workspace with n elements.
linear_workspace(gsl_multifit_linear_workspace *v)
Could construct from a gsl_multifit_linear_workspace.
void swap(linear_workspace &v)
Swap two linear_workspace.
bool unique() const
Find if this is the only object sharing the gsl_multifit_linear_workspace.
gsl_multifit_linear_workspace * ccgsl_pointer
The shared pointer.
bool operator==(linear_workspace const &v) const
Two linear_workspace are identically equal if their elements are identical.
bool empty() const
Find if the linear_workspace is empty.
bool operator>=(linear_workspace const &v) const
A container needs to define an ordering for sorting.
size_t * count
The shared reference count.
linear_workspace(linear_workspace const &v)
The copy constructor.
~linear_workspace()
The destructor only deletes the pointers if count reaches zero.
linear_workspace(linear_workspace &&v)
Move constructor.
size_t use_count() const
Find how many linear_workspace objects share this pointer.
bool operator<(linear_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator!=(linear_workspace const &v) const
Two linear_workspace are different equal if their elements are not identical.
Workspace for robust linear least squares with p parameters and n observations.
bool operator<(robust_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator!=(robust_workspace const &v) const
Two robust_workspace are different equal if their elements are not identical.
size_t use_count() const
Find how many robust_workspace objects share this pointer.
bool unique() const
Find if this is the only object sharing the gsl_multifit_robust_workspace.
bool operator>(robust_workspace const &v) const
A container needs to define an ordering for sorting.
robust_workspace(robust_workspace &&v)
Move constructor.
bool empty() const
Find if the robust_workspace is empty.
robust_workspace(robust_type &T, size_t const n, size_t const p)
The default constructor creates a new robust_workspace with n elements.
~robust_workspace()
The destructor only deletes the pointers if count reaches zero.
bool operator==(robust_workspace const &v) const
Two robust_workspace are identically equal if their elements are identical.
bool operator<=(robust_workspace const &v) const
A container needs to define an ordering for sorting.
robust_workspace(robust_workspace const &v)
The copy constructor.
bool operator>=(robust_workspace const &v) const
A container needs to define an ordering for sorting.
robust_workspace & operator=(robust_workspace const &v)
The assignment operator.
gsl_multifit_robust_workspace * ccgsl_pointer
The shared pointer.
gsl_multifit_robust_workspace * get() const
Get the gsl_multifit_robust_workspace.
robust_workspace(gsl_multifit_robust_workspace *v)
Could construct from a gsl_multifit_robust_workspace.
void swap(robust_workspace &v)
Swap two robust_workspace.
robust_workspace & operator=(robust_workspace &&v)
Move operator.
size_t * count
The shared reference count.
robust_workspace()
The default constructor is only really useful for assigning to.
This class handles vector objects as shared handles.
gsl_vector * get()
Get the gsl_vector.
int linear_lcurve(vector const &y, vector ®_param, vector &rho, vector &eta, linear_workspace &work)
C++ version of gsl_multifit_linear_lcurve().
int linear_est(vector const &x, vector const &c, matrix const &cov, double &y, double &y_err)
C++ version of gsl_multifit_linear_est().
robust_stats robust_statistics(robust_workspace const &w)
C++ version of gsl_multifit_robust_statistics().
int linear_stdform2(matrix const &LQR, vector const &Ltau, matrix const &X, vector const &y, matrix &Xs, vector &ys, matrix &M, linear_workspace &work)
C++ version of gsl_multifit_linear_stdform2().
static robust_type robust_welsch()
Robust linear static type.
int linear_gcv_min(vector const ®_param, vector const &UTy, vector const &G, double const delta0, double &lambda, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_min().
int linear_solve(double const lambda, matrix const &X, vector const &y, vector &c, double &rnorm, double &snorm, linear_workspace &work)
C++ version of gsl_multifit_linear_solve().
int linear_gcv_curve(vector const ®_param, vector const &UTy, double const delta0, vector &G, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_curve().
int linear_lcorner(vector const &rho, vector const &eta, size_t *idx)
C++ version of gsl_multifit_linear_lcorner().
int linear_gcv(vector const &y, vector ®_param, vector &G, double &lambda, double &G_lambda, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv().
int linear_genform1(vector const &L, vector const &cs, vector &c, linear_workspace &work)
C++ version of gsl_multifit_linear_genform1().
int robust_est(vector const &x, vector const &c, matrix const &cov, double &y, double &y_err)
C++ version of gsl_multifit_robust_est().
int robust(matrix const &X, vector const &y, vector &c, matrix &cov, robust_workspace &w)
C++ version of gsl_multifit_robust().
double linear_rcond(linear_workspace const &w)
C++ version of gsl_multifit_linear_rcond().
int linear_bsvd(matrix const &X, linear_workspace &work)
C++ version of gsl_multifit_linear_bsvd().
int linear_L_decomp(matrix &L, vector &tau)
C++ version of gsl_multifit_linear_L_decomp().
int wlinear_svd(matrix const &X, vector const &w, vector const &y, double tol, size_t &rank, vector &c, matrix &cov, double &chisq, linear_workspace &work)
C++ version of gsl_multifit_wlinear_svd().
char const * robust_name(robust_workspace const &w)
C++ version of gsl_multifit_robust_name().
static robust_type robust_huber()
Robust linear static type.
static robust_type robust_cauchy()
Robust linear static type.
int wlinear_usvd(matrix const &X, vector const &w, vector const &y, double tol, size_t &rank, vector &c, matrix &cov, double &chisq, linear_workspace &work)
C++ version of gsl_multifit_wlinear_usvd().
int linear_residuals(matrix const &X, vector const &y, vector const &c, vector &r)
C++ version of gsl_multifit_linear_residuals().
int linear(matrix const &X, vector const &y, vector &c, matrix &cov, double &chisq, linear_workspace &work)
C++ version of gsl_multifit_linear().
gsl_multifit_robust_type const * robust_type
Convenience typedef.
int linear_lcurvature(vector const &y, vector const ®_param, vector const &rho, vector const &eta, vector &kappa, linear_workspace &work)
C++ version of gsl_multifit_linear_lcurvature().
double linear_gcv_calc(double const lambda, vector const &UTy, double const delta0, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_calc().
int wlinear(matrix const &X, vector const &w, vector const &y, vector &c, matrix &cov, double &chisq, linear_workspace &work)
C++ version of gsl_multifit_wlinear().
int linear_lcorner2(vector const ®_param, vector const &eta, size_t *idx)
C++ version of gsl_multifit_linear_lcorner2().
int linear_wgenform2(matrix const &LQR, vector const &Ltau, matrix const &X, vector const &w, vector const &y, vector const &cs, matrix const &M, vector &c, linear_workspace &work)
C++ version of gsl_multifit_linear_wgenform2().
int linear_applyW(matrix const &X, vector const &w, vector const &y, matrix &WX, vector &Wy)
C++ version of gsl_multifit_linear_applyW().
int linear_Lk(size_t const p, size_t const k, matrix &L)
C++ version of gsl_multifit_linear_Lk().
int robust_tune(double const tune, robust_workspace &w)
C++ version of gsl_multifit_robust_tune().
static robust_type robust_default()
Robust linear static type.
static robust_type robust_fair()
Robust linear static type.
int robust_maxiter(size_t const maxiter, robust_workspace &w)
C++ version of gsl_multifit_robust_maxiter().
static robust_type robust_bisquare()
Robust linear static type.
static robust_type robust_ols()
Robust linear static type.
size_t linear_rank(double const tol, linear_workspace const &work)
C++ version of gsl_multifit_linear_rank().
int wlinear_tsvd(matrix const &X, vector const &w, vector const &y, double const tol, vector &c, matrix &cov, double &chisq, size_t &rank, linear_workspace &work)
C++ version of gsl_multifit_wlinear_tsvd().
int linear_Lsobolev(size_t const p, size_t const kmax, vector const &alpha, matrix &L, linear_workspace &work)
C++ version of gsl_multifit_linear_Lsobolev().
int robust_weights(vector const &r, vector &wts, robust_workspace &w)
C++ version of gsl_multifit_robust_weights().
int linear_genform2(matrix const &LQR, vector const &Ltau, matrix const &X, vector const &y, vector const &cs, matrix const &M, vector &c, linear_workspace &work)
C++ version of gsl_multifit_linear_genform2().
gsl_multifit_robust_stats robust_stats
Convenience tyepdef.
int linear_stdform1(vector const &L, matrix const &X, vector const &y, matrix &Xs, vector &ys, linear_workspace &work)
C++ version of gsl_multifit_linear_stdform1().
int linear_wstdform1(vector const &L, matrix const &X, vector const &w, vector const &y, matrix &Xs, vector &ys, linear_workspace &work)
C++ version of gsl_multifit_linear_wstdform1().
int robust_residuals(matrix const &X, vector const &y, vector const &c, vector &r, robust_workspace &w)
C++ version of gsl_multifit_robust_residuals().
int linear_gcv_init(vector const &y, vector ®_param, vector &UTy, double &delta0, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_init().
int linear_svd(matrix const &X, linear_workspace &work)
C++ version of gsl_multifit_linear_svd().
int linear_wstdform2(matrix const &LQR, vector const &Ltau, matrix const &X, vector const &w, vector const &y, matrix &Xs, vector &ys, matrix &M, linear_workspace &work)
C++ version of gsl_multifit_linear_wstdform2().
double chisq(rng const &r, double const nu)
C++ version of gsl_ran_chisq().
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
double eta(double const s)
C++ version of gsl_sf_eta().
The gsl package creates an interface to the GNU Scientific Library for C++.