CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

MatRepSparse< T, D1, D2, S, F > Class Template Reference

#include <MatRepSparse.h>

List of all members.

Public Types

enum  { kRows = D1, kCols = D1, kSize = S }
typedef T value_type

Public Member Functions

T apply (unsigned int i) const
TArray ()
const TArray () const
template<typename FI >
 MatRepSparse (FI fi)
 MatRepSparse ()
Toperator() (unsigned int i, unsigned int j)
T const & operator() (unsigned int i, unsigned int j) const
template<class R >
MatRepSparseoperator+= (const R &)
MatRepSparseoperator+= (const MatRepSparse &rhs)
template<class R >
MatRepSparseoperator-= (const R &)
MatRepSparseoperator-= (const MatRepSparse &rhs)
template<class R >
MatRepSparseoperator= (const R &)
MatRepSparseoperator= (const MatRepSparse &rhs)
template<class R >
bool operator== (const R &rhs) const
Toperator[] (unsigned int i)
T const & operator[] (unsigned int i) const

Static Public Member Functions

static T const & csink ()
static Tsink ()

Public Attributes

f
T fArray [kSize] = {0}

Detailed Description

template<typename T, unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
class MatRepSparse< T, D1, D2, S, F >

a sparse matrix just for storage purposes can be assigned to other matrices

Definition at line 11 of file MatRepSparse.h.


Member Typedef Documentation

template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
typedef T MatRepSparse< T, D1, D2, S, F >::value_type

Definition at line 18 of file MatRepSparse.h.


Member Enumeration Documentation

template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
anonymous enum
Enumerator:
kRows 

return no. of matrix rows

kCols 

return no. of matrix columns

kSize 

return no of elements: rows*columns

Definition at line 112 of file MatRepSparse.h.

       {
    kRows = D1,
    kCols = D1,
    kSize = S
  };

Constructor & Destructor Documentation

template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
MatRepSparse< T, D1, D2, S, F >::MatRepSparse ( ) [inline]

Definition at line 14 of file MatRepSparse.h.

{}
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
template<typename FI >
MatRepSparse< T, D1, D2, S, F >::MatRepSparse ( FI  fi) [inline, explicit]

Definition at line 16 of file MatRepSparse.h.

: f(fi) { } 

Member Function Documentation

template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T MatRepSparse< T, D1, D2, S, F >::apply ( unsigned int  i) const [inline]

Definition at line 51 of file MatRepSparse.h.

References MatRepSparse< T, D1, D2, S, F >::f, MatRepSparse< T, D1, D2, S, F >::fArray, and gen::k.

                                       {
    int k =  f(i);
    return k<0 ? 0 : fArray[k];
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T* MatRepSparse< T, D1, D2, S, F >::Array ( ) [inline]
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
const T* MatRepSparse< T, D1, D2, S, F >::Array ( ) const [inline]

Definition at line 58 of file MatRepSparse.h.

References MatRepSparse< T, D1, D2, S, F >::fArray.

{ return fArray; }  
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
static T const& MatRepSparse< T, D1, D2, S, F >::csink ( ) [inline, static]

Definition at line 25 of file MatRepSparse.h.

References lumiQTWidget::t.

Referenced by MatRepSparse< T, D1, D2, S, F >::operator()(), and MatRepSparse< T, D1, D2, S, F >::operator[]().

                           {
    static const T t=0;
    return t;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T& MatRepSparse< T, D1, D2, S, F >::operator() ( unsigned int  i,
unsigned int  j 
) [inline]
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T const& MatRepSparse< T, D1, D2, S, F >::operator() ( unsigned int  i,
unsigned int  j 
) const [inline]
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator+= ( const MatRepSparse< T, D1, D2, S, F > &  rhs) [inline]

Definition at line 84 of file MatRepSparse.h.

References MatRepSparse< T, D1, D2, S, F >::Array(), MatRepSparse< T, D1, D2, S, F >::fArray, i, and MatRepSparse< T, D1, D2, S, F >::kSize.

                                                            {
    for(unsigned int i=0; i<kSize; ++i) fArray[i] += rhs.Array()[i];
    return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
template<class R >
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator+= ( const R &  ) [inline]

self addition : only sparse to sparse allowed

Definition at line 79 of file MatRepSparse.h.

References dttmaxenums::R, and relativeConstraints::value.

                                             {
    static_assert(std::is_same<R,MatRepSparse<T,D1,D2,S,F>>::value,
                  "Cannot_add_general_to_sparse_matrix_representation");
         return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator-= ( const MatRepSparse< T, D1, D2, S, F > &  rhs) [inline]

Definition at line 99 of file MatRepSparse.h.

References MatRepSparse< T, D1, D2, S, F >::Array(), MatRepSparse< T, D1, D2, S, F >::fArray, i, and MatRepSparse< T, D1, D2, S, F >::kSize.

                                                            {
    for(unsigned int i=0; i<kSize; ++i) fArray[i] -= rhs.Array()[i];
    return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
template<class R >
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator-= ( const R &  ) [inline]

self subtraction : only sparse to sparse allowed

Definition at line 93 of file MatRepSparse.h.

References dttmaxenums::R, and relativeConstraints::value.

                                             {
    static_assert(std::is_same<R,MatRepSparse<T,D1,D2,S,F>>::value,
                  "Cannot_substract_general_to_sparse_matrix_representation");
    return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator= ( const MatRepSparse< T, D1, D2, S, F > &  rhs) [inline]

Definition at line 70 of file MatRepSparse.h.

References MatRepSparse< T, D1, D2, S, F >::Array(), MatRepSparse< T, D1, D2, S, F >::fArray, i, and MatRepSparse< T, D1, D2, S, F >::kSize.

                                                           {
    for(unsigned int i=0; i<kSize; ++i) fArray[i] = rhs.Array()[i];
    return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
template<class R >
MatRepSparse& MatRepSparse< T, D1, D2, S, F >::operator= ( const R &  ) [inline]

assignment : only sparse to sparse allowed

Definition at line 64 of file MatRepSparse.h.

References dttmaxenums::R, and relativeConstraints::value.

                                            {
    static_assert(std::is_same<R,MatRepSparse<T,D1,D2,S,F>>::value,
                  "Cannot_assign_general_to_sparse_matrix_representation");
    return *this;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
template<class R >
bool MatRepSparse< T, D1, D2, S, F >::operator== ( const R &  rhs) const [inline]

Definition at line 104 of file MatRepSparse.h.

References i, and MatRepSparse< T, D1, D2, S, F >::operator[]().

                                             {
    bool rc = true;
    for(unsigned int i=0; i<D1*D2; ++i) {
      rc = rc && (operator[](i) == rhs[i]);
    }
    return rc;
  }
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T& MatRepSparse< T, D1, D2, S, F >::operator[] ( unsigned int  i) [inline]
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T const& MatRepSparse< T, D1, D2, S, F >::operator[] ( unsigned int  i) const [inline]
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
static T& MatRepSparse< T, D1, D2, S, F >::sink ( ) [inline, static]

Definition at line 20 of file MatRepSparse.h.

References lumiQTWidget::t.

Referenced by MatRepSparse< T, D1, D2, S, F >::operator()(), and MatRepSparse< T, D1, D2, S, F >::operator[]().

                    {
    static T t=0;  // this should throw...
    return t;
  }

Member Data Documentation

template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
F MatRepSparse< T, D1, D2, S, F >::f
template<typename T , unsigned int D1, unsigned int D2, unsigned int S, typename F = int(*)(int)>
T MatRepSparse< T, D1, D2, S, F >::fArray[kSize] = {0}