STK++ 0.9.13
STK::ArrayInitializer< Derived > Class Template Reference

Helper class used by the comma initializer operator. More...

#include <STK_ArrayBaseInitializer.h>

Public Types

typedef Derived::Type Type
 

Public Member Functions

 ArrayInitializer (Derived &array, Type const &s)
 Constructor.
 
ArrayInitializeroperator, (Type const &s)
 inserts a scalar value in the target matrix
 
 ~ArrayInitializer ()
 destructor
 

Protected Member Functions

void toFirstElt ()
 Set (row_, col_) to the first element of the array.
 
void toNextElt ()
 Compute the next element.
 

Protected Attributes

Derived & array_
 
int row_
 
int col_
 

Detailed Description

template<typename Derived>
class STK::ArrayInitializer< Derived >

Helper class used by the comma initializer operator.

This class is internally used to implement the comma initializer feature. It is the return type of ArrayBase::operator<<, and most of the time this is the only way it is used.

Definition at line 48 of file STK_ArrayBaseInitializer.h.

Member Typedef Documentation

◆ Type

template<typename Derived >
typedef Derived::Type STK::ArrayInitializer< Derived >::Type

Definition at line 51 of file STK_ArrayBaseInitializer.h.

Constructor & Destructor Documentation

◆ ArrayInitializer()

template<typename Derived >
STK::ArrayInitializer< Derived >::ArrayInitializer ( Derived &  array,
Type const s 
)
inline

Constructor.

Definition at line 53 of file STK_ArrayBaseInitializer.h.

54 : array_(array), row_(array.beginRows()), col_(array.beginCols())
55 { // check if there is space
56 if (array.empty())
58 toFirstElt();
59 array_.elt(row_, col_) = s;
60 }
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
ArrayInitializer(Derived &array, Type const &s)
Constructor.
void toFirstElt()
Set (row_, col_) to the first element of the array.

References STK::ArrayInitializer< Derived >::array_, STK::ArrayInitializer< Derived >::ArrayInitializer(), STK::ArrayInitializer< Derived >::col_, STK::ArrayInitializer< Derived >::row_, STKRUNTIME_ERROR_NO_ARG, and STK::ArrayInitializer< Derived >::toFirstElt().

Referenced by STK::ArrayInitializer< Derived >::ArrayInitializer().

◆ ~ArrayInitializer()

template<typename Derived >
STK::ArrayInitializer< Derived >::~ArrayInitializer ( )
inline

destructor

Definition at line 69 of file STK_ArrayBaseInitializer.h.

69{}

Member Function Documentation

◆ operator,()

template<typename Derived >
ArrayInitializer & STK::ArrayInitializer< Derived >::operator, ( Type const s)
inline

inserts a scalar value in the target matrix

Definition at line 62 of file STK_ArrayBaseInitializer.h.

63 {
64 toNextElt();
65 array_.elt(row_, col_) = s;
66 return *this;
67 }
void toNextElt()
Compute the next element.

References STK::ArrayInitializer< Derived >::array_, STK::ArrayInitializer< Derived >::col_, STK::ArrayInitializer< Derived >::row_, and STK::ArrayInitializer< Derived >::toNextElt().

◆ toFirstElt()

template<typename Derived >
void STK::ArrayInitializer< Derived >::toFirstElt ( )
inlineprotected

Set (row_, col_) to the first element of the array.

Note
Useful only if the structure of the array does not allow element in the (beginRows(), beginCols()) position.

Definition at line 76 of file STK_ArrayBaseInitializer.h.

77 {
78 // loop over the rows, until we get existing columns
79 while (array_.rangeColsInRow(row_).size() <= 0)
80 { row_++;
81 if (row_ >= array_.endRows())
83 }
84 col_ = array_.rangeColsInRow(row_).begin();
85 }

References STK::ArrayInitializer< Derived >::array_, STK::ArrayInitializer< Derived >::col_, STK::ArrayInitializer< Derived >::row_, STKRUNTIME_ERROR_NO_ARG, and STK::ArrayInitializer< Derived >::toFirstElt().

Referenced by STK::ArrayInitializer< Derived >::ArrayInitializer(), and STK::ArrayInitializer< Derived >::toFirstElt().

◆ toNextElt()

template<typename Derived >
void STK::ArrayInitializer< Derived >::toNextElt ( )
inlineprotected

Compute the next element.

Definition at line 87 of file STK_ArrayBaseInitializer.h.

88 {
89 // for the current row go to first available column if necessary
90 if (col_ < array_.rangeColsInRow(row_).begin())
91 { col_ = array_.rangeColsInRow(row_).begin();}
92 else // otherwise just increment
93 { col_++;}
94 // check if we need to go to next row
95 if (col_ > array_.rangeColsInRow(row_).lastIdx())
96 {
97 row_++;
98 while ( (array_.rangeColsInRow(row_).size() <= 0) && (row_ <= array_.lastIdxRows()))
99 { row_++;}
100 if (row_ > array_.lastIdxRows())
101 { STKRUNTIME_ERROR_NO_ARG(ArrayInitializer::toNextElt,Too many coefficients passed to operator<<);}
102 col_ = array_.rangeColsInRow(row_).begin();
103 }
104 }

References STK::ArrayInitializer< Derived >::array_, STK::ArrayInitializer< Derived >::col_, STK::ArrayInitializer< Derived >::row_, STKRUNTIME_ERROR_NO_ARG, and STK::ArrayInitializer< Derived >::toNextElt().

Referenced by STK::ArrayInitializer< Derived >::operator,(), and STK::ArrayInitializer< Derived >::toNextElt().

Member Data Documentation

◆ array_

◆ col_

◆ row_


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