SourcePro® C++ API Reference Guide

Product Documentation:
   SourcePro C++
Documentation Home
List of all members | Public Member Functions
RWAddObservations< T, S > Class Template Reference

Holds information about adding observations to a parameter calculation. More...

#include <rw/analytics/regcalc.h>

Inheritance diagram for RWAddObservations< T, S >:
RWRegressionDataChange< T, S >

Public Member Functions

 RWAddObservations ()
 
 RWAddObservations (const RWAddObservations< T, S > &a)
 
 RWAddObservations (const RWGenMat< T > &r, const RWMathVec< S > o, size_t numAdded, bool setBaseToLast=false)
 
int numAdded () const
 
void setNumAdded (int na)
 
- Public Member Functions inherited from RWRegressionDataChange< T, S >
bool baseToLast () const
 
const RWMathVec< S > & newObservationVec () const
 
const RWGenMat< T > & newRegressionMat () const
 
void setBaseToLast (bool s)
 
void setNewObservationVec (const RWMathVec< S > &o)
 
void setNewRegressionMat (const RWGenMat< T > &r)
 

Detailed Description

template<class T, class S>
class RWAddObservations< T, S >

Class RWAddObservations holds information about adding observations to a parameter calculation object's base calculation. This information must consist of the following:

Synopsis
#include <rw/analytics/regcalc.h>
Example
#include <rw/analytics/lsqqr.h>
#include <rw/rstream.h>
int main()
{
// Full model regression matrix.
RWGenMat<double> regMat( "6x3 [1 1.3 .54 \
1 3.5 .65 \
1 -2.3 .88 \
1 8.2 .76 \
1 -4.2 .32 \
1 2.4 .43]" );
// Reduced model regression matrix. Contains the first 5
// rows of regMat.
RWGenMat<double> reducedRegMat( regMat(RWSlice(0,5),RWAll) );
// Full model observation vector.
RWMathVec<double> observationVec( "[12.3 15.6 22.3
44.1 32.5 65.2]" );
// Reduced model observation vector. Contains the first 5
// elements of the full model observation vector.
RWMathVec<double> reducedObservationVec(
observationVec(RWSlice(0,5)) );
RWLeastSqQRCalc calcObject;
// Set the base calculation for the parameter calculation
// object to the reduced regression matrix.
calcObject.setBaseCalc( reducedRegMat,
reducedObservationVec );
if ( calcObject.fail() )
{
cout << "Parameter calculation for reduced model failed" <<
endl;
return 1;
}
cout << "Parameters for reduced model:" <<
calcObject.parameters() << endl;
// Add the observation contained in the last row of the full
// model regression matrix using the data change class
// RWAddObservations.
observationVec, 1 );
calcObject.addObsToBaseCalc( dataChange );
if ( calcObject.fail() )
{
cout << "Parameter calculation for full model failed" <<
endl;
return 1;
}
cout << "Parameters for full model:" <<
calcObject.parameters() << endl;
return 0;
}

Constructor & Destructor Documentation

template<class T, class S>
RWAddObservations< T, S >::RWAddObservations ( )
inline

Default constructor. Constructs an empty RWAddObservations object.

template<class T, class S>
RWAddObservations< T, S >::RWAddObservations ( const RWAddObservations< T, S > &  a)
inline

Copy constructor. Constructs a copy of a.

template<class T, class S>
RWAddObservations< T, S >::RWAddObservations ( const RWGenMat< T > &  r,
const RWMathVec< S >  o,
size_t  numAdded,
bool  setBaseToLast = false 
)
inline

Constructs an RWAddObservations object with the given regression matrix and observation vector. It assumes that the matrix r is obtained from the base calculations regression matrix by appending numAdded rows, and that the observation vector o is obtained from the base calculations by appending numAdded values. If setBaseToLast is true, the base calculations regression matrix is set to r.

Member Function Documentation

template<class T, class S>
int RWAddObservations< T, S >::numAdded ( ) const
inline

Returns the number of observations added.

template<class T, class S>
void RWAddObservations< T, S >::setNumAdded ( int  na)
inline

Sets the number of observations added.

Copyright © 2016 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.