library of assembled shared sources

http://lass.cocamware.com

lass::num::SplineLinear< ScalarType, DataType, DataTraits > Class Template Reference

connects the data nodes with linear segments. More...

#include <spline_linear.h>

Inheritance diagram for lass::num::SplineLinear< ScalarType, DataType, DataTraits >:

Inheritance graph
[legend]
Collaboration diagram for lass::num::SplineLinear< ScalarType, DataType, DataTraits >:

Collaboration graph
[legend]

Data Structures

struct  Node

Public Types

typedef DataTraits TDataTraits
typedef Spline< ScalarType,
DataType > 
TSplineBase
typedef TSplineBase::TScalar TScalar
typedef TSplineBase::TData TData
typedef TSplineBase::ControlRange TControlRange

Public Member Functions

 SplineLinear ()
template<typename PairInputIterator >
 SplineLinear (PairInputIterator iFirst, PairInputIterator iLast)
 construct a spline from a range of control/data pairs.
template<typename ScalarInputIterator , typename DataInputIterator >
 SplineLinear (ScalarInputIterator iFirstControl, ScalarInputIterator iLastControl, DataInputIterator iFirstData)
 construct a spline from seperate ranges.
const TData operator() (TScalar iX) const
 Get the linear interpolated data value that corresponds with constrol value iX.
const TData derivative (TScalar iX) const
 Get the first derivative of data value that corresponds with constrol value iX.
const TData derivative2 (TScalar iX) const
 Get the second derivative of data value that corresponds with constrol value iX.
const TData integral (TScalar iA, TScalar iB) const
 Get the integrated data value between control points iA and iB.
const bool isEmpty () const
 return true if the spline contains any nodes at all.
const TControlRange controlRange () const
 return the range of control values for which the spline can interpolate.
virtual const TData operator() (TScalar iX) const =0
virtual const TData derivative (TScalar iX) const =0
virtual const TData derivative2 (TScalar iX) const =0
virtual const TData integral (TScalar iA, TScalar iB) const =0

Private Types

typedef std::vector< NodeTNodes
typedef TNodes::const_iterator TNodeConstIterator

Private Member Functions

void init ()
const TNodeConstIterator findNode (TScalar iX) const
 binary search to find node that belongs to iX

Private Attributes

TNodes nodes_
size_t dataDimension_

Detailed Description

template<typename ScalarType, typename DataType, typename DataTraits>
class lass::num::SplineLinear< ScalarType, DataType, DataTraits >

connects the data nodes with linear segments.

Author:
Bram de Greve [BdG]

Definition at line 67 of file spline_linear.h.


Member Typedef Documentation

template<typename ScalarType , typename DataType , typename DataTraits >
typedef DataTraits lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TDataTraits

Definition at line 71 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef Spline<ScalarType, DataType> lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TSplineBase

Definition at line 72 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef TSplineBase::TScalar lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TScalar

Reimplemented from lass::num::Spline< ScalarType, DataType >.

Definition at line 73 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef TSplineBase::TData lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TData

Reimplemented from lass::num::Spline< ScalarType, DataType >.

Definition at line 74 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef TSplineBase::ControlRange lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TControlRange

Definition at line 75 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef std::vector<Node> lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TNodes [private]

Definition at line 103 of file spline_linear.h.

template<typename ScalarType , typename DataType , typename DataTraits >
typedef TNodes::const_iterator lass::num::SplineLinear< ScalarType, DataType, DataTraits >::TNodeConstIterator [private]

Definition at line 104 of file spline_linear.h.


Constructor & Destructor Documentation

template<typename S , typename D , typename T >
lass::num::SplineLinear< S, D, T >::SplineLinear (  )  [inline]

Definition at line 60 of file spline_linear.inl.

template<typename S , typename D , typename T >
template<typename PairInputIterator >
lass::num::SplineLinear< S, D, T >::SplineLinear ( PairInputIterator  iFirst,
PairInputIterator  iLast 
) [inline]

construct a spline from a range of control/data pairs.

Each node consists of a control value and a data value. This contstructor accepts a single range [iFirst, iLast) of control/data pairs. The iterator type should have two fields first and second that contain respectively the control and data values. This is choosen so that a std::pair can be used as a representatin of the control/data pair.

Precondition:
  • [iFirst, iLast) is a valid range.
  • PairInputIterator has a member first containing the control value
  • PairInputIterator has a member second containing the data value
complexity:
O(D * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • N = number of nodes

Definition at line 86 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::init(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::nodes_, lass::num::SplineLinear< ScalarType, DataType, DataTraits >::Node::x, and lass::num::SplineLinear< ScalarType, DataType, DataTraits >::Node::y.

template<typename S , typename D , typename T >
template<typename ScalarInputIterator , typename DataInputIterator >
lass::num::SplineLinear< S, D, T >::SplineLinear ( ScalarInputIterator  iFirstControl,
ScalarInputIterator  iLastControl,
DataInputIterator  iFirstData 
) [inline]

construct a spline from seperate ranges.

Each node consists of a control value and a data value. This contstructor accepts seperate ranges for control and data values. The control values are given by the range [iFirstControl , iLastControl). Of the range of the data values, only the iterator iFirstData to the the first element is given.

Precondition:
  • [iFirstControl, iLastControl) is a valid range.
  • [iFirstData, iFirstData + (iLastControl - iFirstControl)) is a valid range.
complexity:
O(D * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • N = number of nodes

Definition at line 121 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::init(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::nodes_, lass::num::SplineLinear< ScalarType, DataType, DataTraits >::Node::x, and lass::num::SplineLinear< ScalarType, DataType, DataTraits >::Node::y.


Member Function Documentation

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TData lass::num::SplineLinear< S, D, T >::operator() ( TScalar  iX  )  const [inline]

Get the linear interpolated data value that corresponds with constrol value iX.

Precondition:
this->isEmpty() == false
complexity:
O(D * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • N = number of nodes

Definition at line 149 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::findNode(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::isEmpty(), and LASS_ASSERT.

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TData lass::num::SplineLinear< S, D, T >::derivative ( TScalar  iX  )  const [inline]

Get the first derivative of data value that corresponds with constrol value iX.

As long as iX is exact on a node, it equals to lim_{dx->0} (*this(iX + dx) - *this(iX)) / dx. With linear splines, in theory the first derivative does not exist on the nodes. This function however will return the first derivative on the right of the node. *

Precondition:
this->isEmpty() == false
complexity:
O(D * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • N = number of nodes

Definition at line 179 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::findNode(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::isEmpty(), and LASS_ASSERT.

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TData lass::num::SplineLinear< S, D, T >::derivative2 ( TScalar  iX  )  const [inline]

Get the second derivative of data value that corresponds with constrol value iX.

For a linear spline, the second derivative is always zero, except on the nodes where it does not exist. This function however will always return zero, even on the nodes.

Precondition:
this->isEmpty() == false
complexity:
O(D * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • N = number of nodes

Definition at line 203 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::dataDimension_, lass::num::SplineLinear< ScalarType, DataType, DataTraits >::isEmpty(), and LASS_ASSERT.

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TData lass::num::SplineLinear< S, D, T >::integral ( TScalar  iBegin,
TScalar  iEnd 
) const [inline]

Get the integrated data value between control points iA and iB.

Precondition:
this->isEmpty() == false
complexity:
O(D * M * log(N)) with
  • D = a figure that indicates the complexity of operations on data values. Is most probably linear with the dimension of the data value
  • M = number of nodes between iA and iB.
  • N = total number of nodes in spline

Definition at line 227 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::findNode(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::isEmpty(), LASS_ASSERT, lass::stde::next(), lass::num::sqr(), and std::swap().

template<typename S , typename D , typename T >
const bool lass::num::SplineLinear< S, D, T >::isEmpty (  )  const [inline, virtual]

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TControlRange lass::num::SplineLinear< S, D, T >::controlRange (  )  const [inline, virtual]

return the range of control values for which the spline can interpolate.

complexity:
O(1)

Implements lass::num::Spline< ScalarType, DataType >.

Definition at line 296 of file spline_linear.inl.

References lass::num::SplineLinear< ScalarType, DataType, DataTraits >::nodes_.

template<typename S , typename D , typename T >
void lass::num::SplineLinear< S, D, T >::init (  )  [inline, private]

template<typename S , typename D , typename T >
const SplineLinear< S, D, T >::TNodeConstIterator lass::num::SplineLinear< S, D, T >::findNode ( TScalar  iX  )  const [inline, private]

binary search to find node that belongs to iX

Returns:
  • the index i if iX is in the interval [nodes_[i].x, nodes_[i+1].x)
  • 0 if iX is smaller than nodes_[0].x
  • nodes_.size()-2 if iX is greater than nodes_[nodes_.size()-1].x
complexity: O(ln N)

Definition at line 362 of file spline_linear.inl.

References lass::prim::distance(), LASS_ASSERT, lass::stde::next(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::nodes_, and lass::stde::prev().

Referenced by lass::num::SplineLinear< ScalarType, DataType, DataTraits >::derivative(), lass::num::SplineLinear< ScalarType, DataType, DataTraits >::integral(), and lass::num::SplineLinear< ScalarType, DataType, DataTraits >::operator()().

template<typename ScalarType , typename DataType >
virtual const TData lass::num::Spline< ScalarType, DataType >::operator() ( TScalar  iX  )  const [pure virtual, inherited]

template<typename ScalarType , typename DataType >
virtual const TData lass::num::Spline< ScalarType, DataType >::derivative ( TScalar  iX  )  const [pure virtual, inherited]

template<typename ScalarType , typename DataType >
virtual const TData lass::num::Spline< ScalarType, DataType >::derivative2 ( TScalar  iX  )  const [pure virtual, inherited]

template<typename ScalarType , typename DataType >
virtual const TData lass::num::Spline< ScalarType, DataType >::integral ( TScalar  iA,
TScalar  iB 
) const [pure virtual, inherited]


Field Documentation

template<typename ScalarType , typename DataType , typename DataTraits >
TNodes lass::num::SplineLinear< ScalarType, DataType, DataTraits >::nodes_ [private]

template<typename ScalarType , typename DataType , typename DataTraits >
size_t lass::num::SplineLinear< ScalarType, DataType, DataTraits >::dataDimension_ [private]


The documentation for this class was generated from the following files:

Generated on Mon Nov 10 14:22:10 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo