inlib  1.2.0
Public Member Functions
inlib::lut< TB, TO > Class Template Reference

List of all members.

Public Member Functions

 lut ()
 lut (const TB &a_min, const TB &a_max, unsigned int a_coln)
virtual ~lut ()
 lut (const lut &a_from)
lutoperator= (const lut &a_from)
TO apply (const TB &a_x) const

Detailed Description

template<class TB, class TO>
class inlib::lut< TB, TO >

Definition at line 11 of file lut.


Constructor & Destructor Documentation

template<class TB, class TO>
inlib::lut< TB, TO >::lut ( ) [inline]

Definition at line 13 of file lut.

  :m_min(0),m_max(0)
  ,m_bornen(0)
  ,m_bornes(0)
  {}
template<class TB, class TO>
inlib::lut< TB, TO >::lut ( const TB &  a_min,
const TB &  a_max,
unsigned int  a_coln 
) [inline]

Definition at line 18 of file lut.

  :m_min(a_min)
  ,m_max(a_max)
  {
    //NOTE : we should have a_max>a_min and a_coln >=3.

    // a_coln = 5 :
    // <>  |  <>  |  <>  |  <>  |  <>  // a_coln <>
    //    min                  max
    // there are :
    //   5 <> 
    // and :
    //   4 |
    if(m_max<=m_min) m_max = m_min+1; //throw ?
    if(a_coln<3) { //throw ?
      m_bornen = 2;
      m_bornes = new TB[m_bornen];
      m_bornes[0] = m_min;
      m_bornes[1] = m_max;
    } else {
      m_bornen = a_coln-1;
      m_bornes = new TB[m_bornen];
      TB dx = (m_max-m_min)/(m_bornen-1);
      for(unsigned int i=0;i<m_bornen;i++) {
        m_bornes[i] = m_min+dx*i;
      }
    }
  }
template<class TB, class TO>
virtual inlib::lut< TB, TO >::~lut ( ) [inline, virtual]

Definition at line 46 of file lut.

{delete [] m_bornes;}
template<class TB, class TO>
inlib::lut< TB, TO >::lut ( const lut< TB, TO > &  a_from) [inline]

Definition at line 48 of file lut.

  :m_min(a_from.m_min)
  ,m_max(a_from.m_max)
  ,m_bornen(a_from.m_bornen)
  ,m_bornes(0)
  {
    if(m_bornen) {
      m_bornes = new TB[m_bornen];
      for(unsigned int i=0;i<m_bornen;i++) {
        m_bornes[i] = a_from.m_bornes[i];
      }
    }
  }

Member Function Documentation

template<class TB, class TO>
TO inlib::lut< TB, TO >::apply ( const TB &  a_x) const [inline]

Definition at line 77 of file lut.

                                {
    // return something in [0,a_coln-1]
    TB* pos = m_bornes;
    for(TO i=0;i<m_bornen;i++,pos++) {
      if(a_x<*pos) return i;
    }
    return m_bornen;
  }
template<class TB, class TO>
lut& inlib::lut< TB, TO >::operator= ( const lut< TB, TO > &  a_from) [inline]

Definition at line 61 of file lut.

                                   {
    delete [] m_bornes;
    m_bornes = 0;

    m_min = a_from.m_min;
    m_max = a_from.m_max;
    m_bornen = a_from.m_bornen;
    if(m_bornen) {
      m_bornes = new TB[m_bornen];
      for(unsigned int i=0;i<m_bornen;i++) {
        m_bornes[i] = a_from.m_bornes[i];
      }
    }
    return *this;
  }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines