Go to the documentation of this file.
65 using namespace StringUtils;
74 SRI::SRI(
const unsigned int N)
102 "Invalid dimensions in explicit SRI constructor:\n R is " +
103 asString<int>(r.
rows()) +
"x" + asString<int>(r.
cols()) +
104 ", Z has length " + asString<int>(z.
size()) +
105 " and NL has length " + asString<int>(
nl.size()));
126 "Invalid dimensions in SRI constructor from Cov,State:\n"
128 asString<int>(Cov.
rows()) +
"x" + asString<int>(Cov.
cols()) +
129 ", State has length " + asString<int>(State.
size()) +
130 " and NL has length " + asString<int>(NL.
size()));
171 "Invalid input: Namelists must be == to w/in permute");
177 const unsigned int n(R.rows());
181 for (i = 0; i < n; i++)
183 j =
nl.index(names.getName(i));
191 catch (MatrixException& me)
195 catch (VectorException& ve)
272 "split: Input Namelist must be a subset of this one");
279 for (i = 1; i <= n; i++)
281 for (j = 1; j <= m; j++)
285 N0.
swap(m - i, m - j);
292 "split: Input Namelist is not non-trivial subset");
305 for (i = 0; i < n; i++)
306 S1.
Z(i) = Sleft.
Z(m - n + i);
307 for (i = m - n; i < m; i++)
312 catch (MatrixException& me)
316 catch (VectorException& ve)
337 for (
unsigned int i = 0; i < R.rows(); i++)
340 for (
unsigned int j = 0; j < R.cols(); j++)
346 catch (MatrixException& me)
350 catch (VectorException& ve)
384 catch (MatrixException& me)
388 catch (VectorException& ve)
404 if ((names & S.
names).size() > 0)
406 Exception e(
"Cannot append duplicate names");
411 const size_t I(names.size());
422 for (
size_t i = 0; i < S.
names.
size(); i++)
425 for (
size_t j = 0; j < S.
names.
size(); j++)
426 R(I + i, I + j) = S.
R(i, j);
431 catch (MatrixException& me)
435 catch (VectorException& ve)
455 unsigned int i, j, n, m, sm;
463 for (j = 0; j < m; j++)
467 int k = all.
index(names.labels[j]);
470 MatrixException me(
"Algorithm error 1");
475 for (i = 0; i <= j; i++)
482 for (j = 0; j < sm; j++)
487 MatrixException me(
"Algorithm error 2");
490 for (i = 0; i <= j; i++)
491 A(m + i, k) = S.
R(i, j);
492 A(m + j, n) = S.
Z(j);
507 catch (MatrixException& me)
511 catch (VectorException& ve)
527 catch (MatrixException& me)
531 catch (VectorException& ve)
540 void SRI::zeroOne(
const unsigned int n)
547 for (
unsigned int j = n; j < R.cols(); j++) {
557 void SRI::zeroAll(
const unsigned int n)
566 if (n >=
int(R.rows()))
571 for (
unsigned int i = 0; i < n; i++)
573 for (
unsigned int j = i; j < R.cols(); j++) {
586 if (X0.
size() != R.cols())
588 MatrixException me(
"Invalid input dimension: SRI has dimension " +
589 asString<int>(R.rows()) +
590 " while input has length " +
591 asString<int>(X0.
size()));
603 if (Z0.
size() != R.cols())
605 MatrixException me(
"Invalid input dimension: SRI has dimension " +
606 asString<int>(R.rows()) +
607 " while input has length " +
608 asString<int>(Z0.
size()));
622 const unsigned int n(R.rows());
623 if (A.
rows() != n || A.
cols() != n + 1)
625 MatrixException me(
"Invalid input dimension: SRI has dimension " +
626 asString<int>(n) +
" while input has dimension " +
627 asString<int>(A.
rows()) +
"x" +
628 asString<int>(A.
cols()));
648 const unsigned int n(R.rows());
652 "Invalid input dimension: SRI has dimension " + asString<int>(n) +
653 " while input has dimension " + asString<int>(RR.
rows()) +
"x" +
654 asString<int>(RR.
cols()) +
" and " + asString<int>(ZZ.
size()));
672 const unsigned int n(R.rows());
673 if (invT.
rows() != n || invT.
cols() != n)
675 MatrixException me(
"Invalid input dimension: SRI has dimension " +
676 asString<int>(n) +
" while invT has dimension " +
677 asString<int>(invT.
rows()) +
"x" +
678 asString<int>(invT.
cols()));
683 retriangularize(R, Z);
703 void SRI::Qbump(
const unsigned int in,
double q)
717 unsigned int ns = 1, i, j, n = R.rows();
723 for (i = 0; i < n; i++)
725 A(ns + i, 0) = -G(i, 0);
726 for (j = 0; j < n; j++)
729 A(ns + i, ns + j) = R(i, j);
731 A(ns + i, ns + n) = Z(i);
742 catch (MatrixException& me)
746 catch (VectorException& ve)
759 void SRI::stateFix(
const std::string& name,
double value,
760 double sigma,
bool restore)
762 int index = names.index(name);
767 stateFix((
unsigned int)(index), value, sigma, restore);
777 void SRI::stateFix(
const unsigned int index,
double value,
778 double sigma,
bool restore)
780 if (index >= names.size())
784 const unsigned int N(names.size());
790 NL.
swap(index, N - 1);
795 Z(N - 1) = value / sigma;
796 R(N - 1, N - 1) = 1.0 / sigma;
799 if (restore && index != N - 1)
802 NL.
swap(index, N - 1);
811 void SRI::stateFixAndRemove(
const unsigned int in,
double bias)
820 unsigned int i, j, ii, jj, n = R.rows();
824 for (i = 0; i < in; i++)
825 Z(i) -= R(i, in) * bias;
827 for (i = 0, ii = 0; i < n; i++)
834 for (j = i, jj = ii; j < n; j++)
840 Rnew(ii, jj) = R(i, j);
847 names -= names.labels[in];
849 catch (MatrixException& me)
853 catch (VectorException& ve)
862 void SRI::stateFixAndRemove(
const Namelist& dropNL,
867 if (dropNL.
size() != values_in.
size())
869 VectorException e(
"Input has inconsistent lengths");
909 vector<double> value;
910 for (i = 0; i < dropNL.
size(); i++)
913 names.index(dropNL.
getName(i));
917 value.push_back(values_in(i));
921 const unsigned int m = indx.size();
922 const unsigned int n = R.rows();
933 for (k = 0; k < m; k++)
935 for (i = 0; i < indx[k]; i++)
937 Z(i) -= R(i, indx[k]) * value[k];
945 for (i = 0, k = 0; i < n; i++)
948 for (j = 0; j < m; j++)
950 if ((
int)i == indx[j])
962 for (j = i; j < n; j++)
964 Rtmp(k, j) = R(i, j);
974 for (j = 0, k = 0; j < n; j++)
977 for (i = 0; i < m; i++)
979 if ((
int)j == indx[i])
990 for (i = 0; i <= j; i++)
992 R(i, k) = Rtmp(i, j);
998 for (k = 0; k < dropNL.
size(); k++)
1000 std::string name(dropNL.
getName(k));
1004 catch (MatrixException& me)
1008 catch (VectorException& ve)
1019 if (Cov.
rows() != Cov.
cols() || Cov.
rows() != R.rows() ||
1020 X.
size() != R.rows())
1023 "Invalid input dimensions:\n SRI has dimension " +
1024 asString<int>(R.rows()) +
",\n while input is Cov(" +
1025 asString<int>(Cov.
rows()) +
"x" + asString<int>(Cov.
cols()) +
1026 ") and X(" + asString<int>(X.
size()) +
").");
1033 addAPrioriInformation(InvCov, X);
1035 catch (MatrixException& me)
1045 if (InvCov.
rows() != InvCov.
cols() || InvCov.
rows() != R.rows() ||
1046 X.
size() != R.rows())
1049 "Invalid input dimensions:\n SRI has dimension " +
1050 asString<int>(R.rows()) +
",\n while input is InvCov(" +
1051 asString<int>(InvCov.
rows()) +
"x" + asString<int>(InvCov.
cols()) +
1052 ") and X(" + asString<int>(X.
size()) +
").");
1063 catch (MatrixException& me)
1070 void SRI::getConditionNumber(
double& small,
double& big)
const
1075 const int n = R.rows();
1083 small = svd.
S(n - 1);
1086 catch (MatrixException& me)
1088 me.addText(
"Called by getConditionNumber");
1099 const int n = Z.size();
1110 for (i = n - 1; i >= 0; i--)
1119 "Singular matrix; zero diagonal element at index " +
1124 for (j = i + 1; j < n; j++)
1126 sum -= R(i, j) * X(j);
1128 X(i) =
sum / R(i, i);
1137 double *ptrSmall,
double *ptrBig)
const
1158 if (small <= 10 * numeric_limits<double>::epsilon())
1160 MatrixException me(
"Singular matrix: condition number is " +
1161 asString<double>(big) +
" / " +
1162 asString<double>(small));
1169 catch (MatrixException& me)
1173 catch (VectorException& ve)
1185 NLC += string(
"State");
1190 ios_base::fmtflags flags = os.flags();
1191 if (flags & ios_base::scientific)
1195 LM.
setw(os.width());
const Matrix< double > SRINullMatrix
constant (empty) Matrix used for default input arguments
Matrix< T > UTtimesTranspose(const Matrix< T > &UT)
Matrix< T > inverseLUD(const ConstMatrixBase< T, BaseClass > &m)
LabeledMatrix & scientific()
Set the format to scientific.
int index(const std::string &name) const
std::vector< std::string > labels
vector of names (strings)
SparseMatrix< T > lowerCholesky(const SparseMatrix< T > &A)
Matrix< T > inverseUT(const Matrix< T > &UT, T *ptrSmall=NULL, T *ptrBig=NULL)
SRI operator+(const SRI &Sleft, const SRI &Sright)
T sum(const ConstVectorBase< T, BaseClass > &l)
size_t cols() const
The number of columns in the matrix.
size_t rows() const
The number of rows in the matrix.
Matrix< double > R
Information matrix, an upper triangular (square) matrix.
void zeroOne(const unsigned int n)
bool identical(const Namelist &N1, const Namelist &N2)
std::vector< std::string > split(const std::string &str, const char delimiter=' ')
Vector & resize(const size_t index)
Vector< double > Z
SRI state vector, of length equal to the dimension (row and col) of R.
LabeledMatrix & setprecision(int p)
Set the precision to p digits.
SparseMatrix< T > transform(const SparseMatrix< T > &M, const SparseMatrix< T > &C)
void permute(const Namelist &NL)
void SrifMU(Matrix< T > &R, Vector< T > &Z, SparseMatrix< T > &A, const unsigned int M)
const SparseMatrix< double > SRINullSparseMatrix
constant (empty) SparseMatrix used for default input arguments
SparseMatrix< T > transpose(const SparseMatrix< T > &M)
transpose
unsigned int size() const
return the size of the list.
std::string getName(const unsigned int in) const
void sort(bool descending=true)
Matrix< T > A
The upper triangular transformed matrix.
Namelist names
Namelist parallel to R and Z, labelling the elements of the state vector.
#define GNSSTK_RETHROW(exc)
SparseMatrix< T > upperCholesky(const SparseMatrix< T > &A)
@ P
Legacy GPS precise code.
std::ostream & operator<<(std::ostream &s, gnsstk::StringUtils::FFLead v)
size_t size() const
STL size.
Vector< T > colCopy(size_t c, size_t r=0) const
LabeledMatrix & clean(bool s=true)
If true, print 0.0 as 0.
Vector< T > S
Vector of singular values.
#define GNSSTK_THROW(exc)
void swap(const unsigned int &i, const unsigned int &j)
LabeledMatrix & setw(int w)
Set the width to w characters.
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41