Jpp  16.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
JTOOLS::JSplineFunctionalMap< JKey_t, JValue_t, JDistance_t > Struct Template Referenceabstract

Type definition of a spline interpolation based on a JMap implementation. More...

#include <JFunctionalMap_t.hh>

Inheritance diagram for JTOOLS::JSplineFunctionalMap< JKey_t, JValue_t, JDistance_t >:
JTOOLS::JSplineMap< JKey_t, JValue_t, JMap, JResultType< JValue_t >::result_type, JDistance_t > JTOOLS::JMap< JKey_t, JValue_t, JDistance_t > JTOOLS::JFunction< JKey_t, JResultType< JValue_t >::result_type > JTOOLS::JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > JMATH::JMath< JFirst_t, JSecond_t > JTOOLS::JFunctional< JKey_t, JResultType< JValue_t >::result_type > std::vector< JElement_t, JAllocator_t > JTOOLS::JMappableCollection< JKey_t, JValue_t > JTOOLS::JAbstractCollection< JAbscissa_t > JMATH::JMath< JFirst_t, JSecond_t >

Public Types

typedef JMap< JKey_t, JValue_t,
JDistance_t > 
collection_type
 
typedef JFunction< JKey_t,
JResultType< JValue_t >
::result_type
function_type
 
typedef
collection_type::abscissa_type 
abscissa_type
 
typedef
collection_type::ordinate_type 
ordinate_type
 
typedef collection_type::value_type value_type
 
typedef
collection_type::distance_type 
distance_type
 
typedef
collection_type::const_iterator 
const_iterator
 
typedef
collection_type::const_reverse_iterator 
const_reverse_iterator
 
typedef collection_type::iterator iterator
 
typedef
collection_type::reverse_iterator 
reverse_iterator
 
typedef
function_type::argument_type 
argument_type
 
typedef function_type::result_type result_type
 
typedef
function_type::JExceptionHandler 
exceptionhandler_type
 
typedef JResultType
< ordinate_type >::result_type 
data_type
 
typedef JSplineFunction1D
< JSplineElement2D
< argument_type, data_type >
, JMapCollection< JMap >
::template collection_type,
result_type
JSplineFunction1D_t
 
typedef JKey_t key_type
 
typedef JValue_t mapped_type
 
typedef JCollection
< JElement2D< JKey_t, JValue_t >
, JDistance_t > 
container_type
 
typedef
JCollectionElementTransformer
< value_type
transformer_type
 
typedef std::pair
< const_iterator, bool > 
pair_type
 
typedef JFunctional< JKey_t,
JResultType< JValue_t >
::result_type
functional_type
 
typedef JSupervisor supervisor_type
 

Public Member Functions

virtual result_type evaluate (const argument_type *pX) const override
 Recursive interpolation method implementation. More...
 
JMapadd (const JMap &map)
 Add map. More...
 
JCollectionadd (const JCollection &collection)
 Add collection. More...
 
JCollectionadd (typename JClass< ordinate_type >::argument_type value)
 Add offset. More...
 
JCollectionadd (const JFunction1D_t &function)
 Add function. More...
 
JMapsub (const JMap &map)
 Subtract map. More...
 
JCollectionsub (const JCollection &collection)
 Subtract collection. More...
 
JCollectionsub (typename JClass< ordinate_type >::argument_type value)
 Subtract offset. More...
 
JCollectionsub (const JFunction1D_t &function)
 Subtract function. More...
 
JMapmul (const double value)
 Scale contents. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 
JMapdiv (const double value)
 Scale contents. More...
 
virtual void clear () override
 Clear. More...
 
virtual const ordinate_typeget (typename JClass< abscissa_type >::argument_type x) const override
 Get ordinate value. More...
 
virtual ordinate_typeget (typename JClass< abscissa_type >::argument_type x) override
 Get ordinate value. More...
 
virtual const mapped_typeget (typename JClass< key_type >::argument_type key) const =0
 Get mapped value. More...
 
