00001 #pragma ident "$Id: ARBase.cpp 2620 2011-05-26 14:42:13Z yanweignss $"
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "ARBase.hpp"
00031
00032
00033 namespace gpstk
00034 {
00035
00036
00037 Matrix<double> ARBase::sd2ddMatrix(const size_t& n, const size_t& i)
00038 throw(ARException)
00039 {
00040 if( i >= n)
00041 {
00042 Exception e("The reference index CAN NOT greater than toltal number.");
00043 GPSTK_THROW(e);
00044 }
00045
00046 Matrix<double> sdMat(n-1, n, 0.0);
00047
00048 for(int j = 0; j< sdMat.rows(); j++)
00049 {
00050 sdMat(j,i) = -1.0;
00051 if(j<i) sdMat(j,j) = 1.0;
00052 else sdMat(j,j+1) = 1.0;
00053 }
00054
00055 return sdMat;
00056
00057 }
00058
00059
00060 void ARBase::computeFloatAmbiguity(const Matrix<double>& A,
00061 const Matrix<double>& B,
00062 const Matrix<double>& W,
00063 const Vector<double>& y,
00064 Vector<double>& ambFloat,
00065 Matrix<double>& ambCov,
00066 double smFactor)
00067 throw(ARException)
00068 {
00069 try
00070 {
00071
00072 if( (smFactor< 0.001) || (smFactor>0.0001))
00073 {
00074 smFactor = 0.001;
00075 }
00076
00077 Matrix<double> I = ident<double>(A.rows());
00078 Matrix<double> AT = transpose(A);
00079 Matrix<double> ATW = AT*W;
00080
00081 Matrix<double> Px = diag(ATW*A);
00082
00083 Matrix<double> Ja = I - A * inverseSVD(ATW * A + smFactor*Px) * ATW;
00084
00085 Matrix<double> BTWJ = transpose(B) * W * Ja;
00086
00087 ambFloat= inverseSVD(BTWJ * B) * BTWJ * y;
00088 ambCov = inverseSVD(BTWJ * B);
00089 }
00090 catch (...)
00091 {
00092 ARException e("Failed to compute float ambiguity.");
00093 GPSTK_THROW(e);
00094 }
00095
00096 }
00097
00098 }
00099