00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00029
00030 #include <vector>
00031
00032 #include <kfilter/kvector.hpp>
00033 #include <kfilter/kmatrix.hpp>
00034
00035 using namespace std;
00036 using namespace Kalman;
00037
00038 namespace {
00039
00041 typedef vector<KVectorContextImpl> VectorContextList;
00042
00044 VectorContextList vectorContexts(1, KVectorContextImpl());
00045
00047 KVectorContext currentVectorIndex = 0;
00048
00050 typedef vector<KMatrixContextImpl> MatrixContextList;
00051
00053 MatrixContextList matrixContexts(1, KMatrixContextImpl());
00054
00056 KMatrixContext currentMatrixIndex = 0;
00057
00058 }
00059
00061 KVectorContextImpl* Kalman::currentVectorContext = &vectorContexts[0];
00062
00064 KVectorContext Kalman::DEFAULT_VECTOR_CONTEXT = 0;
00065
00085 KVectorContext Kalman::createKVectorContext(std::string elemDelim,
00086 std::string startDelim,
00087 std::string endDelim,
00088 unsigned prec) {
00089 if (prec < 1) prec = 1;
00090 if (prec > 9) prec = 9;
00091
00092 vectorContexts.push_back(KVectorContextImpl(elemDelim,
00093 startDelim,
00094 endDelim,
00095 prec));
00096 return vectorContexts.size() - 1;
00097 }
00098
00103 KVectorContext Kalman::selectKVectorContext(KVectorContext c) {
00104
00105 if (c >= vectorContexts.size()) {
00106 return currentVectorIndex;
00107 }
00108
00109 KVectorContext tmp = currentVectorIndex;
00110 currentVectorIndex = c;
00111 currentVectorContext = &vectorContexts[c];
00112 return tmp;
00113 }
00114
00116 KMatrixContextImpl* Kalman::currentMatrixContext = &matrixContexts[0];
00117
00119 KMatrixContext Kalman::DEFAULT_MATRIX_CONTEXT = 0;
00120
00144 KMatrixContext Kalman::createKMatrixContext(std::string elemDelim,
00145 std::string rowDelim,
00146 std::string startDelim,
00147 std::string endDelim,
00148 unsigned prec) {
00149 if (prec < 1) prec = 1;
00150 if (prec > 9) prec = 9;
00151
00152 matrixContexts.push_back(KMatrixContextImpl(elemDelim,
00153 rowDelim,
00154 startDelim,
00155 endDelim,
00156 prec));
00157 return matrixContexts.size() - 1;
00158 }
00159
00164 KMatrixContext Kalman::selectKMatrixContext(KMatrixContext c) {
00165
00166 if (c >= matrixContexts.size()) {
00167 return currentMatrixIndex;
00168 }
00169
00170 KMatrixContext tmp = currentMatrixIndex;
00171 currentMatrixIndex = c;
00172 currentMatrixContext = &matrixContexts[c];
00173 return tmp;
00174 }