24#include<gsl/gsl_movstat.h>
36 typedef gsl_movstat_end_t
end_t;
56 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
71 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
88 ccgsl_pointer = gsl_movstat_alloc_with_size( accum_state_size, H, J );
90 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
142#ifdef __GXX_EXPERIMENTAL_CXX0X__
148 std::swap(
count, v.count );
149 v.ccgsl_pointer =
nullptr;
157 workspace( std::move( v ) ).swap( *
this );
267#ifdef __GXX_EXPERIMENTAL_CXX0X__
284 int apply_accum(
end_t const endtype,
vector const& x,
285 gsl_movstat_accum
const* accum,
void* accum_params,
287 return gsl_movstat_apply_accum( endtype, x.
get(), accum, accum_params,
299 int apply(
end_t const endtype, gsl_movstat_function
const*
F,
301 return gsl_movstat_apply( endtype,
F, x.
get(), y.
get(),
get() ); }
313 return gsl_movstat_apply( endtype, &
F, x.
get(), y.
get(),
get() ); }
322 return gsl_movstat_mean( endtype, x.
get(), y.
get(),
get() ); }
331 return gsl_movstat_variance( endtype, x.
get(), y.
get(),
get() ); }
340 return gsl_movstat_sd( endtype, x.
get(), y.
get(),
get() ); }
349 return gsl_movstat_median( endtype, x.
get(), y.
get(),
get() ); }
358 return gsl_movstat_min( endtype, x.
get(), y.
get(),
get() ); }
367 return gsl_movstat_max( endtype, x.
get(), y.
get(),
get() ); }
378 return gsl_movstat_minmax( endtype, x.
get(), y_min.
get(), y_max.
get(),
get() ); }
389 return gsl_movstat_mad0( endtype, x.
get(), xmedian.
get(), xmad.
get(),
get() ); }
400 return gsl_movstat_mad( endtype, x.
get(), xmedian.
get(), xmad.
get(),
get() ); }
411 return gsl_movstat_qqr( endtype, x.
get(), q, xqqr.
get(),
get() ); }
420 return gsl_movstat_Sn( endtype, x.
get(), xscale.
get(),
get() ); }
429 return gsl_movstat_Qn( endtype, x.
get(), xscale.
get(),
get() ); }
438 return gsl_movstat_sum( endtype, x.
get(), y.
get(),
get() ); }
467 gsl_movstat_accum
const* accum,
void* accum_params,
469 return gsl_movstat_apply_accum( endtype, x.
get(), accum, accum_params,
470 y.
get(), z.
get(), w.get() ); }
481 vector
const& x, vector& y, workspace& w ){
482 return gsl_movstat_apply( endtype,
F, x.get(), y.get(), w.get() ); }
495 return gsl_movstat_apply( endtype, &
F, x.
get(), y.
get(), w.
get() ); }
510 size_t const idx,
size_t const H,
size_t const J,
double* window ){
511 return gsl_movstat_fill( endtype, x.
get(), idx, H, J, window ); }
525 size_t const idx,
size_t const H,
size_t const J,
gsl::vector& window ){
526 if( window.
size() != H + J + 1 )
528 return gsl_movstat_fill( endtype, x.
get(), idx, H, J, window.
get()->data ); }
539 return gsl_movstat_mean( endtype, x.
get(), y.
get(), w.
get() ); }
550 return gsl_movstat_variance( endtype, x.
get(), y.
get(), w.
get() ); }
561 return gsl_movstat_sd( endtype, x.
get(), y.
get(), w.
get() ); }
572 return gsl_movstat_median( endtype, x.
get(), y.
get(), w.
get() ); }
583 return gsl_movstat_min( endtype, x.
get(), y.
get(), w.
get() ); }
594 return gsl_movstat_max( endtype, x.
get(), y.
get(), w.
get() ); }
606 return gsl_movstat_minmax( endtype, x.
get(), y_min.
get(), y_max.
get(), w.
get() ); }
618 return gsl_movstat_mad0( endtype, x.
get(), xmedian.
get(), xmad.
get(), w.
get() ); }
630 return gsl_movstat_mad( endtype, x.
get(), xmedian.
get(), xmad.
get(), w.
get() ); }
642 return gsl_movstat_qqr( endtype, x.
get(), q, xqqr.
get(), w.
get() ); }
653 return gsl_movstat_Sn( endtype, x.
get(), xscale.
get(), w.
get() ); }
664 return gsl_movstat_Qn( endtype, x.
get(), xscale.
get(), w.
get() ); }
675 return gsl_movstat_sum( endtype, x.
get(), y.
get(), w.
get() ); }
684 inline gsl_movstat_accum
const*
mad(){
return gsl_movstat_accum_mad; }
688 inline gsl_movstat_accum
const*
max(){
return gsl_movstat_accum_max; }
692 inline gsl_movstat_accum
const*
mean(){
return gsl_movstat_accum_mean; }
696 inline gsl_movstat_accum
const*
median(){
return gsl_movstat_accum_median; }
700 inline gsl_movstat_accum
const*
min(){
return gsl_movstat_accum_min; }
704 inline gsl_movstat_accum
const*
minmax(){
return gsl_movstat_accum_minmax; }
708 inline gsl_movstat_accum
const*
sd(){
return gsl_movstat_accum_sd; }
712 inline gsl_movstat_accum
const*
Sn(){
return gsl_movstat_accum_Sn; }
716 inline gsl_movstat_accum
const*
sum(){
return gsl_movstat_accum_sum; }
720 inline gsl_movstat_accum
const*
Qn(){
return gsl_movstat_accum_Qn; }
724 inline gsl_movstat_accum
const*
qqr(){
return gsl_movstat_accum_qqr; }
726 inline gsl_movstat_accum
const* userfunc(){
return gsl_movstat_accum_userfunc; }
731 inline gsl_movstat_accum
const*
variance(){
return gsl_movstat_accum_variance; }
@ GSL_EBADLEN
matrix, vector lengths are not conformant
Class that extends gsl_movstat_function so that it can be constructed from arbitrary function objects...
Workspace for moving window statistics.
workspace(workspace &&v)
Move constructor.
size_t * count
The shared reference count.
workspace(workspace const &v)
The copy constructor.
int max(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_max().
int apply(end_t const endtype, movstat::function const &F, vector const &x, vector &y)
C++ version of gsl_movstat_apply().
int mean(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_mean().
int Qn(end_t const endtype, vector const &x, vector &xscale)
C++ version of gsl_movstat_Qn().
int minmax(end_t const endtype, vector const &x, vector &y_min, vector &y_max)
C++ version of gsl_movstat_minmax().
bool empty() const
Find if the workspace is empty.
bool operator>=(workspace const &v) const
A container needs to define an ordering for sorting.
workspace & operator=(workspace const &v)
The assignment operator.
workspace(gsl_movstat_workspace *v)
Could construct from a gsl_movstat_workspace*.
gsl_movstat_workspace * ccgsl_pointer
The shared pointer.
int mad0(end_t const endtype, vector const &x, vector &xmedian, vector &xmad)
C++ version of gsl_movstat_mad0().
int qqr(end_t const endtype, vector const &x, double const q, vector &xqqr)
C++ version of gsl_movstat_qqr().
int median(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_median().
int variance(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_variance().
~workspace()
The destructor only deletes the pointers if count reaches zero.
int min(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_min().
bool operator==(workspace const &v) const
Two workspace are identically equal if their elements are identical.
size_t use_count() const
Find how many workspace objects share this pointer.
int sd(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_sd().
workspace(size_t const K)
The default constructor creates a new workspace with window length K.
int mad(end_t const endtype, vector const &x, vector &xmedian, vector &xmad)
C++ version of gsl_movstat_mad().
gsl_movstat_workspace * get() const
Get the gsl_movstat_workspace.
bool operator!=(workspace const &v) const
Two workspace are different if their elements are not identical.
int Sn(end_t const endtype, vector const &x, vector &xscale)
C++ version of gsl_movstat_Sn().
void swap(workspace &v)
Swap two workspace objects.
int sum(end_t const endtype, vector const &x, vector &y)
C++ version of gsl_movstat_sum().
bool operator>(workspace const &v) const
A container needs to define an ordering for sorting.
bool operator<(workspace const &v) const
A container needs to define an ordering for sorting.
bool unique() const
Find if this is the only object sharing the gsl_movstat_workspace.
workspace & operator=(workspace &&v)
Move operator.
workspace(size_t const H, size_t const J)
Creates a new workspace with H samples before current and J after current sample.
bool operator<=(workspace const &v) const
A container needs to define an ordering for sorting.
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.
size_type size() const
The size (number of elements) of the vector.
gsl_movstat_accum const * minmax()
Moving window minmax.
gsl_movstat_accum const * sd()
Moving window standard deviation.
gsl_movstat_accum const * Qn()
Moving window .
gsl_movstat_accum const * Sn()
Moving window .
gsl_movstat_accum const * max()
Moving window maximum.
gsl_movstat_accum const * mad()
Moving window mean absolute deviation?
gsl_movstat_accum const * median()
Moving window median.
gsl_movstat_accum const * qqr()
Moving window q-quantile range.
gsl_movstat_accum const * variance()
Moving window variance.
gsl_movstat_accum const * sum()
Moving window maximum.
gsl_movstat_accum const * min()
Moving window minimum.
gsl_movstat_accum const * mean()
Moving window mean.
int qqr(movstat::end_t const endtype, vector const &x, double const q, vector &xqqr, workspace &w)
C++ version of gsl_movstat_qqr().
int max(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_max().
int Sn(movstat::end_t const endtype, vector const &x, vector &xscale, workspace &w)
C++ version of gsl_movstat_Sn().
int mad0(movstat::end_t const endtype, vector const &x, vector &xmedian, vector &xmad, workspace &w)
C++ version of gsl_movstat_mad0().
int minmax(movstat::end_t const endtype, vector const &x, vector &y_min, vector &y_max, workspace &w)
C++ version of gsl_movstat_minmax().
size_t fill(movstat::end_t const endtype, vector const &x, size_t const idx, size_t const H, size_t const J, gsl::vector &window)
C++ version of gsl_movstat_fill().
int min(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_min().
int Qn(movstat::end_t const endtype, vector const &x, vector &xscale, workspace &w)
C++ version of gsl_movstat_Qn().
int variance(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_variance().
@ TRUNCATE
Defined for handling end points.
@ PADVALUE
Defined for handling end points.
@ PADZERO
Defined for handling end points.
int mad(movstat::end_t const endtype, vector const &x, vector &xmedian, vector &xmad, workspace &w)
C++ version of gsl_movstat_mad().
int median(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_median().
int sd(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_sd().
int mean(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_mean().
int apply(movstat::end_t const endtype, movstat::function const &F, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_apply().
int sum(movstat::end_t const endtype, vector const &x, vector &y, workspace &w)
C++ version of gsl_movstat_sum().
gsl_movstat_end_t end_t
Convenient typedef.
double F(double phi, double k, mode_t mode)
C++ version of gsl_sf_ellint_F().
The gsl package creates an interface to the GNU Scientific Library for C++.