File indexing completed on 2025-02-21 10:03:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef __GSL_MOVSTAT_H__
0021 #define __GSL_MOVSTAT_H__
0022
0023 #include <gsl/gsl_math.h>
0024 #include <gsl/gsl_vector.h>
0025
0026 #undef __BEGIN_DECLS
0027 #undef __END_DECLS
0028 #ifdef __cplusplus
0029 # define __BEGIN_DECLS extern "C" {
0030 # define __END_DECLS }
0031 #else
0032 # define __BEGIN_DECLS
0033 # define __END_DECLS
0034 #endif
0035
0036 __BEGIN_DECLS
0037
0038 typedef enum
0039 {
0040 GSL_MOVSTAT_END_PADZERO,
0041 GSL_MOVSTAT_END_PADVALUE,
0042 GSL_MOVSTAT_END_TRUNCATE
0043 } gsl_movstat_end_t;
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 typedef struct
0054 {
0055 size_t (*size) (const size_t n);
0056 int (*init) (const size_t n, void * vstate);
0057 int (*insert) (const double x, void * vstate);
0058 int (*delete_oldest) (void * vstate);
0059 int (*get) (void * params, double * result, const void * vstate);
0060 } gsl_movstat_accum;
0061
0062 typedef struct
0063 {
0064 double (* function) (const size_t n, double x[], void * params);
0065 void * params;
0066 } gsl_movstat_function;
0067
0068 #define GSL_MOVSTAT_FN_EVAL(F,n,x) (*((F)->function))((n),(x),(F)->params)
0069
0070
0071
0072 typedef struct
0073 {
0074 size_t H;
0075 size_t J;
0076 size_t K;
0077 double *work;
0078 void *state;
0079 size_t state_size;
0080 } gsl_movstat_workspace;
0081
0082
0083
0084 gsl_movstat_workspace *gsl_movstat_alloc(const size_t K);
0085 gsl_movstat_workspace *gsl_movstat_alloc2(const size_t H, const size_t J);
0086 gsl_movstat_workspace *gsl_movstat_alloc_with_size(const size_t accum_state_size, const size_t H, const size_t J);
0087 void gsl_movstat_free(gsl_movstat_workspace * w);
0088
0089
0090 int gsl_movstat_apply_accum(const gsl_movstat_end_t endtype, const gsl_vector * x,
0091 const gsl_movstat_accum * accum, void * accum_params,
0092 gsl_vector * y, gsl_vector * z,
0093 gsl_movstat_workspace * w);
0094 int gsl_movstat_apply(const gsl_movstat_end_t endtype, const gsl_movstat_function * F,
0095 const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0096
0097
0098 size_t gsl_movstat_fill(const gsl_movstat_end_t endtype, const gsl_vector * x, const size_t idx,
0099 const size_t H, const size_t J, double * window);
0100
0101 int gsl_movstat_mean(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0102 int gsl_movstat_variance(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0103 int gsl_movstat_sd(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0104 int gsl_movstat_median(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0105 int gsl_movstat_min(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0106 int gsl_movstat_max(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0107 int gsl_movstat_minmax(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y_min, gsl_vector * y_max, gsl_movstat_workspace * w);
0108 int gsl_movstat_mad0(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xmedian,
0109 gsl_vector * xmad, gsl_movstat_workspace * w);
0110 int gsl_movstat_mad(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * xmedian,
0111 gsl_vector * xmad, gsl_movstat_workspace * w);
0112 int gsl_movstat_qqr(const gsl_movstat_end_t endtype, const gsl_vector * x, const double q,
0113 gsl_vector * xqqr, gsl_movstat_workspace * w);
0114 int gsl_movstat_Sn(const gsl_movstat_end_t endtype, const gsl_vector * x,
0115 gsl_vector * xscale, gsl_movstat_workspace * w);
0116 int gsl_movstat_Qn(const gsl_movstat_end_t endtype, const gsl_vector * x,
0117 gsl_vector * xscale, gsl_movstat_workspace * w);
0118 int gsl_movstat_sum(const gsl_movstat_end_t endtype, const gsl_vector * x, gsl_vector * y, gsl_movstat_workspace * w);
0119
0120
0121
0122 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_mad;
0123 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_max;
0124 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_mean;
0125 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_median;
0126 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_min;
0127 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_minmax;
0128 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_sd;
0129 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_Sn;
0130 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_sum;
0131 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_Qn;
0132 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_qqr;
0133 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_userfunc;
0134 GSL_VAR const gsl_movstat_accum * gsl_movstat_accum_variance;
0135
0136 __END_DECLS
0137
0138 #endif