virtual mapped_typeget (typename JClass< key_type >::argument_type key)=0
 Get mapped value. More...
 
virtual int getSize () const override
 Get number of elements. More...
 
virtual abscissa_type getX (int index) const override
 Get abscissa value. More...
 
virtual abscissa_type getXmin () const override
 Get minimal abscissa value. More...
 
virtual abscissa_type getXmax () const override
 Get maximal abscissa value. More...
 
const ordinate_typegetY (int index) const
 Get ordinate value. More...
 
ordinate_typegetY (int index)
 Get ordinate value. More...
 
void transform (const transformer_type &transformer)
 Transform collection. More...
 
void sort ()
 Sort elements. More...
 
const_iterator lower_bound (typename JClass< abscissa_type >::argument_type x) const
 Get first position of element i, where x >= i->getX(). More...
 
iterator lower_bound (typename JClass< abscissa_type >::argument_type x)
 Get first position of element i, where x >= i->getX(). More...
 
pair_type insert (const value_type &element)
 Insert element. More...
 
void configure (const JAbstractCollection< abscissa_type > &bounds)
 Configure collection. More...
 
void configure (const JAbstractCollection< abscissa_type > &bounds, typename JClass< ordinate_type >::argument_type value)
 Configure collection. More...
 
void configure (const JAbstractCollection< abscissa_type > &bounds, const JFunction1D_t &function)
 Configure collection. More...
 
bool is_compatible (const JCollection &collection) const
 Test whether collections are compatible. More...
 
JCollectionnegate ()
 Negate collection. More...
 
const JComparatorgetComparator () const
 Get comparator. More...
 
const mapped_typeoperator[] (typename JClass< key_type >::argument_type key) const
 Get mapped value. More...
 
mapped_typeoperator[] (typename JClass< key_type >::argument_type key)
 Get mapped value. More...
 
