quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a #include <KalmanFilter.h> KalmanFilter(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order); boolean eq(const KalmanFilter& arg); boolean setAlgorithm(ALGORITHM algorithm); boolean setOrder(long order); boolean setNoise(double covar_nse_pro, double covar_nse_obs, double covar_err_est); boolean setParameter(double alpha, double beta, double kappa);
description:KalmanFilter kf; VectorDouble input(L"1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"); VectorDouble output; kf.setAlgorithm(CONVENTIONAL); kf.setImplementation(AR_SCALAR); kf.setNoise(0.03, 0.02, 0.0001); kf.setOrder(8); kf.compute(output, input);
static const String CLASS_NAME = L"KalmanFilter";
enum ALGORITHM { CONVENTIONAL = 0, UNSCENTED, DEF_ALGORITHM = CONVENTIONAL};
enum IMPLEMENTATION { AR_SCALAR, AR_VECTOR, DEF_IMPLEMENTATION = AR_SCALAR };
static const NameMap ALGO_MAP(L"CONVENTIONAL, UNSCENTED");
static const NameMap IMPL_MAP(L"AR_SCALAR, AR_VECTOR");
static const String DEF_PARAM = L"";
static const String PARAM_ALGORITHM = L"algorithm";
static const String PARAM_IMPLEMENTATION = L"implementation";
static const String PARAM_FLOOR = L"order";
static const String PARAM_NOISE_PRC = L"process_noise";
static const String PARAM_NOISE_OBS = L"obsn_noise";
static const String PARAM_NOISE_ERR = L"estimate_eror";
static const String PARAM_ALPHA = L"alpha";
static const String PARAM_BETA = L"beta";
static const String PARAM_KAPPA = L"kappa";
static const long DEF_ORDER = -1;
static const double DEF_PROCESS_NOISE = -1.00;
static const double DEF_OBSN_NOISE = -1.00;
static const double DEF_ERR_NOISE = -1.00;
static const double DEF_ALPHA = -1.00;
static const double DEF_BETA = -1.00;
static const double DEF_KAPPA = -1.00;
static const VectorDouble DEF_STATE_MEM(L"1");
static const VectorDouble DEF_OBS(L"-1");
static const MatrixDouble DEF_TRN(1, 1, L"0", Integral::FULL);
static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SIGNAL;
static const long ERR = 73300;
static const long ERR_MISDIM = 73301;
static const long ERR_UNIPAR = 73302;
ALGORITHM algorithm_d;
IMPLEMENTATION implementation_d;
Long order_d;
MatrixDouble trn_d;
VectorDouble obs_d;
VectorDouble state_mem_d;
MatrixDouble covar_nse_pro_d;
double covar_nse_obs_d;
MatrixDouble covar_err_est_d;
VectorDouble data_filt_d;
Double alpha_d;
Double beta_d;
Double kappa_d;
Double lambda_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~KalmanFilter();
KalmanFilter(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order);
KalmanFilter(const KalmanFilter& arg);
boolean assign(const KalmanFilter& arg);
KalmanFilter& operator= (const KalmanFilter& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean eq(const KalmanFilter& arg) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);
boolean setAlgorithm(ALGORITHM algorithm);
boolean setImplementation(IMPLEMENTATION implementation);
boolean setOrder(double floor = DEF_ORDER);
boolean setProcessNoise(double covar_nse_pro);
boolean setObsnNoise(double covar_nse_obs);
boolean setEstimateError(double covar_err_est);
boolean setNoise(double covar_nse_pro, double covar_nse_obs, double covar_err_est);
boolean setInitialState(VectorDouble& state_mem = DEF_STATE_MEM);
boolean setTransitionModel(MatrixDouble trn = DEF_TRN);
boolean setObsnModel(VectorDouble obs = DEF_OBS);
boolean setModel(MatrixDouble trn = DEF_TRN, VectorDouble obs = DEF_OBS);
boolean setAlpha(double alpha = DEF_ALPHA);
boolean setBeta(double beta = DEF_BETA);
boolean setKappa(double kappa = DEF_KAPPA);
boolean setParameters(double alpha = DEF_ALPHA, double beta = DEF_BETA, double kappa = DEF_KAPPA);
boolean setKF(long order, double covar_nse_pro, double covar_nse_obs, double covar_err_est, VectorDouble state_mem = DEF_STATE_MEM);
boolean setKF(VectorDouble& covar_nse_pro, double covar_nse_obs, MatrixDouble& covar_err_est, VectorDouble state_mem = DEF_STATE_MEM, MatrixDouble trn = DEF_TRN, VectorDouble obs = DEF_OBS);
boolean setUKF(long order, double covar_nse_pro, double covar_nse_obs, double covar_err_est, VectorDouble state_mem = DEF_STATE_MEM, double alpha = DEF_ALPHA, double beta = DEF_BETA, double kappa = DEF_KAPPA);
boolean setUKF(VectorDouble& covar_nse_pro, double covar_nse_obs, MatrixDouble& covar_err_est, VectorDouble state_mem = DEF_STATE_MEM, MatrixDouble trn = DEF_TRN, VectorDouble obs = DEF_OBS, double alpha = DEF_ALPHA, double beta = DEF_BETA, double kappa = DEF_KAPPA);
boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER);
ALGORITHM getAlgorithm() const;
IMPLEMENTATION getImplementation() const;
double getOrder() const;
boolean getInitialState(VectorDouble& state_mem) const;
boolean getTransitionModel(MatrixDouble& trn) const;
boolean getObservationModel(VectorDouble& obs) const;
boolean getModel(MatrixDouble& trn, VectorDouble& obs ) const;
boolean getProcessNoise(VectorDouble& covar_nse_pro) const;
boolean getObservationNoise(double covar_nse_obs) const;
boolean getEstimateError(MatrixDouble& covar_err_est) const;
boolean getNoise(VectorDouble& covar_nse_pro, double covar_nse_obs, MatrixDouble& covar_err_est) const;
boolean getAlpha(double alpha) const;
boolean getBeta(double beta) const;
boolean getKappa(double kappa) const;
boolean getParameters(double alpha, double beta, double kappa) const;
boolean getResult(VectorDouble& data_filt) const;
boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, Long& order);
boolean compute(VectorDouble& output, const VectorDouble& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean compute(VectorComplexDouble& output, const VectorComplexDouble& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, long index = DEF_CHANNEL_INDEX);
boolean assign(const AlgorithmBase& arg);
boolean eq(const AlgorithmBase& arg) const;
const String& className() const;
boolean init();
boolean apply(Vector<AlgorithmData>& output, const Vector<AlgorithmData>& input);
boolean setParser(SofParser* parser);
boolean readDataKalmanFilter(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeDataKalmanFilter(Sof& sof, const String& pname) const;
boolean computeStates(const VectorDouble& obsn, VectorDouble& filtered_data);
boolean initializeTransitionModel(const VectorDouble& obsn);
boolean matrixSqrt(MatrixDouble& mat_in, MatrixDouble& mat_sqrt);examples:
// declare an KalmanFilter object and an output vector // KalmanFilter kf; VectorDouble output; // set the input vector // VectorDouble input(L"0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"); // choose algorithm // kf.setAlgorithm(KalmanFilter::CONVENTIONAL); // choose implementation // kf.setImplementation(KalmanFilter::AR_SCALAR); // set the process noise covariance, observation noise covariance, // estimate error covariance kf.setNoise(0.01, 0.06, 1.0); // set the order // kf.setOrder(8); // compute filtered signal // kf.compute(output, input);notes: