00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00074 #ifndef __LWPR_H
00075 #define __LWPR_H
00076
00077 #include <lwpr_config.h>
00078
00079 #ifndef NUM_THREADS
00080 #define NUM_THREADS 1
00081 #endif
00082
00083 #if NUM_THREADS < 1 || NUM_THREADS > 32
00084 #error "NUM_THREADS must be a number between 1 and 32."
00085 #endif
00086
00087 #ifndef LWPR_REGSTORE
00088
00089 #define LWPR_REGSTORE 2
00090
00092 #define LWPR_REGINCR 2
00093 #endif
00094
00095
00096 #ifdef __cplusplus
00097 extern "C" {
00098 #endif
00099
00105 typedef enum {
00106 LWPR_GAUSSIAN_KERNEL, LWPR_BISQUARE_KERNEL
00107 } LWPR_Kernel;
00108
00133 typedef struct {
00134 int nReg;
00135 int nRegStore;
00137 double *fixStorage;
00138 double *varStorage;
00140 int trustworthy;
00141 int slopeReady;
00142 double w;
00143 double sum_e2;
00144 double beta0;
00145 double SSp;
00147 double *D;
00148 double *M;
00149 double *alpha;
00150 double *beta;
00151 double *c;
00152 double *SXresYres;
00153 double *SSs2;
00154 double *SSYres;
00155 double *SSXres;
00156 double *U;
00157 double *P;
00158 double *H;
00159 double *r;
00160 double *h;
00161 double *b;
00162 double *sum_w;
00163 double *sum_e_cv2;
00164 double *n_data;
00165 double *lambda;
00166 double *mean_x;
00167 double *var_x;
00168 double *s;
00169 double *slope;
00170 const struct LWPR_Model *model;
00171 } LWPR_ReceptiveField;
00172
00177 typedef struct {
00178 int numRFS;
00179 int numPointers;
00180 int n_pruned;
00181 LWPR_ReceptiveField **rf;
00182 const struct LWPR_Model *model;
00183 } LWPR_SubModel;
00184
00194 typedef struct LWPR_Model {
00195 int nIn;
00196 int nInStore;
00197 int nOut;
00198 int n_data;
00200 double *mean_x;
00201 double *var_x;
00202 char *name;
00203 int diag_only;
00204 int meta;
00205 double meta_rate;
00206 double penalty;
00207 double *init_alpha;
00208 double *norm_in;
00209 double *norm_out;
00210 double *init_D;
00211 double *init_M;
00212 double w_gen;
00213 double w_prune;
00214 double init_lambda;
00215 double final_lambda;
00216 double tau_lambda;
00217 double init_S2;
00218 double add_threshold;
00219 LWPR_Kernel kernel;
00220 int update_D;
00221 LWPR_SubModel *sub;
00222 struct LWPR_Workspace *ws;
00224 double *storage;
00226 double *xn;
00227 double *yn;
00229 #ifdef MATLAB
00230 int isPersistent;
00236 #endif
00237 } LWPR_Model;
00238
00250 void lwpr_predict(const LWPR_Model *model, const double *x,
00251 double cutoff, double *y, double *conf, double *max_w);
00252
00280 void lwpr_predict_J(const LWPR_Model *model, const double *x,
00281 double cutoff, double *y, double *J);
00282
00283
00298 void lwpr_predict_JcJ(const LWPR_Model *model, const double *x,
00299 double cutoff, double *y, double *J, double *conf, double *Jconf);
00300
00316 void lwpr_predict_JH(const LWPR_Model *model, const double *x,
00317 double cutoff, double *y, double *J, double *H);
00318
00332 int lwpr_update(LWPR_Model *model, const double *x, const double *y,
00333 double *yp, double *max_w);
00334
00349 int lwpr_init_model(LWPR_Model *model, int nIn, int nOut, const char *name);
00350
00380 void lwpr_free_model(LWPR_Model *model);
00381
00390 int lwpr_set_init_alpha(LWPR_Model *model, double alpha);
00391
00400 int lwpr_set_init_D_spherical(LWPR_Model *model, double sigma);
00401
00411 int lwpr_set_init_D_diagonal(LWPR_Model *model, const double *d);
00412
00425 int lwpr_set_init_D(LWPR_Model *model, const double *D, int stride);
00426
00437 int lwpr_duplicate_model(LWPR_Model *dest, const LWPR_Model *src);
00438
00439 #ifdef __cplusplus
00440 }
00441 #endif
00442
00443 #endif
00444