void put (typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
 Put pair-wise element (key,value) into collection. More...
 
bool is_equal (const JAbstractCollection &collection) const
 Test whether abstract collections are equal. More...
 
JSupervisor getSupervisor () const
 Get supervisor. More...
 
const JExceptionHandler & getExceptionHandler () const
 Get exception handler. More...
 
void setExceptionHandler (const JSupervisor &supervisor)
 Set the supervisor for handling of exceptions. More...
 

Static Public Member Functions

static result_type getValue (const JFunctional &function, const argument_type *pX)
 Recursive function value evaluation. More...
 
static JClass< result_type >
::argument_type 
getValue (typename JClass< result_type >::argument_type value, const argument_type *pX)
 Termination of recursive function value evaluation. More...
 

Public Attributes

JDistance_t getDistance
 Function object for distance evaluation. More...
 

Protected Member Functions

void resize (typename container_type::size_type size)
 Resize collection. More...
 

Protected Attributes

JComparator compare
 Function object for comparison. More...
 
JSupervisor supervisor
 

Detailed Description

template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
struct JTOOLS::JSplineFunctionalMap< JKey_t, JValue_t, JDistance_t >

Type definition of a spline interpolation based on a JMap implementation.

Definition at line 28 of file JFunctionalMap_t.hh.

Member Typedef Documentation

typedef JMap <JKey_t, JValue_t, JDistance_t> JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::collection_type
inherited

Definition at line 725 of file JSpline.hh.

typedef JFunction<JKey_t, JResultType< JValue_t >::result_type > JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::function_type
inherited

Definition at line 726 of file JSpline.hh.

typedef collection_type::abscissa_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::abscissa_type
inherited

Definition at line 728 of file JSpline.hh.

typedef collection_type::ordinate_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::ordinate_type
inherited

Definition at line 729 of file JSpline.hh.

typedef collection_type::value_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::value_type
inherited

Definition at line 730 of file JSpline.hh.

typedef collection_type::distance_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::distance_type
inherited

Definition at line 731 of file JSpline.hh.

typedef collection_type::const_iterator JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::const_iterator
inherited

Definition at line 733 of file JSpline.hh.

typedef collection_type::const_reverse_iterator JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::const_reverse_iterator
inherited

Definition at line 734 of file JSpline.hh.

typedef collection_type::iterator JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::iterator
inherited

Definition at line 735 of file JSpline.hh.

typedef collection_type::reverse_iterator JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::reverse_iterator
inherited

Definition at line 736 of file JSpline.hh.

typedef function_type::argument_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::argument_type
inherited

Definition at line 738 of file JSpline.hh.

typedef function_type::result_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::result_type
inherited

Definition at line 739 of file JSpline.hh.

typedef function_type::JExceptionHandler JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::exceptionhandler_type
inherited

Definition at line 740 of file JSpline.hh.

typedef JResultType<ordinate_type>::result_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::data_type
inherited

Definition at line 742 of file JSpline.hh.

Definition at line 745 of file JSpline.hh.

template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
typedef JKey_t JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::key_type
inherited

Definition at line 36 of file JMap.hh.

template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
typedef JValue_t JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::mapped_type
inherited

Definition at line 37 of file JMap.hh.

template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
typedef JCollection<JElement2D<JKey_t, JValue_t>, JDistance_t> JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::container_type
inherited

Definition at line 39 of file JMap.hh.

typedef JCollectionElementTransformer<value_type> JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::transformer_type
inherited

Definition at line 96 of file JCollection.hh.

typedef std::pair<const_iterator, bool> JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::pair_type
inherited

Definition at line 97 of file JCollection.hh.

typedef JFunctional<JKey_t , JResultType< JValue_t >::result_type > JTOOLS::JFunction< JKey_t , JResultType< JValue_t >::result_type >::functional_type
inherited

Definition at line 306 of file JFunctional.hh.

typedef JSupervisor JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::supervisor_type
inherited

Definition at line 89 of file JFunctional.hh.

Member Function Documentation

virtual result_type JTOOLS::JSplineMap< JKey_t, JValue_t, JMap , JResultType< JValue_t >::result_type , JDistance_t >::evaluate ( const argument_type pX) const
inlineoverridevirtualinherited

Recursive interpolation method implementation.

Parameters
pXpointer to abscissa values
Returns
function value

Implements JTOOLS::JFunctional< JKey_t, JResultType< JValue_t >::result_type >.

Definition at line 761 of file JSpline.hh.

762  {
763  const argument_type x = *pX;
764 
765  ++pX; // next argument value
766 
767  const_iterator p = this->begin();
768 
769  for (typename JSplineFunction1D_t::iterator q = buffer.begin(); q != buffer.end(); ++q, ++p) {
770  q->getY() = JFunction<argument_type, data_type>::getValue(p->getY(), pX);
771  }
772 
773  buffer.compile();
774 
775  return buffer(x);
776  }
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
JMap& JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::add ( const JMap< JKey_t, JValue_t, JDistance_t > &  map)
inlineinherited

Add map.

Parameters
mapmap
Returns
this map

Definition at line 60 of file JMap.hh.

61  {
62  static_cast<container_type&>(*this).add(static_cast<const container_type&>(map));
63 
64  return *this;
65  }
JCollection & add(const JCollection &collection)
Add collection.
Definition: JCollection.hh:454
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > container_type
Definition: JMap.hh:39
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::add ( const JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > &  collection)
inlineinherited

Add collection.

Parameters
collectioncollection
Returns
this collection

Definition at line 454 of file JCollection.hh.

455  {
456  if (!collection.empty()) {
457 
458  if (this->empty()) {
459 
460  for (const_iterator i = collection.begin(); i != collection.end(); ++i) {
461  this->put(i->getX(), +i->getY());
462  }
463 
464  } else if (this->is_compatible(collection)) {
465 
466  const double precision = JDistance<abscissa_type>::precision;
467 
468  iterator p = this->begin();
469  const_iterator q = collection.begin();
470 
471  if (getDistance(p->getX(), q->getX()) > precision) {
472 
473  do {
474  ++p;
475  } while (p != this->end() && getDistance(p->getX(), q->getX()) > precision);
476 
477  } else if (getDistance(q->getX(), p->getX()) > precision) {
478 
479  do {
480  ++q;
481  } while (q != collection.end() && getDistance(q->getX(), p->getX()) > precision);
482  }
483 
484  const_iterator i = q;
485 
486  for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
487  p->getY() += i->getY();
488  }
489 
490  for ( ; i != collection.end(); ++i) {
491  this->put(i->getX(), +i->getY());
492  }
493 
494  for (i = collection.begin(); i != q; ++i) {
495  this->put(i->getX(), +i->getY());
496  }
497  }
498  }
499 
500  return *this;
501  }
Template class for distance evaluation.
Definition: JDistance.hh:24
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
bool is_compatible(const JCollection &collection) const
Test whether collections are compatible.
Definition: JCollection.hh:396
void put(typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::add ( typename JClass< ordinate_type >::argument_type  value)
inlineinherited

Add offset.

Parameters
valueoffset
Returns
this collection

Definition at line 602 of file JCollection.hh.

603  {
604  for (iterator i = this->begin(); i != this->end(); ++i) {
605  i->getY() += value;
606  }
607 
608  return *this;
609  }
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::add ( const JFunction1D_t &  function)
inlineinherited

Add function.

Parameters
functionfunction
Returns
this collection

Definition at line 635 of file JCollection.hh.

636  {
637  for (iterator i = this->begin(); i != this->end(); ++i) {
638  i->getY() += function(i->getX());
639  }
640 
641  return *this;
642  }
template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
JMap& JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::sub ( const JMap< JKey_t, JValue_t, JDistance_t > &  map)
inlineinherited

Subtract map.

Parameters
mapmap
Returns
this map

Definition at line 74 of file JMap.hh.

75  {
76  static_cast<container_type&>(*this).sub(static_cast<const container_type&>(map));
77 
78  return *this;
79  }
JCollection & sub(const JCollection &collection)
Subtract collection.
Definition: JCollection.hh:510
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > container_type
Definition: JMap.hh:39
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::sub ( const JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > &  collection)
inlineinherited

Subtract collection.

Parameters
collectioncollection
Returns
this collection

Definition at line 510 of file JCollection.hh.

511  {
512  if (!collection.empty()) {
513 
514  if (this->empty()) {
515 
516  for (const_iterator i = collection.begin(); i != collection.end(); ++i) {
517  this->put(i->getX(), -i->getY());
518  }
519 
520  } else if (this->is_compatible(collection)) {
521 
522  const double precision = JDistance<abscissa_type>::precision;
523 
524  iterator p = this->begin();
525  const_iterator q = collection.begin();
526 
527  if (getDistance(p->getX(), q->getX()) > precision) {
528 
529  do {
530  ++p;
531  } while (p != this->end() && getDistance(p->getX(), q->getX()) > precision);
532 
533  } else if (getDistance(q->getX(), p->getX()) > precision) {
534 
535  do {
536  ++q;
537  } while (q != collection.end() && getDistance(q->getX(), p->getX()) > precision);
538  }
539 
540  const_iterator i = q;
541 
542  for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
543  p->getY() -= i->getY();
544  }
545 
546  for ( ; i != collection.end(); ++i) {
547  this->put(i->getX(), -i->getY());
548  }
549 
550  for (i = collection.begin(); i != q; ++i) {
551  this->put(i->getX(), -i->getY());
552  }
553 
554  } else {
555 
556  throw JException("JCollection::add() collections incompatible.");
557  }
558  }
559 
560  return *this;
561  }
General exception.
Definition: JException.hh:23
Template class for distance evaluation.
Definition: JDistance.hh:24
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
bool is_compatible(const JCollection &collection) const
Test whether collections are compatible.
Definition: JCollection.hh:396
void put(typename JClass< key_type >::argument_type key, typename JClass< mapped_type >::argument_type value)
Put pair-wise element (key,value) into collection.
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::sub ( typename JClass< ordinate_type >::argument_type  value)
inlineinherited

