ARSimple.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: ARSimple.cpp 2937 2011-10-23 19:23:33Z yanweignss $"
00002 
00008 //============================================================================
00009 //
00010 //  This file is part of GPSTk, the GPS Toolkit.
00011 //
00012 //  The GPSTk is free software; you can redistribute it and/or modify
00013 //  it under the terms of the GNU Lesser General Public License as published
00014 //  by the Free Software Foundation; either version 2.1 of the License, or
00015 //  any later version.
00016 //
00017 //  The GPSTk is distributed in the hope that it will be useful,
00018 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //  GNU Lesser General Public License for more details.
00021 //
00022 //  You should have received a copy of the GNU Lesser General Public
00023 //  License along with GPSTk; if not, write to the Free Software Foundation,
00024 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 //
00026 //  Wei Yan - Chinese Academy of Sciences . 2011
00027 //
00028 //============================================================================
00029 
00030 #include "ARSimple.hpp"
00031 
00032 
00033 namespace gpstk
00034 {
00035    Vector<double> ARSimple::resolveIntegerAmbiguity( 
00036                                                  const Vector<double>& ambFloat, 
00037                                                  const Matrix<double>& ambCov )
00038       throw(ARException)
00039    {
00040          // check input
00041       if( ambFloat.size()!=ambCov.rows() || ambFloat.size()!=ambCov.cols() )
00042       {
00043          ARException e("The dimension of input does not match.");
00044          GPSTK_THROW(e);
00045       }
00046 
00047       const size_t n = ambFloat.size();
00048 
00049       Vector<double> ambFixed(n,0.0);
00050       for(int i = 0; i < ambFloat.size(); i++)
00051       {
00052          const double threshold = 3.0 * std::sqrt(ambCov(i,i));
00053 
00054          double lowerValue = ambFloat(i) - threshold;
00055          double upperValue = ambFloat(i) + threshold;
00056 
00057          if( std::abs(upperValue-lowerValue) <= 1.0 )
00058          {
00059             ambFixed(i) = double( std::floor(ambFloat(i)+0.5) );
00060          }
00061          else
00062          {
00063             ambFixed(i) = ambFloat(i);       // keep it with float value
00064          }
00065       }
00066 
00067       return ambFixed;
00068 
00069    }  // End of method 'ARSimple::resolveIntegerAmbiguity()'
00070 
00071    
00072 }   // End of namespace gpstk
00073 

Generated on Tue May 22 03:30:56 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1