Equation.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Equation.hpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00008 #ifndef GPSTK_EQUATION_HPP
00009 #define GPSTK_EQUATION_HPP
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00028 //
00029 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2009, 2011
00030 //
00031 //============================================================================
00032 
00033 
00034 
00035 #include "DataStructures.hpp"
00036 #include "StochasticModel.hpp"
00037 #include "Variable.hpp"
00038 
00039 
00040 namespace gpstk
00041 {
00042 
00045 
00046 
00048    struct equationHeader
00049    {
00050 
00052       SourceID equationSource;
00053 
00054 
00056       SatID equationSat;
00057 
00058 
00063       std::set<SourceID> equationSourceSet;
00064       
00065 
00069       std::set<SatID> equationSatSet;
00070 
00071 
00073       Variable indTerm;
00074 
00075 
00080       double constWeight;
00081 
00082 
00084       equationHeader()
00085          : equationSource(Variable::allSources), equationSat(Variable::allSats),
00086            constWeight(1.0) {};
00087 
00088 
00096       equationHeader( const SourceID& source,
00097                       const SatID& sat,
00098                       const Variable indep,
00099                       const double& cweight )
00100          : equationSource(source), equationSat(sat), indTerm(indep),
00101            constWeight(cweight) {};
00102 
00103 
00108       equationHeader(const Variable& indep)
00109          : equationSource(Variable::allSources), equationSat(Variable::allSats),
00110            indTerm(indep), constWeight(1.0) {};
00111 
00112 
00114       virtual equationHeader& operator=(const equationHeader& right);
00115 
00116 
00121       virtual equationHeader& operator=(const Variable& indep)
00122       { indTerm = indep; return (*this); };
00123 
00124 
00126       virtual ~equationHeader() {};
00127 
00128 
00129    }; // End of struct 'equationHeader'
00130 
00131 
00132 
00136    struct Equation : gnssData<equationHeader, VariableSet>
00137    {
00138 
00140       Equation();
00141 
00142 
00148       Equation( const equationHeader& head )
00149       { header = head; };
00150 
00151 
00157       Equation( const Variable& indep );
00158 
00159 
00165       Equation( const TypeID& type );
00166 
00167 
00187       Equation( const gnssEquationDefinition& gnssEq );
00188 
00189 
00191       virtual Variable getIndependentTerm() const
00192       { return header.indTerm; };
00193 
00194 
00199       virtual Equation& setIndependentTerm(const Variable& var)
00200       { header = var; return (*this); };
00201 
00202 
00204       virtual double getWeight() const
00205       { return header.constWeight; };
00206 
00207 
00212       virtual Equation& setWeight(const double& cweight)
00213       { header.constWeight = cweight; return (*this); };
00214 
00215 
00220       virtual Equation& addVariable(const Variable& var)
00221       { body.insert(var); return (*this); };
00222 
00223 
00237       virtual Equation& addVariable( const TypeID& type,
00238                                      StochasticModel* pModel   =
00239                                                       &Variable::defaultModel,
00240                                      bool sourceIndexed        = true,
00241                                      bool satIndexed           = false,
00242                                      double variance           = 4.0e14,
00243                                      double coef               = 1.0 );
00244 
00245 
00250       virtual Equation& removeVariable(const Variable& var)
00251       { body.erase(var); return (*this); };
00252 
00253 
00260       virtual Equation& clear()
00261       { body.clear(); return (*this); };
00262 
00263 
00265       SourceID getEquationSource() const
00266       { return header.equationSource; };
00267 
00269       SatID getEquationSat() const
00270       { return header.equationSat; };
00271 
00272 
00276       std::set<SourceID> getSourceSet() const
00277       { return header.equationSourceSet; };
00278       
00279 
00283       std::set<SatID> getSatSet() const
00284       { return header.equationSatSet; };
00285 
00286 
00290       Equation& addSource2Set( const SourceID& source )
00291       { header.equationSourceSet.insert(source); return (*this); };
00292 
00293       
00296       Equation& addSat2Set( const SatID& sat )
00297       { header.equationSatSet.insert(sat); return (*this); };
00298 
00299 
00303       Equation& clearSourceSet()
00304       { header.equationSourceSet.clear(); return (*this); };
00305 
00306 
00310       Equation& clearSatSet()
00311       { header.equationSatSet.clear(); return (*this); };
00312 
00313 
00317       virtual bool operator<(const Equation& right) const
00318       { return (header.indTerm < right.header.indTerm); };
00319 
00320 
00322       virtual ~Equation() {};
00323 
00324 
00325    }; // End of struct 'Equation'
00326 
00327 
00328    namespace StringUtils
00329    {
00330       inline std::string asString(const VariableSet& vset)
00331       {
00332          std::ostringstream oss;
00333          for( VariableSet::const_iterator it = vset.begin();
00334               it != vset.end();
00335               ++it )
00336          {
00337             oss << it->getType() << "   "
00338                 << it->getSource() << "   "
00339                 << it->getSatellite() << "   "
00340                 << it->getTypeIndexed() << " "
00341                 << it->getSourceIndexed() << " "
00342                 << it->getSatIndexed()<< std::endl;
00343          }
00344          
00345          return oss.str();
00346       }
00347    }
00348 
00350 
00351 }  // End of namespace gpstk
00352 
00353 #endif   // GPSTK_EQUATION_HPP

Generated on Tue May 21 03:31:08 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1