Subtract offset.

Parameters
valueoffset
Returns
this collection

Definition at line 618 of file JCollection.hh.

619  {
620  for (iterator i = this->begin(); i != this->end(); ++i) {
621  i->getY() -= value;
622  }
623 
624  return *this;
625  }
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::sub ( const JFunction1D_t &  function)
inlineinherited

Subtract function.

Parameters
functionfunction
Returns
this collection

Definition at line 652 of file JCollection.hh.

653  {
654  for (iterator i = this->begin(); i != this->end(); ++i) {
655  i->getY() -= function(i->getX());
656  }
657 
658  return *this;
659  }
template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
JMap& JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::mul ( const double  value)
inlineinherited

Scale contents.

Parameters
valuemultiplication factor
Returns
this map

Definition at line 88 of file JMap.hh.

89  {
90  static_cast<container_type&>(*this).mul(value);
91 
92  return *this;
93  }
JCollection & mul(const double value)
Scale contents.
Definition: JCollection.hh:570
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > container_type
Definition: JMap.hh:39
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 357 of file JMath.hh.

358  {
359  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
360  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18
template<class JKey_t, class JValue_t, class JDistance_t = JDistance<JKey_t>>
JMap& JTOOLS::JMap< JKey_t, JValue_t, JDistance_t >::div ( const double  value)
inlineinherited

Scale contents.

Parameters
valuedivision factor
Returns
this map

Definition at line 101 of file JMap.hh.

102  {
103  static_cast<container_type&>(*this).div(value);
104 
105  return *this;
106  }
JCollection & div(const double value)
Scale contents.
Definition: JCollection.hh:586
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > container_type
Definition: JMap.hh:39
virtual void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::clear ( )
inlineoverridevirtualinherited

Clear.

Implements JTOOLS::JMappableCollection< JKey_t, JValue_t >.

Definition at line 150 of file JCollection.hh.

151  {
152  container_type::clear();
153  }
virtual const ordinate_type& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::get ( typename JClass< abscissa_type >::argument_type  x) const
inlineoverridevirtualinherited

Get ordinate value.

Parameters
xabscissa value
Returns
ordinate value

Definition at line 162 of file JCollection.hh.

163  {
164  const_iterator i = this->lower_bound(x);
165 
166  if (i == this->end() || this->getDistance(x, i->getX()) > distance_type::precision) {
167  THROW(JValueOutOfRange, "Invalid abscissa value " << x);
168  }
169 
170  return i->getY();
171  }
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
const_iterator lower_bound(typename JClass< abscissa_type >::argument_type x) const
Get first position of element i, where x &gt;= i-&gt;getX().
Definition: JCollection.hh:294
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
virtual ordinate_type& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::get ( typename JClass< abscissa_type >::argument_type  x)
inlineoverridevirtualinherited

Get ordinate value.

Parameters
xabscissa value
Returns
ordinate value

Definition at line 180 of file JCollection.hh.

181  {
182  iterator i = this->lower_bound(x);
183 
184  if (i == this->end() || this->getDistance(x, i->getX()) > distance_type::precision) {
185  i = container_type::insert(i, value_type(x, ordinate_type()));
186  }
187 
188  return i->getY();
189  }
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
const_iterator lower_bound(typename JClass< abscissa_type >::argument_type x) const
Get first position of element i, where x &gt;= i-&gt;getX().
Definition: JCollection.hh:294
JElement2D< JKey_t, JValue_t >::ordinate_type ordinate_type
Definition: JCollection.hh:83
template<class JKey_t, class JValue_t>
virtual const mapped_type& JTOOLS::JMappableCollection< JKey_t, JValue_t >::get ( typename JClass< key_type >::argument_type  key) const
pure virtualinherited
template<class JKey_t, class JValue_t>
virtual mapped_type& JTOOLS::JMappableCollection< JKey_t, JValue_t >::get ( typename JClass< key_type >::argument_type  key)
pure virtualinherited
virtual int JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getSize ( ) const
inlineoverridevirtualinherited

Get number of elements.

Returns
number of elements

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 197 of file JCollection.hh.

198  {
199  return (int) this->size();
200  }
virtual abscissa_type JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getX ( int  index) const
inlineoverridevirtualinherited

Get abscissa value.

Parameters
indexindex
Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 209 of file JCollection.hh.

210  {
211  return this->at(index).getX();
212  }
virtual abscissa_type JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getXmin ( ) const
inlineoverridevirtualinherited

Get minimal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 220 of file JCollection.hh.

221  {
222  return this->begin()->getX();
223  }
virtual abscissa_type JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getXmax ( ) const
inlineoverridevirtualinherited

Get maximal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 231 of file JCollection.hh.

232  {
233  return this->rbegin()->getX();
234  }
const ordinate_type& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getY ( int  index) const
inlineinherited

Get ordinate value.

Parameters
indexindex
Returns
ordinate value

Definition at line 244 of file JCollection.hh.

245  {
246  return this->at(index).getY();
247  }
ordinate_type& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getY ( int  index)
inlineinherited

Get ordinate value.

Parameters
indexindex
Returns
ordinate value

Definition at line 256 of file JCollection.hh.

257  {
258  return this->at(index).getY();
259  }
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::transform ( const transformer_type transformer)
inlineinherited

Transform collection.

Parameters
transformerelement transformer

Definition at line 267 of file JCollection.hh.

268  {
269  collection_type buffer;
270 
271  this->swap(buffer);
272 
273  for (const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
274  this->insert(transformer(*i));
275  }
276  }
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > collection_type
Definition: JCollection.hh:87
pair_type insert(const value_type &element)
Insert element.
Definition: JCollection.hh:318
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::sort ( )
inlineinherited

Sort elements.

Definition at line 282 of file JCollection.hh.

283  {
284  std::sort(this->begin(), this->end(), compare);
285  }
JComparator compare
Function object for comparison.
Definition: JCollection.hh:781
const_iterator JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::lower_bound ( typename JClass< abscissa_type >::argument_type  x) const
inlineinherited

Get first position of element i, where x >= i->getX().

Parameters
xabscissa value
Returns
position of corresponding element

Definition at line 294 of file JCollection.hh.

295  {
296  return std::lower_bound(this->begin(), this->end(), x, compare);
297  }
JComparator compare
Function object for comparison.
Definition: JCollection.hh:781
iterator JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::lower_bound ( typename JClass< abscissa_type >::argument_type  x)
inlineinherited

Get first position of element i, where x >= i->getX().

Parameters
xabscissa value
Returns
position of corresponding element

Definition at line 306 of file JCollection.hh.

307  {
308  return std::lower_bound(this->begin(), this->end(), x, compare);
309  }
JComparator compare
Function object for comparison.
Definition: JCollection.hh:781
pair_type JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::insert ( const value_type element)
inlineinherited

Insert element.

Parameters
elementelement
Returns
(iterator, status), where status is true if inserted; else false

Definition at line 318 of file JCollection.hh.

319  {
320  iterator i = this->lower_bound(element.getX());
321 
322  if (i == this->end() || this->getDistance(element.getX(), i->getX()) > 0.0)
323  return pair_type(container_type::insert(i, element), true);
324  else
325  return pair_type(this->end(), false);
326  }
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
const_iterator lower_bound(typename JClass< abscissa_type >::argument_type x) const
Get first position of element i, where x &gt;= i-&gt;getX().
Definition: JCollection.hh:294
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::configure ( const JAbstractCollection< abscissa_type > &  bounds)
inlineinherited

Configure collection.

Parameters
boundsabscissa values

Definition at line 334 of file JCollection.hh.

335  {
336  configure(bounds, JMATH::getZero<ordinate_type>());
337  }
void configure(const JAbstractCollection< abscissa_type > &bounds)
Configure collection.
Definition: JCollection.hh:334
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::configure ( const JAbstractCollection< abscissa_type > &  bounds,
typename JClass< ordinate_type >::argument_type  value 
)
inlineinherited

Configure collection.

Parameters
boundsabscissa values
valueordinate value

Definition at line 346 of file JCollection.hh.

348  {
349  this->resize(bounds.getSize());
350 
351  for (iterator i = this->begin(); i != this->end(); ++i) {
352 
353  const abscissa_type x = bounds.getX(std::distance(this->begin(),i));
354 
355  *i = value_type(x,value);
356  }
357  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
void resize(typename container_type::size_type size)
Resize collection.
Definition: JCollection.hh:789
JElement2D< JKey_t, JValue_t >::abscissa_type abscissa_type
Definition: JCollection.hh:82
virtual abscissa_type getX(int index) const =0
Get abscissa value.
virtual int getSize() const =0
Get number of elements.
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::configure ( const JAbstractCollection< abscissa_type > &  bounds,
const JFunction1D_t &  function 
)
inlineinherited

Configure collection.

Parameters
boundsabscissa values
functionfunction

Definition at line 367 of file JCollection.hh.

369  {
370  using namespace JLANG;
371 
372  collection_type* out = (is_identical(*this, function) ? new collection_type() : this);
373 
374  for (int i = 0; i != bounds.getSize(); ++i) {
375 
376  const abscissa_type x = bounds.getX(i);
377 
378  out->put(x, function(x));
379  }
380 
381  if (is_identical(*this, function)) {
382 
383  this->swap(*out);
384 
385  delete out;
386  }
387  }
JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > collection_type
Definition: JCollection.hh:87
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
JElement2D< JKey_t, JValue_t >::abscissa_type abscissa_type
Definition: JCollection.hh:82
bool is_identical(JFirst_t &first, JSecond_t &second)
Check if two objects are indentical.
Definition: JLangToolkit.hh:46
virtual abscissa_type getX(int index) const =0
Get abscissa value.
virtual int getSize() const =0
Get number of elements.
bool JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::is_compatible ( const JCollection< JElement2D< JKey_t, JValue_t >, JDistance_t > &  collection) const
inlineinherited

Test whether collections are compatible.

Parameters
collectioncollection
Returns
true if collections are compatible; else false

Definition at line 396 of file JCollection.hh.

397  {
398  if (this->empty() || collection.empty()) {
399 
400  return true;
401 
402  } else {
403 
404  const double precision = JDistance<abscissa_type>::precision;
405 
406  const_iterator p = this->begin();
407  const_iterator q = collection.begin();
408 
409  if (getDistance(p->getX(), q->getX()) > precision) {
410 
411  do {
412  ++p;
413  } while (p != this->end() && getDistance(p->getX(), q->getX()) > precision);
414 
415  } else if (getDistance(q->getX(), p->getX()) > precision) {
416 
417  do {
418  ++q;
419  } while (q != collection.end() && getDistance(q->getX(), p->getX()) > precision);
420  }
421 
422  for ( ; p != this->end() && q != collection.end(); ++p, ++q) {
423  if (fabs(getDistance(p->getX(), q->getX())) > precision) {
424  return false;
425  }
426  }
427 
428  return true;
429  }
430  }
Template class for distance evaluation.
Definition: JDistance.hh:24
JDistance_t getDistance
Function object for distance evaluation.
Definition: JCollection.hh:774
JCollection& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::negate ( )
inlineinherited

Negate collection.

Returns
this collection

Definition at line 438 of file JCollection.hh.

439  {
440  for (iterator i = this->begin(); i != this->end(); ++i) {
441  i->getY() = -i->getY();
442  }
443 
444  return *this;
445  }
const JComparator& JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getComparator ( ) const
inlineinherited

Get comparator.

Returns
comparator

Definition at line 765 of file JCollection.hh.

766  {
767  return compare;
768  }
JComparator compare
Function object for comparison.
Definition: JCollection.hh:781
void JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::resize ( typename container_type::size_type  size)
inlineprotectedinherited

Resize collection.

Parameters
sizesize

Definition at line 789 of file JCollection.hh.

790  {
791  container_type::resize(size);
792  }
template<class JKey_t, class JValue_t>
const mapped_type& JTOOLS::JMappableCollection< JKey_t, JValue_t >::operator[] ( typename JClass< key_type >::argument_type  key) const
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 73 of file JMappableCollection.hh.

74  {
75  return get(key);
76  }
template<class JKey_t, class JValue_t>
mapped_type& JTOOLS::JMappableCollection< JKey_t, JValue_t >::operator[] ( typename JClass< key_type >::argument_type  key)
inlineinherited

Get mapped value.

Parameters
keykey
Returns
value

Definition at line 85 of file JMappableCollection.hh.

86  {
87  return get(key);
88  }
template<class JKey_t, class JValue_t>
void JTOOLS::JMappableCollection< JKey_t, JValue_t >::put ( typename JClass< key_type >::argument_type  key,
typename JClass< mapped_type >::argument_type  value 
)
inlineinherited

Put pair-wise element (key,value) into collection.

Parameters
keykey
valuevalue

Definition at line 97 of file JMappableCollection.hh.

99  {
100  get(key) = value;
101  }
template<class JAbscissa_t>
bool JTOOLS::JAbstractCollection< JAbscissa_t >::is_equal ( const JAbstractCollection< JAbscissa_t > &  collection) const
inlineinherited

Test whether abstract collections are equal.

Parameters
collectionabstract collection
Returns
true if collections are equals; else false

Definition at line 69 of file JAbstractCollection.hh.

70  {
71  if (this->getSize() == collection.getSize()) {
72 
73  for (int i = 0; i != this->getSize(); ++i) {
74 
75  if (this->getX(i) != collection.getX(i)) {
76  return false;
77  }
78  }
79 
80  return true;
81  }
82 
83  return false;
84  }
virtual abscissa_type getX(int index) const =0
Get abscissa value.
virtual int getSize() const =0
Get number of elements.
static result_type JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::getValue ( const JFunctional< JKey_t, JResultType< JValue_t >::result_type > &  function,
const argument_type pX 
)
inlinestaticinherited

Recursive function value evaluation.

Parameters
functionfunction
pXpointer to abscissa values

Definition at line 107 of file JFunctional.hh.

109  {
110  return function.evaluate(pX);
111  }
static JClass<result_type>::argument_type JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::getValue ( typename JClass< result_type >::argument_type  value,
const argument_type pX 
)
inlinestaticinherited

Termination of recursive function value evaluation.

Parameters
valueresult
pXpointer to abscissa values

Definition at line 121 of file JFunctional.hh.

123  {
124  return value;
125  }
JSupervisor JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::getSupervisor ( ) const
inlineinherited

Get supervisor.

Returns
supervisor

Definition at line 266 of file JFunctional.hh.

const JExceptionHandler& JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::getExceptionHandler ( ) const
inlineinherited

Get exception handler.

Returns
exception handler

Definition at line 277 of file JFunctional.hh.

void JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::setExceptionHandler ( const JSupervisor &  supervisor)
inlineinherited

Set the supervisor for handling of exceptions.

Parameters
supervisorsupervisor

Definition at line 288 of file JFunctional.hh.

Member Data Documentation

JDistance_t JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::getDistance
inherited

Function object for distance evaluation.

Definition at line 774 of file JCollection.hh.

JComparator JTOOLS::JCollection< JElement2D< JKey_t, JValue_t > , JDistance_t >::compare
protectedinherited

Function object for comparison.

Definition at line 781 of file JCollection.hh.

JSupervisor JTOOLS::JFunctional< JKey_t , JResultType< JValue_t >::result_type >::supervisor
protectedinherited

Definition at line 295 of file JFunctional.hh.


The documentation for this struct was generated from the following file: