EquationSystem.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: EquationSystem.cpp 2386 2010-04-14 10:03:34Z 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 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2009
00027 //
00028 //============================================================================
00029 
00030 
00031 #include "EquationSystem.hpp"
00032 #include <iterator>
00033 
00034 namespace gpstk
00035 {
00036 
00037 
00038 
00039       // General white noise stochastic model
00040    WhiteNoiseModel EquationSystem::whiteNoiseModel;
00041 
00042 
00043 
00044       /* Add a new equation to be managed.
00045        *
00046        * @param equation   Equation object to be added.
00047        *
00048        */
00049    EquationSystem& EquationSystem::addEquation( const Equation& equation )
00050    {
00051 
00052          // Add "equation" to "equationDescriptionList"
00053       equationDescriptionList.push_back(equation);
00054 
00055          // We must "Prepare()" this EquationSystem
00056       isPrepared = false;
00057 
00058       return (*this);
00059 
00060    }  // End of method 'EquationSystem::addEquation()'
00061 
00062 
00063 
00064       /* Remove an Equation being managed. In this case the equation is
00065        * identified by its independent term.
00066        *
00067        * @param indterm  Variable object of the equation independent term
00068        *                 (measurement type).
00069        *
00070        * \warning All Equations with the same independent term will be
00071        *          erased.
00072        */
00073    EquationSystem& EquationSystem::removeEquation( const Variable& indterm )
00074    {
00075 
00076          // Create a backup list
00077       std::list<Equation> backupList;
00078 
00079          // Visit each "Equation" in "equationDescriptionList"
00080       for( std::list<Equation>::const_iterator itEq =
00081                                                 equationDescriptionList.begin();
00082            itEq != equationDescriptionList.end();
00083            ++itEq )
00084       {
00085 
00086             // If current equation has a different independent term, save it
00087          if ( (*itEq).getIndependentTerm() != indterm )
00088          {
00089             backupList.push_back(*itEq);
00090          }
00091 
00092       }
00093 
00094          // Clear the full contents of this object
00095       clearEquations();
00096 
00097          // Add each "Equation" in the backup equation list
00098       for( std::list<Equation>::const_iterator itEq = backupList.begin();
00099            itEq != backupList.end();
00100            ++itEq )
00101       {
00102          addEquation(*itEq);
00103       }
00104 
00105          // We must "Prepare()" this EquationSystem again
00106       isPrepared = false;
00107 
00108       return (*this);
00109 
00110    }  // End of method 'EquationSystem::removeEquation()'
00111 
00112 
00113 
00114       // Remove all Equation objects from this EquationSystem.
00115    EquationSystem& EquationSystem::clearEquations()
00116    {
00117          // First, clear the "equationDescriptionList"
00118       equationDescriptionList.clear();
00119 
00120       isPrepared = false;
00121 
00122       return (*this);
00123 
00124    }  // End of method 'EquationSystem::clearEquations()'
00125 
00126 
00127 
00128       /* Prepare this object to carry out its work.
00129        *
00130        * @param gData   GNSS data structure (GDS).
00131        *
00132        */
00133    EquationSystem& EquationSystem::Prepare( gnssRinex& gData )
00134    {
00135 
00136          // First, create a temporary gnssDataMap
00137       gnssDataMap myGDSMap;
00138 
00139          // Get gData into myGDSMap
00140       myGDSMap.addGnssRinex( gData );
00141 
00142          // Call the map-enabled method, and return the result
00143       return (Prepare(myGDSMap));
00144 
00145    }  // End of method 'EquationSystem::Prepare()'
00146 
00147 
00148 
00149       /* Prepare this object to carry out its work.
00150        *
00151        * @param gdsMap     Map of GNSS data structures (GDS), indexed
00152        *                   by SourceID.
00153        *
00154        */
00155    EquationSystem& EquationSystem::Prepare( gnssDataMap& gdsMap )
00156    {
00157 
00158          // Let's start storing 'current' unknowns set from 'previous' epoch
00159       oldUnknowns = currentUnknowns;
00160 
00161          // Former currentUnknowns will belong to global unknowns set
00162       varUnknowns = currentUnknowns;
00163 
00164          // Prepare set of current unknowns and list of current equations
00165       currentUnknowns = prepareCurrentUnknownsAndEquations(gdsMap);
00166 
00167         // Backup all unknowns and delete not type indexed variable in the 'currentUnknowns'
00168       allUnknowns.clear();
00169       for(VariableSet::const_iterator it = currentUnknowns.begin();
00170           it != currentUnknowns.end();
00171           it++)
00172       { allUnknowns.push_back(*it); }
00173       
00174       currentUnknowns.clear();
00175       rejectUnknowns.clear();
00176       for(std::list<Variable>::const_iterator it = allUnknowns.begin();
00177           it != allUnknowns.end();
00178           it++)
00179       {
00180            if((*it).getTypeIndexed())
00181            {
00182                currentUnknowns.insert(*it);
00183            }
00184            else
00185            {
00186                rejectUnknowns.insert(*it);
00187            }
00188       }
00189       
00190 
00191          // Now, let's update the global set of unknowns with current unknowns
00192       varUnknowns.insert( currentUnknowns.begin(), currentUnknowns.end() );
00193 
00194          // Compute phiMatrix and qMatrix
00195       getPhiQ(gdsMap);
00196 
00197          // Build prefit residuals vector
00198       getPrefit(gdsMap);
00199 
00200          // Get geometry and weights matrices
00201       getGeometryWeights(gdsMap);
00202 
00203          // Set this object as "prepared"
00204       isPrepared = true;
00205 
00206       return (*this);
00207 
00208    }  // End of method 'EquationSystem::Prepare()'
00209 
00210 
00211 
00212       // Get current sources (SourceID's) and satellites (SatID's)
00213    void EquationSystem::prepareCurrentSourceSat( gnssDataMap& gdsMap )
00214    {
00215 
00216          // Clear "currentSatSet" and "currentSourceSet"
00217       currentSatSet.clear();
00218       currentSourceSet.clear();
00219 
00220          // Insert the corresponding SatID's in "currentSatSet"
00221       currentSatSet = gdsMap.getSatIDSet();
00222 
00223          // Insert the corresponding SourceID's in "currentSourceSet"
00224       currentSourceSet = gdsMap.getSourceIDSet();
00225 
00226          // Let's return
00227       return;
00228 
00229    }  // End of method 'EquationSystem::prepareCurrentSourceSat()'
00230 
00231 
00232 
00233       // Prepare set of current unknowns and list of current equations
00234    VariableSet EquationSystem::prepareCurrentUnknownsAndEquations(
00235                                                          gnssDataMap& gdsMap )
00236    {
00237 
00238          // Let's clear the current equations list
00239       currentEquationsList.clear();
00240 
00241          // Let's create 'currentUnkSet' set
00242       VariableSet currentUnkSet;
00243 
00244          // Get "currentSatSet" and "currentSourceSet"
00245          // and stored in currentSourceSet and currentSatSet
00246       prepareCurrentSourceSat( gdsMap );
00247 
00248 
00249          // Visit each "Equation" in "equationDescriptionList"
00250       for( std::list<Equation>::const_iterator itEq =
00251                                                 equationDescriptionList.begin();
00252            itEq != equationDescriptionList.end();
00253            ++itEq )
00254       {
00255 
00256             // First, get the SourceID set for this equation description
00257          SourceIDSet equSourceSet;
00258 
00259             // Check if current equation description is valid for all sources
00260          if ( (*itEq).getEquationSource() == Variable::allSources )
00261          {
00262             equSourceSet = currentSourceSet;
00263          }
00264          else
00265          {
00266 
00267                // Check if equation description is valid for some sources
00268             if ( (*itEq).getEquationSource() == Variable::someSources )
00269             {
00270 
00271                   // We have to find the intersection between equation
00272                   // description SourceID's and available SourceID's.
00273                SourceIDSet tempSourceSet( (*itEq).getSourceSet() );
00274 
00275                   // Declare an 'insert_iterator' to be used by
00276                   // 'set_intersection' algorithm (provided by STL)
00277                std::insert_iterator< SourceIDSet >
00278                                  itOut( equSourceSet, equSourceSet.begin() );
00279 
00280                   // Let's intersect both sets
00281                set_intersection( tempSourceSet.begin(), tempSourceSet.end(),
00282                               currentSourceSet.begin(), currentSourceSet.end(),
00283                               itOut );
00284 
00285             }
00286             else
00287             {
00288                   // In this case, we take directly the source into the
00289                   // equation source set
00290                equSourceSet.insert( (*itEq).getEquationSource() );
00291             }
00292 
00293          }  // End of 'if ( (*itEq).getEquationSource() == ...'
00294          
00295             // Second, get the SatID set for this equation description
00296          SatIDSet equSatSet = (*itEq).getSatSet();
00297          
00298 
00299             // We have the SourceID set that is applicable to this
00300             // equation description.
00301 
00302             // Now we must get the satellites visible from each
00303             // particular SourceID
00304          for( SourceIDSet::const_iterator itSource = equSourceSet.begin();
00305               itSource != equSourceSet.end();
00306               ++itSource )
00307          {
00308 
00309                // Get visible satellites from this SourceID
00310             SatIDSet visibleSatSet;
00311 
00312                // Iterate through all items in the gnssDataMap
00313             for( gnssDataMap::const_iterator it = gdsMap.begin();
00314                  it != gdsMap.end();
00315                  ++it )
00316             {
00317 
00318                   // Look for current SourceID
00319                sourceDataMap::const_iterator sdmIter(
00320                                              (*it).second.find( (*itSource) ) );
00321 
00322                   // If SourceID was found, then look for satellites
00323                if( sdmIter != (*it).second.end() )
00324                {
00325 
00326                      // Iterate through corresponding 'satTypeValueMap'
00327                   for( satTypeValueMap::const_iterator stvmIter =
00328                                                       (*sdmIter).second.begin();
00329                        stvmIter != (*sdmIter).second.end();
00330                        stvmIter++ )
00331                   {
00332                         // for some sat   
00333                      if((equSatSet.size() > 0)                           &&
00334                         (equSatSet.find((*stvmIter).first) == equSatSet.end()))
00335                      {
00336                         continue;
00337                      }
00338 
00339                         // Add current SatID to 'visibleSatSet'
00340                      visibleSatSet.insert( (*stvmIter).first );
00341 
00342                   }  // End of 'for( satTypeValueMap::const_iterator ...'
00343 
00344                }  // End of 'for( sourceDataMap::const_iterator sdmIter = ...'
00345 
00346             }  // End of 'for( gnssDataMap::const_iterator it = ...'
00347 
00348                // We have the satellites visible from this SourceID
00349 
00350                
00351                // We need a copy of current Equation object description
00352             Equation tempEquation( (*itEq) );
00353 
00354                // Remove all variables from current equation
00355             tempEquation.clear();
00356 
00357                // Update equation independent term with SourceID information
00358             tempEquation.header.equationSource = (*itSource);
00359 
00360                // Now, let's visit all Variables in this equation description
00361             for( VariableSet::const_iterator itVar = (*itEq).body.begin();
00362                  itVar != (*itEq).body.end();
00363                  ++itVar )
00364             {
00365 
00366                   // We will work with a copy of current Variable
00367                Variable var( (*itVar) );
00368 
00369                   // Check what type of variable we are working on
00370 
00371                   // If variable is source-indexed, set SourceID
00372                if( var.getSourceIndexed() )
00373                {
00374                   var.setSource( (*itSource) );
00375                }
00376 
00377                   // Add this variable to current equation description. Please
00378                   // be aware that satellite-indexed variables inside current
00379                   // equations will be handled later
00380                tempEquation.addVariable(var);
00381 
00382                   // If variable is not satellite-indexed, we just need to
00383                   // add it to "currentUnkSet
00384                if( !var.getSatIndexed() )
00385                {
00386                      // Insert the result in "currentUnkSet" and
00387                      // current equation
00388                   currentUnkSet.insert(var);
00389                   //tempEquation.addVariable(var);
00390                }
00391                else
00392                {
00393                      // If variable IS satellite-indexed, we have to visit all
00394                      // visible satellites (from current SourceID) and set the
00395                      // satellite before adding variable to "currentUnkSet
00396                   for( SatIDSet::const_iterator itSat = visibleSatSet.begin();
00397                        itSat != visibleSatSet.end();
00398                        ++itSat )
00399                   {
00400 
00401                         // Set satellite
00402                      var.setSatellite( (*itSat) );
00403 
00404                         // Insert the result in "currentUnkSet" and
00405                         // current equation
00406                      currentUnkSet.insert(var);
00407                   }
00408 
00409                }  // End of 'if( !var.getSatIndexed() )...'
00410 
00411             }  // End of 'for( VariableSet::const_iterator itVar = ...'
00412 
00413 
00414                // Let's generate the current equations starting from this
00415                // equation description. Therefore, we update equation
00416                // independent term with SatID information and add each instance
00417                // to 'currentEquationsList'.
00418             for( SatIDSet::const_iterator itSat = visibleSatSet.begin();
00419                  itSat != visibleSatSet.end();
00420                  ++itSat )
00421             {
00422                tempEquation.header.equationSat = (*itSat);
00423 
00424                   // New equation is complete: Add it to 'currentEquationsList'
00425                currentEquationsList.push_back( tempEquation );
00426             }
00427 
00428          }  // End of 'for( SourceIDSet::const_iterator itSource = ...'
00429 
00430       }  // End of 'for( std::list<Equation>::const_iterator itEq = ...'
00431 
00432 
00433          // Now we will take care of satellite-indexed variables inside each
00434          // specific "Equation" in "currentEquationsList"
00435       int eqListSize( currentEquationsList.size() );
00436       for( int i = 0; i < eqListSize; ++i )
00437       {
00438 
00439             // Get a copy of first equation on 'currentEquationsList'
00440          Equation tempEqu( currentEquationsList.front() );
00441 
00442             // Remove the original equation at the beginning of the list.
00443          currentEquationsList.pop_front();
00444 
00445             // Get a copy of variables inside this equation
00446          VariableSet varSet( tempEqu.body );
00447 
00448             // Clear the variables from this equation
00449          tempEqu.clear();
00450 
00451             // Visit each variable inside 'varSet', check if it is
00452             // satellite-indexed, and add it to equation
00453          for( VariableSet::iterator itVar = varSet.begin();
00454               itVar != varSet.end();
00455               ++itVar )
00456          {
00457 
00458                // Check if it is satellite-indexed
00459             if( !(*itVar).getSatIndexed() )
00460             {
00461                   // If not satellite-indexed, just add it back
00462                tempEqu.addVariable( (*itVar) );
00463             }
00464             else
00465             {
00466                // If 'itVar' is satellite-indexed, let's index a copy of it
00467                // and add it to equation
00468                Variable var( (*itVar) );
00469                var.setSatellite( tempEqu.header.equationSat );
00470 
00471                tempEqu.addVariable( var );
00472             }
00473 
00474          }  // End of 'for( VariableSet::iterator itVar = varSet.begin(); ...'
00475 
00476             // Our equation is ready, let's add it to the end of the list
00477          currentEquationsList.push_back( tempEqu );
00478 
00479       }  // End of 'for( int i = 0; i < eqListSize; ++i ) ...'
00480 
00481 
00482          // Return set of current unknowns
00483       return currentUnkSet;
00484 
00485    }  // End of method 'EquationSystem::prepareCurrentUnknownsAndEquations()'
00486 
00487 
00488 
00489       // Compute PhiMatrix
00490    void EquationSystem::getPhiQ( const gnssDataMap& gdsMap )
00491    {
00492 
00493       const int numVar( varUnknowns.size() );
00494 
00495          // Resize phiMatrix and qMatrix
00496       phiMatrix.resize( numVar, numVar, 0.0);
00497       qMatrix.resize( numVar, numVar, 0.0);
00498 
00499          // Set a counter
00500       int i(0);
00501 
00502          // Visit each "Variable" inside "varUnknowns"
00503       for( VariableSet::const_iterator itVar  = varUnknowns.begin();
00504            itVar != varUnknowns.end();
00505            ++itVar )
00506       {
00507 
00508             // Check if (*itVar) is inside 'currentUnknowns'
00509          if( currentUnknowns.find( (*itVar) ) != currentUnknowns.end() )
00510          {
00511 
00512                // Get a 'gnssRinex' data structure
00513             gnssRinex gRin( gdsMap.getGnssRinex( (*itVar).getSource() ) );
00514 
00515                // Prepare variable's stochastic model
00516             (*itVar).getModel()->Prepare( (*itVar).getType(),
00517                                           (*itVar).getSatellite(),
00518                                           gRin );
00519 
00520                // Now, check if this is an 'old' variable
00521             if( oldUnknowns.find( (*itVar) ) != oldUnknowns.end() )
00522             {
00523                   // This variable is 'old'; compute its phi and q values
00524                phiMatrix(i,i) = (*itVar).getModel()->getPhi();
00525                qMatrix(i,i)   = (*itVar).getModel()->getQ();
00526             }
00527             else
00528             {
00529                   // This variable is 'new', so let's use its initial variance
00530                   // instead of its stochastic model
00531                phiMatrix(i,i) = 0.0;
00532                qMatrix(i,i)   = (*itVar).getInitialVariance();
00533             }
00534 
00535          }
00536          else
00537          {
00538                // If (*itVar) is NOT inside 'currentUnknowns', then apply it
00539                // a white noise stochastic model to decorrelate it
00540             phiMatrix(i,i) = whiteNoiseModel.getPhi();
00541             qMatrix(i,i)   = whiteNoiseModel.getQ();
00542          }
00543 
00544             // Increment counter
00545          ++i;
00546       }
00547 
00548 
00549       return;
00550 
00551    }  // End of method 'EquationSystem::getPhiQ()'
00552 
00553 
00554 
00555       // Compute prefit residuals vector
00556    void EquationSystem::getPrefit( gnssDataMap& gdsMap )
00557    {
00558 
00559          // Declare temporal storage for values
00560       std::vector<double> tempPrefit;
00561 
00562          // Visit each Equation in "currentEquationsList"
00563       for( std::list<Equation>::const_iterator itEq =
00564                                                    currentEquationsList.begin();
00565            itEq != currentEquationsList.end();
00566            ++itEq )
00567       {
00568 
00569             // Store SourceID, SatID and TypeID of current equation
00570          tempPrefit.push_back( gdsMap.getValue( (*itEq).header.equationSource,
00571                                           (*itEq).header.equationSat,
00572                                           (*itEq).header.indTerm.getType() ) );
00573 
00574 
00575       }  // End of 'for( std::list<Equation>::const_iterator itEq = ...'
00576 
00577          // Then, finally get prefit residuals into appropriate gpstk::Vector
00578       measVector = tempPrefit;
00579 
00580       return;
00581 
00582    }  // End of method 'EquationSystem::getPrefit()'
00583 
00584 
00585 
00586       // Compute hMatrix and rMatrix
00587    void EquationSystem::getGeometryWeights( gnssDataMap& gdsMap )
00588    {
00589 
00590          // Resize hMatrix and rMatrix
00591       hMatrix.resize( measVector.size(), varUnknowns.size(), 0.0);
00592       rMatrix.resize( measVector.size(),  measVector.size(), 0.0);
00593 
00594          // Let's work with the first element of the data structure
00595       gnssDataMap gds2( gdsMap.frontEpoch() );
00596 
00597          // Let's fill weights and geometry matrices
00598       int row(0);                      // Declare a counter for row number
00599       for( std::list<Equation>::const_iterator itRow =
00600                                                    currentEquationsList.begin();
00601            itRow != currentEquationsList.end();
00602            ++itRow )
00603       {
00604 
00605             // Create temporal GDS objects
00606          SourceID source( (*itRow).header.equationSource );
00607          SatID sat( (*itRow).header.equationSat );
00608 
00609             // Get a TypeIDSet with all the data types present in current GDS
00610             // Declare an appropriate object
00611          TypeIDSet typeSet;
00612 
00613             // We need a flag
00614          bool found( false );
00615 
00616             // Iterate through data structure
00617          for( gnssDataMap::const_iterator itGDS = gds2.begin();
00618               itGDS != gds2.end() && !found;
00619               ++itGDS )
00620          {
00621                // Look for source
00622             sourceDataMap::const_iterator itSDM = (*itGDS).second.find(source);
00623             if( itSDM != (*itGDS).second.end() )
00624             {
00625                   // Get the types
00626                typeSet = (*itSDM).second.getTypeID();
00627                found = true;
00628             }
00629          }
00630 
00631 
00632             // First, fill weights matrix
00633             // Check if current GDS has weight info. If you don't want those
00634             // weights to get into equations, please don't put them in GDS
00635          if( typeSet.find(TypeID::weight) != typeSet.end() )
00636          {
00637                // Weights matrix = Equation weight * observation weight
00638             rMatrix(row,row) = (*itRow).header.constWeight
00639                                * gds2.getValue(source, sat, TypeID::weight);
00640          }
00641          else
00642          {
00643                // Weights matrix = Equation weight
00644             rMatrix(row,row) = (*itRow).header.constWeight;
00645          }
00646 
00647             // Second, fill geometry matrix: Look for equation coefficients
00648          int col(0);                   // Declare a counter for column number
00649          for( VariableSet::const_iterator itCol = varUnknowns.begin();
00650               itCol != varUnknowns.end();
00651               ++itCol )
00652          {
00653 
00654                // Check if unknown is in current equation and also is marked
00655                // as a current unknown
00656             if( (*itRow).body.find( (*itCol) ) != (*itRow).body.end() &&
00657                 currentUnknowns.find( (*itCol) ) != currentUnknowns.end() )
00658             {
00659 
00660                   // Check if '(*itCol)' unknown variable enforces a specific
00661                   // coefficient
00662                if( (*itCol).isDefaultForced() )
00663                {
00664                      // Use default coefficient
00665                   hMatrix(row,col) = (*itCol).getDefaultCoefficient();
00666                }
00667                else
00668                {
00669                      // Look the coefficient in provided data
00670 
00671                      // Get type of current varUnknown
00672                   TypeID type( (*itCol).getType() );
00673 
00674                      // Check if this type has an entry in current GDS type set
00675                   if( typeSet.find(type) != typeSet.end() )
00676                   {
00677                         // If type was found, insert value into hMatrix
00678                      hMatrix(row,col) = gds2.getValue(source, sat, type);
00679                   }
00680                   else
00681                   {
00682                         // If value for current type is not in gdsMap, then
00683                         // insert default coefficient for this variable
00684                      hMatrix(row,col) = (*itCol).getDefaultCoefficient();
00685                   }
00686 
00687                }  // End of 'if( (*itCol).isDefaultForced() ) ...'
00688 
00689             }  // End of 'if( (*itRow).body.find( (*itCol) ) != ...'
00690 
00691                // Increment column counter
00692             ++col;
00693 
00694          }  // End of 'for( VariableSet::const_iterator itCol = ...'
00695 
00696             // Handle type index variable
00697          for( VariableSet::const_iterator itCol = (*itRow).body.begin();
00698              itCol != (*itRow).body.end();
00699              ++itCol )
00700          {
00701 
00702             VariableSet::const_iterator itr = rejectUnknowns.find( (*itCol) );
00703             if( itr == rejectUnknowns.end() || (*itr).getTypeIndexed()) continue;
00704 
00705             Variable var(*itr);
00706 
00707             col = 0;            
00708             for( VariableSet::const_iterator it = varUnknowns.begin(); it != varUnknowns.end(); it++)
00709             {
00710                 if(((*itCol).getType() == (*it).getType())                  &&
00711                    ((*itCol).getModel() == (*it).getModel())                &&
00712                    ((*itCol).getSourceIndexed() == (*it).getSourceIndexed())&&
00713                    ((*itCol).getSatIndexed() == (*it).getSatIndexed())      &&
00714                    ((*itCol).getSource() == (*it).getSource())              &&
00715                    ((*itCol).getSatellite() == (*it).getSatellite())        
00716                    )
00717                 {
00718                     break;
00719                 }
00720 
00721                 col++;    
00722             }
00723 
00724             
00725             // Check if '(*itCol)' unknown variable enforces a specific
00726             // coefficient
00727             if( (*itCol).isDefaultForced() )
00728             {
00729                    // Use default coefficient
00730                 hMatrix(row,col) = (*itCol).getDefaultCoefficient();
00731             }
00732             else
00733             {
00734                 // Look the coefficient in provided data
00735 
00736                    // Get type of current varUnknown
00737                 TypeID type( (*itCol).getType() );
00738 
00739                    // Check if this type has an entry in current GDS type set
00740                 if( typeSet.find(type) != typeSet.end() )
00741                 {
00742                        // If type was found, insert value into hMatrix
00743                     hMatrix(row,col) = gds2.getValue(source, sat, type);
00744                 }
00745                 else
00746                 {
00747                       // If value for current type is not in gdsMap, then
00748                       // insert default coefficient for this variable
00749                     hMatrix(row,col) = (*itCol).getDefaultCoefficient();
00750                 }
00751 
00752             }  // End of 'if( (*itCol).isDefaultForced() ) ...'
00753             
00754          }
00755 
00756             // Increment row number
00757          ++row;
00758 
00759       }  // End of 'std::list<Equation>::const_iterator itRow = ...'
00760 
00761 
00762       return;
00763 
00764    }  // End of method 'EquationSystem::getGeometryWeights()'
00765 
00766 
00767 
00768       /* Return the TOTAL number of variables being processed.
00769        *
00770        * \warning You must call method Prepare() first, otherwise this
00771        * method will throw an InvalidEquationSystem exception.
00772        */
00773    int EquationSystem::getTotalNumVariables() const
00774       throw(InvalidEquationSystem)
00775    {
00776 
00777          // If the object as not ready, throw an exception
00778       if (!isPrepared)
00779       {
00780          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00781       }
00782 
00783       return varUnknowns.size();
00784 
00785    }  // End of method 'EquationSystem::getTotalNumVariables()'
00786 
00787 
00788 
00789       /* Return the set containing all variables being processed.
00790        *
00791        * \warning You must call method Prepare() first, otherwise this
00792        * method will throw an InvalidEquationSystem exception.
00793        */
00794    VariableSet EquationSystem::getVarUnknowns() const
00795       throw(InvalidEquationSystem)
00796    {
00797 
00798          // If the object as not ready, throw an exception
00799       if (!isPrepared)
00800       {
00801          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00802       }
00803 
00804       return varUnknowns;
00805 
00806    }  // End of method 'EquationSystem::getVarUnknowns()'
00807 
00808 
00809 
00810       /* Return the CURRENT number of variables, given the current equation
00811        * system definition and the GDS's involved.
00812        *
00813        * \warning You must call method Prepare() first, otherwise this
00814        * method will throw an InvalidEquationSystem exception.
00815        */
00816    int EquationSystem::getCurrentNumVariables() const
00817       throw(InvalidEquationSystem)
00818    {
00819 
00820          // If the object as not ready, throw an exception
00821       if (!isPrepared)
00822       {
00823          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00824       }
00825 
00826       return currentUnknowns.size();
00827 
00828    }  // End of method 'EquationSystem::getCurrentNumVariables()'
00829 
00830 
00831 
00832       /* Return the set containing variables being currently processed.
00833        *
00834        * \warning You must call method Prepare() first, otherwise this
00835        * method will throw an InvalidEquationSystem exception.
00836        */
00837    VariableSet EquationSystem::getCurrentUnknowns() const
00838       throw(InvalidEquationSystem)
00839    {
00840 
00841          // If the object as not ready, throw an exception
00842       if (!isPrepared)
00843       {
00844          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00845       }
00846 
00847       return currentUnknowns;
00848 
00849    }  // End of method 'EquationSystem::getCurrentUnknowns()'
00850 
00851 
00852 
00853       /* Return the CURRENT number of sources, given the current equation
00854        * system definition and the GDS's involved.
00855        *
00856        * \warning You must call method Prepare() first, otherwise this
00857        * method will throw an InvalidEquationSystem exception.
00858        */
00859    int EquationSystem::getCurrentNumSources() const
00860       throw(InvalidEquationSystem)
00861    {
00862 
00863          // If the object as not ready, throw an exception
00864       if (!isPrepared)
00865       {
00866          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00867       }
00868 
00869       return currentSourceSet.size();
00870 
00871    }  // End of method 'EquationSystem::getCurrentNumSources()'
00872 
00873 
00874 
00875       /* Return the set containing sources being currently processed.
00876        *
00877        * \warning You must call method Prepare() first, otherwise this
00878        * method will throw an InvalidEquationSystem exception.
00879        */
00880    SourceIDSet EquationSystem::getCurrentSources() const
00881       throw(InvalidEquationSystem)
00882    {
00883 
00884          // If the object as not ready, throw an exception
00885       if (!isPrepared)
00886       {
00887          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00888       }
00889 
00890       return currentSourceSet;
00891 
00892    }  // End of method 'EquationSystem::getCurrentSources()'
00893 
00894 
00895 
00896       /* Return the CURRENT number of satellites, given the current equation
00897        * system definition and the GDS's involved.
00898        *
00899        * \warning You must call method Prepare() first, otherwise this
00900        * method will throw an InvalidEquationSystem exception.
00901        */
00902    int EquationSystem::getCurrentNumSats() const
00903       throw(InvalidEquationSystem)
00904    {
00905 
00906          // If the object as not ready, throw an exception
00907       if (!isPrepared)
00908       {
00909          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00910       }
00911 
00912       return currentSatSet.size();
00913 
00914    }  // End of method 'EquationSystem::getCurrentNumSats()'
00915 
00916 
00917 
00918       /* Return the set containing satellites being currently processed.
00919        *
00920        * \warning You must call method Prepare() first, otherwise this
00921        * method will throw an InvalidEquationSystem exception.
00922        */
00923    SatIDSet EquationSystem::getCurrentSats() const
00924       throw(InvalidEquationSystem)
00925    {
00926 
00927          // If the object as not ready, throw an exception
00928       if (!isPrepared)
00929       {
00930          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00931       }
00932 
00933       return currentSatSet;
00934 
00935    }  // End of method 'EquationSystem::getCurrentSats()'
00936 
00937 
00938 
00939       /* Get prefit residuals GPSTk Vector, given the current equation
00940        *  system definition and the GDS' involved.
00941        *
00942        * \warning You must call method Prepare() first, otherwise this
00943        * method will throw an InvalidEquationSystem exception.
00944        */
00945    Vector<double> EquationSystem::getPrefitsVector() const
00946       throw(InvalidEquationSystem)
00947    {
00948 
00949          // If the object as not ready, throw an exception
00950       if (!isPrepared)
00951       {
00952          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00953       }
00954 
00955       return measVector;
00956 
00957    }  // End of method 'EquationSystem::getPrefitsVector()'
00958 
00959 
00960 
00961       /* Get geometry matrix, given the current equation system definition
00962        *  and the GDS' involved.
00963        *
00964        * \warning You must call method Prepare() first, otherwise this
00965        * method will throw an InvalidEquationSystem exception.
00966        */
00967    Matrix<double> EquationSystem::getGeometryMatrix() const
00968       throw(InvalidEquationSystem)
00969    {
00970 
00971          // If the object as not ready, throw an exception
00972       if (!isPrepared)
00973       {
00974          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00975       }
00976 
00977       return hMatrix;
00978 
00979    }  // End of method 'EquationSystem::getGeometryMatrix()'
00980 
00981 
00982 
00983       /* Get weights matrix, given the current equation system definition
00984        *  and the GDS' involved.
00985        *
00986        * \warning You must call method Prepare() first, otherwise this
00987        * method will throw an InvalidEquationSystem exception.
00988        */
00989    Matrix<double> EquationSystem::getWeightsMatrix() const
00990       throw(InvalidEquationSystem)
00991    {
00992 
00993          // If the object as not ready, throw an exception
00994       if (!isPrepared)
00995       {
00996          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
00997       }
00998 
00999       return rMatrix;
01000 
01001    }  // End of method 'EquationSystem::getWeightsMatrix()'
01002 
01003 
01004       /* Get the State Transition Matrix (PhiMatrix), given the current
01005        * equation system definition and the GDS' involved.
01006        *
01007        * \warning You must call method Prepare() first, otherwise this
01008        * method will throw an InvalidEquationSystem exception.
01009        */
01010    Matrix<double> EquationSystem::getPhiMatrix() const
01011       throw(InvalidEquationSystem)
01012    {
01013 
01014          // If the object as not ready, throw an exception
01015       if (!isPrepared)
01016       {
01017          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
01018       }
01019 
01020       return phiMatrix;
01021 
01022    }  // End of method 'EquationSystem::getPhiMatrix()'
01023 
01024 
01025 
01026       /* Get the Process Noise Covariance Matrix (QMatrix), given the
01027        * current equation system definition and the GDS' involved.
01028        *
01029        * \warning You must call method Prepare() first, otherwise this
01030        * method will throw an InvalidEquationSystem exception.
01031        */
01032    Matrix<double> EquationSystem::getQMatrix() const
01033       throw(InvalidEquationSystem)
01034    {
01035 
01036          // If the object as not ready, throw an exception
01037       if (!isPrepared)
01038       {
01039          GPSTK_THROW(InvalidEquationSystem("EquationSystem is not prepared"));
01040       }
01041 
01042       return qMatrix;
01043 
01044    }  // End of method 'EquationSystem::getQMatrix()'
01045 
01046 
01047 
01048 }  // End of namespace gpstk

Generated on Thu Sep 9 03:30:52 2010 for GPS ToolKit Software Library by  doxygen 1.3.9.1