ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
multifit.hpp
Go to the documentation of this file.
1/*
2 * $Id: multifit.hpp 309 2013-11-17 16:26:16Z jdl3 $
3 * Copyright (C) 2011, 2012, 2019, 2021 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_MULTIFIT_HPP
21#define CCGSL_MULTIFIT_HPP
22
23#include<cmath>
24#include<gsl/gsl_multifit.h>
25#include"vector.hpp"
26#include"matrix.hpp"
27
28namespace gsl {
33 namespace multifit {
38 public:
43 ccgsl_pointer = 0;
44 count = 0; // initially nullptr will do
45 }
46 // Refines random access container
47 // Refines assignable
53 explicit linear_workspace( size_t const n, size_t const p ){
54 ccgsl_pointer = gsl_multifit_linear_alloc( n, p );
55 // just plausibly we could allocate linear_workspace but not count
56 try { count = new size_t; } catch( std::bad_alloc& e ){
57 // try to tidy up before rethrowing
58 gsl_multifit_linear_free( ccgsl_pointer );
59 throw e;
60 }
61 *count = 1; // initially there is just one reference to ccgsl_pointer
62 }
69 explicit linear_workspace( gsl_multifit_linear_workspace* v ){
70 ccgsl_pointer = v;
71 // just plausibly we could fail to allocate count: no further action needed.
72 count = new size_t;
73 *count = 1; // initially there is just one reference to ccgsl_pointer
74 }
75 // copy constructor
81 count = v.count; if( count != 0 ) ++*count; }
82 // assignment operator
88 // first, possibly delete anything pointed to by this
89 if( count == 0 or --*count == 0 ){
90 if( ccgsl_pointer != 0 ) gsl_multifit_linear_free( ccgsl_pointer );
91 delete count;
92 } // Then copy
93 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
94 }
95 // destructor
100 if( count == 0 or --*count == 0 ){
101 // could have allocated null pointer
102 if( ccgsl_pointer != 0 ) gsl_multifit_linear_free( ccgsl_pointer );
103 delete count;
104 }
105 }
106#ifdef __GXX_EXPERIMENTAL_CXX0X__
112 : ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
113 std::swap( count, v.count );
114 v.ccgsl_pointer = nullptr;
115 }
122 linear_workspace( std::move( v ) ).swap( *this );
123 return *this;
124 }
125#endif
126 // Refines equality comparable
127 // == operator
134 bool operator==( linear_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
135 // != operator
142 bool operator!=( linear_workspace const& v ) const { return not operator==( v ); }
143 // Refines forward container
144 // Refines less than comparable
145 // operator<
154 bool operator<( linear_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
155 // operator>
164 bool operator>( linear_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
165 // operator<=
174 bool operator<=( linear_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
175 // operator>=
184 bool operator>=( linear_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
189 bool empty() const { return ccgsl_pointer == 0; }
190 // swap() --- should work even if sizes don't match
197 std::swap( ccgsl_pointer, v.ccgsl_pointer );
198 std::swap( count, v.count );
199 }
200 private:
204 gsl_multifit_linear_workspace* ccgsl_pointer;
208 size_t* count;
209 public:
210 // shared reference functions
215 gsl_multifit_linear_workspace* get() const { return ccgsl_pointer; }
221 bool unique() const { return count != 0 and *count == 1; }
226 size_t use_count() const { return count == 0 ? 0 : *count; }
232#ifdef __GXX_EXPERIMENTAL_CXX0X__
233 explicit
234#endif
235 operator bool() const { return ccgsl_pointer != 0; }
236 };
237
238#ifndef DOXYGEN_SKIP
250 inline int linear( matrix const& X, vector const& y, vector& c, matrix& cov,
251 double* chisq, linear_workspace& work ){
252 return gsl_multifit_linear( X.get(), y.get(), c.get(), cov.get(), chisq, work.get() ); }
253#endif
265 inline int linear( matrix const& X, vector const& y, vector& c, matrix& cov,
266 double& chisq, linear_workspace& work ){
267 return gsl_multifit_linear( X.get(), y.get(), c.get(), cov.get(), &chisq, work.get() ); }
275 inline int linear_svd( matrix const& X, linear_workspace& work ){
276 return gsl_multifit_linear_svd( X.get(), work.get() ); }
277
278#ifndef DOXYGEN_SKIP
292 inline int wlinear( matrix const& X, vector const& w, vector const& y, vector& c, matrix& cov,
293 double* chisq, linear_workspace& work ){
294 return gsl_multifit_wlinear( X.get(), w.get(), y.get(), c.get(), cov.get(), chisq,
295 work.get() ); }
296#endif
310 inline int wlinear( matrix const& X, vector const& w, vector const& y, vector& c, matrix& cov,
311 double& chisq, linear_workspace& work ){
312 return gsl_multifit_wlinear( X.get(), w.get(), y.get(), c.get(), cov.get(), &chisq,
313 work.get() ); }
314
315#ifndef DOXYGEN_SKIP
333 inline int wlinear_svd( matrix const& X, vector const& w, vector const& y, double tol, size_t* rank,
334 vector& c, matrix& cov, 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() ); }
337#endif
355 inline int wlinear_svd( matrix const& X, vector const& w, vector const& y, double tol,
356 size_t& rank,
357 vector& c, matrix& cov, double& chisq, linear_workspace& work ){
358 return gsl_multifit_wlinear_svd( X.get(), w.get(), y.get(), tol, &rank, c.get(), cov.get(),
359 &chisq, work.get() ); }
360
361#ifndef DOXYGEN_SKIP
379 inline int wlinear_usvd( matrix const& X, vector const& w, vector const& y, double tol,
380 size_t* rank,
381 vector& c, matrix& cov, double* chisq, linear_workspace& work ){
382 return gsl_multifit_wlinear_usvd( X.get(), w.get(), y.get(), tol, rank, c.get(),
383 cov.get(), chisq, work.get() ); }
384#endif
402 inline int wlinear_usvd( matrix const& X, vector const& w, vector const& y, double tol,
403 size_t& rank,
404 vector& c, matrix& cov, double& chisq, linear_workspace& work ){
405 return gsl_multifit_wlinear_usvd( X.get(), w.get(), y.get(), tol, &rank, c.get(),
406 cov.get(), &chisq, work.get() ); }
407
408#ifndef DOXYGEN_SKIP
418 inline int linear_est( vector const& x, vector const& c, matrix const& cov,
419 double* y, double* y_err ){
420 return gsl_multifit_linear_est( x.get(), c.get(), cov.get(), y, y_err ); }
421#endif
431 inline int linear_est( vector const& x, vector const& c, matrix const& cov,
432 double& y, double& y_err ){
433 return gsl_multifit_linear_est( x.get(), c.get(), cov.get(), &y, &y_err ); }
434
444 inline int linear_residuals( matrix const& X, vector const& y, vector const& c, vector& r ){
445 return gsl_multifit_linear_residuals( X.get(), y.get(), c.get(), r.get() ); }
446
450 typedef gsl_multifit_robust_type const* robust_type;
451
456 public:
461 ccgsl_pointer = 0;
462 count = 0; // initially nullptr will do
463 }
464 // Refines random access container
465 // Refines assignable
472 explicit robust_workspace( robust_type& T, size_t const n, size_t const p ){
473 ccgsl_pointer = gsl_multifit_robust_alloc( T, n, p );
474 // just plausibly we could allocate robust_workspace but not count
475 try { count = new size_t; } catch( std::bad_alloc& e ){
476 // try to tidy up before rethrowing
477 gsl_multifit_robust_free( ccgsl_pointer );
478 throw e;
479 }
480 *count = 1; // initially there is just one reference to ccgsl_pointer
481 }
488 explicit robust_workspace( gsl_multifit_robust_workspace* v ){
489 ccgsl_pointer = v;
490 // just plausibly we could fail to allocate count: no further action needed.
491 count = new size_t;
492 *count = 1; // initially there is just one reference to ccgsl_pointer
493 }
494 // copy constructor
500 count = v.count; if( count != 0 ) ++*count; }
501 // assignment operator
507 // first, possibly delete anything pointed to by this
508 if( count == 0 or --*count == 0 ){
509 if( ccgsl_pointer != 0 ) gsl_multifit_robust_free( ccgsl_pointer );
510 delete count;
511 } // Then copy
512 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
513 }
514 // destructor
519 if( count == 0 or --*count == 0 ){
520 // could have allocated null pointer
521 if( ccgsl_pointer != 0 ) gsl_multifit_robust_free( ccgsl_pointer );
522 delete count;
523 }
524 }
525#ifdef __GXX_EXPERIMENTAL_CXX0X__
531 : ccgsl_pointer( v.ccgsl_pointer ), count( nullptr ){
532 std::swap( count, v.count );
533 v.ccgsl_pointer = nullptr;
534 }
541 robust_workspace( std::move( v ) ).swap( *this );
542 return *this;
543 }
544#endif
545 // Refines equality comparable
546 // == operator
553 bool operator==( robust_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
554 // != operator
561 bool operator!=( robust_workspace const& v ) const { return not operator==( v ); }
562 // Refines forward container
563 // Refines less than comparable
564 // operator<
573 bool operator<( robust_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
574 // operator>
583 bool operator>( robust_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
584 // operator<=
593 bool operator<=( robust_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
594 // operator>=
603 bool operator>=( robust_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
608 bool empty() const { return ccgsl_pointer == 0; }
609 // swap() --- should work even if sizes don't match
616 std::swap( ccgsl_pointer, v.ccgsl_pointer );
617 std::swap( count, v.count );
618 }
619 private:
623 gsl_multifit_robust_workspace* ccgsl_pointer;
627 size_t* count;
628 public:
629 // shared reference functions
634 gsl_multifit_robust_workspace* get() const { return ccgsl_pointer; }
640 bool unique() const { return count != 0 and *count == 1; }
645 size_t use_count() const { return count == 0 ? 0 : *count; }
651#ifdef __GXX_EXPERIMENTAL_CXX0X__
652 explicit
653#endif
654 operator bool() const { return ccgsl_pointer != 0; }
655 };
656
660 typedef gsl_multifit_robust_stats robust_stats;
661
668 inline int robust_tune( double const tune, robust_workspace& w ){
669 return gsl_multifit_robust_tune( tune, w.get() ); }
670
676 inline char const* robust_name( robust_workspace const& w ){
677 return gsl_multifit_robust_name( w.get() ); }
678
685 return gsl_multifit_robust_statistics( w.get() ); }
686
696 inline int robust( matrix const& X, vector const& y, vector& c, matrix& cov,
697 robust_workspace& w ){
698 return gsl_multifit_robust( X.get(), y.get(), c.get(), cov.get(), w.get() ); }
699
700#ifndef DOXYGEN_SKIP
710 inline int robust_est( vector const& x, vector const& c, matrix const& cov,
711 double* y, double* y_err ){
712 return gsl_multifit_robust_est( x.get(), c.get(), cov.get(), y, y_err ); }
713#endif
723 inline int robust_est( vector const& x, vector const& c, matrix const& cov,
724 double& y, double& y_err ){
725 return gsl_multifit_robust_est( x.get(), c.get(), cov.get(), &y, &y_err ); }
726
733 inline int linear_bsvd( matrix const& X, linear_workspace& work ){
734 return gsl_multifit_linear_bsvd( X.get(), work.get() ); }
741 inline size_t linear_rank( double const tol, linear_workspace const& work ){
742 return gsl_multifit_linear_rank( tol, work.get() ); }
754 inline int linear_solve( double const lambda, matrix const& X, vector const& y,
755 vector& c, double& rnorm, double& snorm, linear_workspace& work ){
756 return gsl_multifit_linear_solve( lambda, X.get(), y.get(), c.get(),
757 &rnorm, &snorm, work.get() ); }
767 inline int linear_applyW( matrix const& X, vector const& w, vector const& y,
768 matrix& WX, vector& Wy ){
769 return gsl_multifit_linear_applyW( X.get(), w.get(), y.get(), WX.get(), Wy.get() ); }
780 inline int linear_stdform1( vector const& L, matrix const& X, vector const& y,
781 matrix& Xs, vector& ys, linear_workspace& work ){
782 return gsl_multifit_linear_stdform1( L.get(), X.get(), y.get(), Xs.get(), ys.get(),
783 work.get() ); }
795 inline int linear_wstdform1( vector const& L, matrix const& X, vector const& w,
796 vector const& y, matrix& Xs, vector& ys,
797 linear_workspace& work ){
798 return gsl_multifit_linear_wstdform1( L.get(), X.get(), w.get(), y.get(), Xs.get(),
799 ys.get(), work.get() ); }
806 inline int linear_L_decomp( matrix& L, vector& tau ){
807 return gsl_multifit_linear_L_decomp( L.get(), tau.get() ); }
820 inline int linear_stdform2( matrix const& LQR, vector const& Ltau, matrix const& X,
821 vector const& y, matrix& Xs, vector& ys, matrix& M,
822 linear_workspace& work ){
823 return gsl_multifit_linear_stdform2( LQR.get(), Ltau.get(), X.get(), y.get(), Xs.get(),
824 ys.get(), M.get(), work.get() ); }
838 inline int linear_wstdform2( matrix const& LQR, vector const& Ltau, matrix const& X,
839 vector const& w, vector const& y, matrix& Xs, vector& ys,
840 matrix& M, linear_workspace& work ){
841 return gsl_multifit_linear_wstdform2( LQR.get(), Ltau.get(), X.get(), w.get(), y.get(),
842 Xs.get(), ys.get(), M.get(), work.get() ); }
851 inline int linear_genform1( vector const& L, vector const& cs, vector& c,
852 linear_workspace& work ){
853 return gsl_multifit_linear_genform1( L.get(), cs.get(), c.get(), work.get() ); }
866 inline int linear_genform2( matrix const& LQR, vector const& Ltau, matrix const& X,
867 vector const& y, vector const& cs, matrix const& M,
868 vector& c, linear_workspace& work ){
869 return gsl_multifit_linear_genform2( LQR.get(), Ltau.get(), X.get(), y.get(), cs.get(),
870 M.get(), c.get(), work.get() ); }
884 inline int linear_wgenform2( matrix const& LQR, vector const& Ltau, matrix const& X,
885 vector const& w, vector const& y, vector const& cs,
886 matrix const& M, vector& c, linear_workspace& work ){
887 return gsl_multifit_linear_wgenform2( LQR.get(), Ltau.get(), X.get(), w.get(), y.get(),
888 cs.get(), M.get(), c.get(), work.get() ); }
889#ifndef DOXYGEN_SKIP
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() ); }
899#endif
909 inline int linear_lcurve( vector const& y, vector& reg_param, vector& rho, vector& eta,
910 linear_workspace& work ){
911 return gsl_multifit_linear_lcurve( y.get(), reg_param.get(), rho.get(), eta.get(),
912 work.get() ); }
923 inline int linear_lcurvature( vector const& y, vector const& reg_param, vector const& rho,
924 vector const& eta, vector& kappa, linear_workspace& work ){
925 return gsl_multifit_linear_lcurvature( y.get(), reg_param.get(), rho.get(),
926 eta.get(), kappa.get(), work.get() ); }
934 inline int linear_lcorner( vector const& rho, vector const& eta, size_t* idx ){
935 return gsl_multifit_linear_lcorner( rho.get(), eta.get(), idx ); }
943 inline int linear_lcorner( vector const& rho, vector const& eta, size_t& idx ){
944 return gsl_multifit_linear_lcorner( rho.get(), eta.get(), &idx ); }
952 inline int linear_lcorner2( vector const& reg_param, vector const& eta, size_t* idx ){
953 return gsl_multifit_linear_lcorner2( reg_param.get(), eta.get(), idx ); }
961 inline int linear_lcorner2( vector const& reg_param, vector const& eta, size_t& idx ){
962 return gsl_multifit_linear_lcorner2( reg_param.get(), eta.get(), &idx ); }
970 inline int linear_Lk( size_t const p, size_t const k, matrix& L ){
971 return gsl_multifit_linear_Lk( p, k, L.get() ); }
981 inline int linear_Lsobolev( size_t const p, size_t const kmax, vector const& alpha,
982 matrix& L, linear_workspace& work ){
983 return gsl_multifit_linear_Lsobolev( p, kmax, alpha.get(), L.get(), work.get() ); }
997 inline int wlinear_tsvd( matrix const& X, vector const& w, vector const& y,
998 double const tol, vector& c, matrix& cov, double& chisq,
999 size_t& rank, linear_workspace& work ){
1000 return gsl_multifit_wlinear_tsvd( X.get(), w.get(), y.get(), tol, c.get(), cov.get(),
1001 &chisq, &rank, work.get() ); }
1007 inline double linear_rcond( linear_workspace const& w ){
1008 return gsl_multifit_linear_rcond( w.get() ); }
1018 inline int linear_gcv_init( vector const& y, vector& reg_param, vector& UTy,
1019 double& delta0, linear_workspace& work ){
1020 return gsl_multifit_linear_gcv_init( y.get(), reg_param.get(), UTy.get(),
1021 &delta0, work.get() ); }
1031 inline int linear_gcv_curve( vector const& reg_param, vector const& UTy,
1032 double const delta0, vector& G, linear_workspace& work ){
1033 return gsl_multifit_linear_gcv_curve( reg_param.get(), UTy.get(), delta0, G.get(),
1034 work.get() ); }
1045 inline int linear_gcv_min( vector const& reg_param, vector const& UTy, vector const& G,
1046 double const delta0, double& lambda, linear_workspace& work ){
1047 return gsl_multifit_linear_gcv_min( reg_param.get(), UTy.get(), G.get(), delta0,
1048 &lambda, work.get() ); }
1057 inline double linear_gcv_calc( double const lambda, vector const& UTy, double const delta0,
1058 linear_workspace& work ){
1059 return gsl_multifit_linear_gcv_calc( lambda, UTy.get(), delta0, work.get() ); }
1070 inline int linear_gcv( vector const& y, vector& reg_param, vector& G, double& lambda,
1071 double& G_lambda, linear_workspace& work ){
1072 return gsl_multifit_linear_gcv( y.get(), reg_param.get(), G.get(), &lambda, &G_lambda,
1073 work.get() ); }
1080 inline int robust_maxiter( size_t const maxiter, robust_workspace& w ){
1081 return gsl_multifit_robust_maxiter( maxiter, w.get() ); }
1089 inline int robust_weights( vector const& r, vector& wts, robust_workspace& w ){
1090 return gsl_multifit_robust_weights( r.get(), wts.get(), w.get() ); }
1100 inline int robust_residuals( matrix const& X, vector const& y, vector const& c,
1101 vector& r, robust_workspace& w ){
1102 return gsl_multifit_robust_residuals( X.get(), y.get(), c.get(), r.get(), w.get() ); }
1107 inline static robust_type robust_default(){ return gsl_multifit_robust_default; }
1112 inline static robust_type robust_bisquare(){ return gsl_multifit_robust_bisquare; }
1117 inline static robust_type robust_cauchy(){ return gsl_multifit_robust_cauchy; }
1122 inline static robust_type robust_fair(){ return gsl_multifit_robust_fair; }
1127 inline static robust_type robust_huber(){ return gsl_multifit_robust_huber; }
1132 inline static robust_type robust_ols(){ return gsl_multifit_robust_ols; }
1137 inline static robust_type robust_welsch(){ return gsl_multifit_robust_welsch; }
1138 }
1139}
1140#endif
This class handles matrix objects as shared handles.
Definition: matrix.hpp:72
gsl_matrix * get()
Get the gsl_matrix.
Definition: matrix.hpp:1207
Workspace for general linear least squares with p parameters and n observations.
Definition: multifit.hpp:37
gsl_multifit_linear_workspace * get() const
Get the gsl_multifit_linear_workspace.
Definition: multifit.hpp:215
linear_workspace & operator=(linear_workspace &&v)
Move operator.
Definition: multifit.hpp:121
linear_workspace & operator=(linear_workspace const &v)
The assignment operator.
Definition: multifit.hpp:87
bool operator>(linear_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:164
bool operator<=(linear_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:174
linear_workspace()
The default constructor is only really useful for assigning to.
Definition: multifit.hpp:42
linear_workspace(size_t const n, size_t const p)
The default constructor creates a new linear_workspace with n elements.
Definition: multifit.hpp:53
linear_workspace(gsl_multifit_linear_workspace *v)
Could construct from a gsl_multifit_linear_workspace.
Definition: multifit.hpp:69
void swap(linear_workspace &v)
Swap two linear_workspace.
Definition: multifit.hpp:196
bool unique() const
Find if this is the only object sharing the gsl_multifit_linear_workspace.
Definition: multifit.hpp:221
gsl_multifit_linear_workspace * ccgsl_pointer
The shared pointer.
Definition: multifit.hpp:204
bool operator==(linear_workspace const &v) const
Two linear_workspace are identically equal if their elements are identical.
Definition: multifit.hpp:134
bool empty() const
Find if the linear_workspace is empty.
Definition: multifit.hpp:189
bool operator>=(linear_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:184
size_t * count
The shared reference count.
Definition: multifit.hpp:208
linear_workspace(linear_workspace const &v)
The copy constructor.
Definition: multifit.hpp:80
~linear_workspace()
The destructor only deletes the pointers if count reaches zero.
Definition: multifit.hpp:99
linear_workspace(linear_workspace &&v)
Move constructor.
Definition: multifit.hpp:111
size_t use_count() const
Find how many linear_workspace objects share this pointer.
Definition: multifit.hpp:226
bool operator<(linear_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:154
bool operator!=(linear_workspace const &v) const
Two linear_workspace are different equal if their elements are not identical.
Definition: multifit.hpp:142
Workspace for robust linear least squares with p parameters and n observations.
Definition: multifit.hpp:455
bool operator<(robust_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:573
bool operator!=(robust_workspace const &v) const
Two robust_workspace are different equal if their elements are not identical.
Definition: multifit.hpp:561
size_t use_count() const
Find how many robust_workspace objects share this pointer.
Definition: multifit.hpp:645
bool unique() const
Find if this is the only object sharing the gsl_multifit_robust_workspace.
Definition: multifit.hpp:640
bool operator>(robust_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:583
robust_workspace(robust_workspace &&v)
Move constructor.
Definition: multifit.hpp:530
bool empty() const
Find if the robust_workspace is empty.
Definition: multifit.hpp:608
robust_workspace(robust_type &T, size_t const n, size_t const p)
The default constructor creates a new robust_workspace with n elements.
Definition: multifit.hpp:472
~robust_workspace()
The destructor only deletes the pointers if count reaches zero.
Definition: multifit.hpp:518
bool operator==(robust_workspace const &v) const
Two robust_workspace are identically equal if their elements are identical.
Definition: multifit.hpp:553
bool operator<=(robust_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:593
robust_workspace(robust_workspace const &v)
The copy constructor.
Definition: multifit.hpp:499
bool operator>=(robust_workspace const &v) const
A container needs to define an ordering for sorting.
Definition: multifit.hpp:603
robust_workspace & operator=(robust_workspace const &v)
The assignment operator.
Definition: multifit.hpp:506
gsl_multifit_robust_workspace * ccgsl_pointer
The shared pointer.
Definition: multifit.hpp:623
gsl_multifit_robust_workspace * get() const
Get the gsl_multifit_robust_workspace.
Definition: multifit.hpp:634
robust_workspace(gsl_multifit_robust_workspace *v)
Could construct from a gsl_multifit_robust_workspace.
Definition: multifit.hpp:488
void swap(robust_workspace &v)
Swap two robust_workspace.
Definition: multifit.hpp:615
robust_workspace & operator=(robust_workspace &&v)
Move operator.
Definition: multifit.hpp:540
size_t * count
The shared reference count.
Definition: multifit.hpp:627
robust_workspace()
The default constructor is only really useful for assigning to.
Definition: multifit.hpp:460
This class handles vector objects as shared handles.
Definition: vector.hpp:74
gsl_vector * get()
Get the gsl_vector.
Definition: vector.hpp:1320
int linear_lcurve(vector const &y, vector &reg_param, vector &rho, vector &eta, linear_workspace &work)
C++ version of gsl_multifit_linear_lcurve().
Definition: multifit.hpp:909
int linear_est(vector const &x, vector const &c, matrix const &cov, double &y, double &y_err)
C++ version of gsl_multifit_linear_est().
Definition: multifit.hpp:431
robust_stats robust_statistics(robust_workspace const &w)
C++ version of gsl_multifit_robust_statistics().
Definition: multifit.hpp:684
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().
Definition: multifit.hpp:820
static robust_type robust_welsch()
Robust linear static type.
Definition: multifit.hpp:1137
int linear_gcv_min(vector const &reg_param, vector const &UTy, vector const &G, double const delta0, double &lambda, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_min().
Definition: multifit.hpp:1045
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().
Definition: multifit.hpp:754
int linear_gcv_curve(vector const &reg_param, vector const &UTy, double const delta0, vector &G, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_curve().
Definition: multifit.hpp:1031
int linear_lcorner(vector const &rho, vector const &eta, size_t *idx)
C++ version of gsl_multifit_linear_lcorner().
Definition: multifit.hpp:934
int linear_gcv(vector const &y, vector &reg_param, vector &G, double &lambda, double &G_lambda, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv().
Definition: multifit.hpp:1070
int linear_genform1(vector const &L, vector const &cs, vector &c, linear_workspace &work)
C++ version of gsl_multifit_linear_genform1().
Definition: multifit.hpp:851
int robust_est(vector const &x, vector const &c, matrix const &cov, double &y, double &y_err)
C++ version of gsl_multifit_robust_est().
Definition: multifit.hpp:723
int robust(matrix const &X, vector const &y, vector &c, matrix &cov, robust_workspace &w)
C++ version of gsl_multifit_robust().
Definition: multifit.hpp:696
double linear_rcond(linear_workspace const &w)
C++ version of gsl_multifit_linear_rcond().
Definition: multifit.hpp:1007
int linear_bsvd(matrix const &X, linear_workspace &work)
C++ version of gsl_multifit_linear_bsvd().
Definition: multifit.hpp:733
int linear_L_decomp(matrix &L, vector &tau)
C++ version of gsl_multifit_linear_L_decomp().
Definition: multifit.hpp:806
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().
Definition: multifit.hpp:355
char const * robust_name(robust_workspace const &w)
C++ version of gsl_multifit_robust_name().
Definition: multifit.hpp:676
static robust_type robust_huber()
Robust linear static type.
Definition: multifit.hpp:1127
static robust_type robust_cauchy()
Robust linear static type.
Definition: multifit.hpp:1117
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().
Definition: multifit.hpp:402
int linear_residuals(matrix const &X, vector const &y, vector const &c, vector &r)
C++ version of gsl_multifit_linear_residuals().
Definition: multifit.hpp:444
int linear(matrix const &X, vector const &y, vector &c, matrix &cov, double &chisq, linear_workspace &work)
C++ version of gsl_multifit_linear().
Definition: multifit.hpp:265
gsl_multifit_robust_type const * robust_type
Convenience typedef.
Definition: multifit.hpp:450
int linear_lcurvature(vector const &y, vector const &reg_param, vector const &rho, vector const &eta, vector &kappa, linear_workspace &work)
C++ version of gsl_multifit_linear_lcurvature().
Definition: multifit.hpp:923
double linear_gcv_calc(double const lambda, vector const &UTy, double const delta0, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_calc().
Definition: multifit.hpp:1057
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().
Definition: multifit.hpp:310
int linear_lcorner2(vector const &reg_param, vector const &eta, size_t *idx)
C++ version of gsl_multifit_linear_lcorner2().
Definition: multifit.hpp:952
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().
Definition: multifit.hpp:884
int linear_applyW(matrix const &X, vector const &w, vector const &y, matrix &WX, vector &Wy)
C++ version of gsl_multifit_linear_applyW().
Definition: multifit.hpp:767
int linear_Lk(size_t const p, size_t const k, matrix &L)
C++ version of gsl_multifit_linear_Lk().
Definition: multifit.hpp:970
int robust_tune(double const tune, robust_workspace &w)
C++ version of gsl_multifit_robust_tune().
Definition: multifit.hpp:668
static robust_type robust_default()
Robust linear static type.
Definition: multifit.hpp:1107
static robust_type robust_fair()
Robust linear static type.
Definition: multifit.hpp:1122
int robust_maxiter(size_t const maxiter, robust_workspace &w)
C++ version of gsl_multifit_robust_maxiter().
Definition: multifit.hpp:1080
static robust_type robust_bisquare()
Robust linear static type.
Definition: multifit.hpp:1112
static robust_type robust_ols()
Robust linear static type.
Definition: multifit.hpp:1132
size_t linear_rank(double const tol, linear_workspace const &work)
C++ version of gsl_multifit_linear_rank().
Definition: multifit.hpp:741
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().
Definition: multifit.hpp:997
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().
Definition: multifit.hpp:981
int robust_weights(vector const &r, vector &wts, robust_workspace &w)
C++ version of gsl_multifit_robust_weights().
Definition: multifit.hpp:1089
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().
Definition: multifit.hpp:866
gsl_multifit_robust_stats robust_stats
Convenience tyepdef.
Definition: multifit.hpp:660
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().
Definition: multifit.hpp:780
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().
Definition: multifit.hpp:795
int robust_residuals(matrix const &X, vector const &y, vector const &c, vector &r, robust_workspace &w)
C++ version of gsl_multifit_robust_residuals().
Definition: multifit.hpp:1100
int linear_gcv_init(vector const &y, vector &reg_param, vector &UTy, double &delta0, linear_workspace &work)
C++ version of gsl_multifit_linear_gcv_init().
Definition: multifit.hpp:1018
int linear_svd(matrix const &X, linear_workspace &work)
C++ version of gsl_multifit_linear_svd().
Definition: multifit.hpp:275
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().
Definition: multifit.hpp:838
double chisq(rng const &r, double const nu)
C++ version of gsl_ran_chisq().
Definition: randist.hpp:365
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
double eta(double const s)
C++ version of gsl_sf_eta().
Definition: sf_zeta.hpp:181
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34