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

template interface base class for two-dimensional arrays. More...

#include <STK_IArray2D.h>

Inheritance diagram for STK::IArray2D< Derived >:
Inheritance graph

Public Types

enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
typedef hidden::Traits< Derived >::Row Row
 
typedef hidden::Traits< Derived >::Col Col
 
typedef hidden::Traits< Derived >::SubRow SubRow
 
typedef hidden::Traits< Derived >::SubCol SubCol
 
typedef hidden::Traits< Derived >::SubArray SubArray
 
typedef hidden::Traits< Derived >::SubVector SubVector
 
typedef hidden::Traits< Derived >::ColVector ColVector
 
typedef ColVectorPtrCol
 
typedef ColVector constPtrColConst
 
typedef TRange< sizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< sizeCols_ColRange
 Type of the Range for the columns.
 
typedef IContainer2D< sizeRows_, sizeCols_Base2D
 Type for the IContainer2D base Class.
 
typedef MemAllocator< PtrCol, sizeCols_Allocator
 Type for the Base Class.
 
typedef ArrayBase< Derived > Base
 type of the Base Container Class.
 
- Public Types inherited from STK::ArrayBase< Derived >
enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef ExprBase< Derived > Base
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
- Public Types inherited from STK::ExprBase< Derived >
enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef ITContainer< Derived, structure_Base
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 

Public Member Functions

void clear ()
 clear the object.
 
Derived & move (Derived const &T)
 move T to this.
 
void exchange (IArray2D &T)
 exchange this container with T.
 
bool isRef () const
 
RowRange constrowsImpl () const
 
ColRange constcolsImpl () const
 
RowRange constrows () const
 
int beginRows () const
 
int endRows () const
 
int sizeRows () const
 
ColRange constcols () const
 
int beginCols () const
 
int endCols () const
 
int sizeCols () const
 
int lastIdxCols () const
 
int lastIdxRows () const
 
bool empty () const
 
Allocator constallocator () const
 
PtrColConst ptr (int j) const
 
int availableCols () const
 
int capacityCol (int col) const
 
Array1D< Range, sizeCols_ > constrangeCols () const
 
Range constrangeCol (int col) const
 
void setValueImpl (int j, TypeConst v)
 implement setValue for vector/point/diagonal arrays
 
void setValueImpl (int i, int j, TypeConst v)
 implement setValue for vector/point/diagonal arrays
 
Typeelt2Impl (int i, int j)
 access to an element.
 
TypeConst elt2Impl (int i, int j) const
 constant access to an element.
 
TypeConst operator() (int i, int j) const
 
Typeoperator() (int i, int j)
 
TypeConst operator[] (int i) const
 
Typeoperator[] (int i)
 
TypeConst operator() () const
 
Typeoperator() ()
 
Col col (int j) const
 access to a part of a column.
 
SubCol col (Range const &I, int j) const
 access to a part of a column.
 
SubArray col (Range const &J) const
 access to many columns.
 
Row row (int i) const
 access to a part of a row.
 
SubRow row (int i, Range const &J) const
 access to a part of a row.
 
SubArray row (Range const &I) const
 access to many rows.
 
SubVector sub (Range const &J) const
 
SubArray sub (Range const &I, Range const &J) const
 access to a sub-array.
 
SubVector operator[] (Range const &I) const
 
SubCol operator() (Range const &I, int j) const
 
SubRow operator() (int i, Range const &J) const
 
SubArray operator() (Range const &I, Range const &J) const
 
SubCol atCol (int j) const
 
Row atRow (int i) const
 
void reserve (int sizeRows, int sizeCols)
 function for reserving memory in all the columns
 
void reserveRows (int size)
 Reserve a certain amount of rows in all columns.
 
void reserveCols (int sizeCols)
 Reserve a certain amount of columns.
 
void shift (int rbeg, int cbeg)
 Set new beginning indexes to the array.
 
void shift (int beg)
 New first index for the object (only for vectors/points/square/... arrays)
 
void shiftRows (int beg)
 New first index for the rows of the array.
 
void shiftCols (int cbeg)
 New first index for the columns of the object.
 
Derived & resize (Range const &I, Range const &J)
 resize the array.
 
Derived & resize (Range const &I)
 
void insertRows (int pos, int n=1)
 Insert n rows at position pos in the array If pos is outside the range of a column, then the method do nothing (useful for triangular/diagonal/... arrays).
 
void eraseRows (int pos, int n=1)
 Delete n rows at the position pos.
 
void pushFrontRows (int n=1)
 Insert n rows in front of the array.
 
void pushBackRows (int n=1)
 Add n rows to the array.
 
void popFrontRows (int n=1)
 Delete n first rows of the array.
 
void popBackRows (int n=1)
 Delete n latest rows of the array.
 
template<class Other >
Derived & pushFrontRows (ExprBase< Other > const &other)
 set other at the beginning of this (concatenate).
 
template<class Other >
Derived & pushBackRows (ExprBase< Other > const &other)
 set other at the end of this (concatenate).
 
void insertCols (int pos, int n=1)
 Insert n columns at the index pos to the array.
 
void eraseCols (int pos, int n=1)
 Delete n columns at the specified position of the array.
 
void pushFrontCols (int n=1)
 Insert n columns at the beginning of the array.
 
void pushBackCols (int n=1)
 Add n columns at the end of the array.
 
void popFrontCols (int n=1)
 Delete first columns of the array.
 
void popBackCols (int n=1)
 Delete last columns of the array.
 
template<class Other >
Derived & pushFrontCols (ExprBase< Other > const &other)
 merge (by value) the array other with this.
 
template<class Other >
Derived & pushBackCols (IArray1D< Other > const &other)
 Specialization for Array1D.
 
void push_front (Type const &v)
 STL compatibility: push front an element.
 
void push_back (Type const &v)
 STL compatibility: append an element v.
 
void insert (Range const &I, Type const &v)
 STL compatibility: insert element v in the range I of the Array.
 
void erase (int pos, int n=1)
 STL compatibility:Delete n elements at the pos index from the container.
 
void swapCols (int pos1, int pos2)
 Swapping two columns.
 
void swap (int i, int j)
 swap two elements: only for vectors and points
 
template<class OtherDerived >
void merge (IArray2D< OtherDerived > const &other)
 Append the container other to this without copying the data explicitly.
 
template<class OtherDerived >
void merge (IArray1D< OtherDerived > const &other)
 Append the vector other to this without copying the data explicitly.
 
void update (Range const &J)
 Update columns of the array at a specified range.
 
void update (int col)
 Update column of the array at specified position.
 
void setCols (ColRange const &J=ColRange())
 Set the columns range.
 
void setRows (RowRange const &I=RowRange())
 Set the range of the number of rows.
 
- Public Member Functions inherited from STK::ArrayBase< Derived >
template<typename Visitor >
void apply (Visitor &visitor)
 Apply the Visitor visitor to the whole coefficients of the array.
 
Derived & randUnif ()
 set random values to this using a uniform law.
 
Derived & randGauss ()
 set random values to this using a standard gaussian law.
 
Derived & rand (Law::IUnivLaw< Type > const &law)
 set random values to this using a distribution law given by the user.
 
Derived & setOnes ()
 set one to this using a Visitor.
 
Derived & setZeros ()
 set zero to this using a Visitor.
 
Derived & ones ()
 set one to this using a Visitor.
 
Derived & zeros ()
 set zero to this using a Visitor.
 
Derived & setValue (TypeConst value)
 set a value to this container.
 
void setValue (int i, TypeConst value)
 set a value to this container at index i.
 
void setValue (int i, int j, TypeConst value)
 set a value to this container at position (i,j).
 
template<class Rhs >
Derived & assign (ExprBase< Rhs > const &rhs)
 
Derived & operator= (Type const &value)
 
Derived & operator= (Derived const &rhs)
 
template<typename Rhs >
Derived & operator= (ExprBase< Rhs > const &rhs)
 
template<typename Rhs >
Derived & operator+= (ExprBase< Rhs > const &other)
 Add Rhs to this.
 
template<typename Rhs >
Derived & operator-= (ExprBase< Rhs > const &other)
 subtract a Rhs to this.
 
template<typename Rhs >
Derived & operator/= (ExprBase< Rhs > const &other)
 divide this by Rhs.
 
template<typename Rhs >
Derived & operator%= (ExprBase< Rhs > const &other)
 Take modulo of this by Rhs.
 
template<typename Rhs >
Derived & operator*= (ExprBase< Rhs > const &other)
 multiply this by Rhs.
 
Derived & operator+= (Type const &other)
 Adding a constant to this.
 
Derived & operator-= (Type const &other)
 Subtract a constant to this.
 
Derived & operator*= (Type const &other)
 product of this by a constant.
 
Derived & operator/= (Type const &other)
 dividing this by a constant.
 
Derived & operator%= (Type const &other)
 take modulo of this by a constant.
 
template<class Rhs >
Derived & copy (ExprBase< Rhs > const &rhs)
 overwrite this with src.
 
TransposeOperator< Derived > const transpose () const
 
TransposeAccessor< Derived > transpose ()
 
DiagonalizeOperator< Derived > const diagonalize () const
 
DiagonalizeAccessor< Derived > diagonalize ()
 
DiagonalGetterOperator< Derived > const getDiagonal () const
 
DiagonalGetterAccessor< Derived > getDiagonal ()
 
UpperTriangularizeOperator< Derived > const upperTriangularize () const
 
UpperTriangularizeAccessor< Derived > upperTriangularize ()
 
LowerTriangularizeOperator< Derived > const lowerTriangularize () const
 
LowerTriangularizeAccessor< Derived > lowerTriangularize ()
 
SymmetrizeOperator< Derived > const symmetrize () const
 
SymmetrizeAccessor< Derived > symmetrize ()
 
UpperSymmetrizeOperator< Derived > const upperSymmetrize () const
 
UpperSymmetrizeAccessor< Derived > upperSymmetrize ()
 
LowerSymmetrizeOperator< Derived > const lowerSymmetrize () const
 
LowerSymmetrizeAccessor< Derived > lowerSymmetrize ()
 
ColOperator< Derived > const col (int j) const
 
RowOperator< Derived > const row (int i) const
 
template<int Size_>
SubVectorOperator< Derived, Size_ > const sub (TRange< Size_ > const &I) const
 
template<int SizeRows_, int SizeCols_>
SubOperator< Derived, SizeRows_, SizeCols_ > const sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J) const
 
ColAccessor< Derived > col (int j)
 
RowAccessor< Derived > row (int i)
 
template<int Size_>
SubVectorAccessor< Derived, Size_sub (TRange< Size_ > const &I)
 
template<int SizeRows_, int SizeCols_>
SubAccessor< Derived, SizeRows_, SizeCols_sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J)
 
TypeConst operator() (int i, int j) const
 
Typeoperator() (int i, int j)
 
TypeConst operator[] (int i) const
 
Typeoperator[] (int i)
 
TypeConst operator() () const
 
Typeoperator() ()
 
ArrayInitializer< Derived > operator<< (Type const &s)
 Convenient operator to set the coefficients of a matrix.
 
template<typename Rhs >
ArrayInitializer< Derived > operator<< (ArrayBase< Rhs > const &other)
 
- Public Member Functions inherited from STK::ExprBase< Derived >
template<typename Visitor >
Visitor::TypeConst visit (Visitor &visitor) const
 Visit the container using a constant visitor.
 
int count () const
 compute the value of non-zero element in an expression.
 
bool const any () const
 check if there is any non-zero element in an expression.
 
bool const all () const
 check if all the elements in an expression are not zero.
 
int nbAvailableValues () const
 
Type const minElt (int &row, int &col) const
 
Type const minEltSafe (int &row, int &col) const
 
Type const maxElt (int &row, int &col) const
 
Type const maxEltSafe (int &row, int &col) const
 
Type const minElt (int &pos) const
 
Type const minEltSafe (int &pos) const
 
Type const maxElt (int &pos) const
 
Type const maxEltSafe (int &pos) const
 
Type const minElt () const
 
Type const minEltSafe () const
 
Type const maxElt () const
 
Type const maxEltSafe () const
 
Type const sum () const
 
Type const sumSafe () const
 
Type const norm () const
 
Type const normSafe () const
 
Type const norm2 () const
 
Type const norm2Safe () const
 
Type const normInf () const
 
Type const mean () const
 
Type const meanSafe () const
 
Type const variance () const
 
Type const varianceSafe () const
 
Type const variance (Type const &mean) const
 
Type const varianceSafe (Type const &mean) const
 
template<typename Rhs >
Type const wsum (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wsumSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnormSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm2 (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm2Safe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wmean (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wmeanSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvariance (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvarianceSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvariance (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvarianceSafe (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::equalOp_ >::Result const operator== (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::notEqualOp_ >::Result const operator!= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::greaterThanOp_ >::Result const operator> (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::lessThanOp_ >::Result const operator< (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::greaterThanOrEqualOp_ >::Result const operator>= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::lessThanOrEqualOp_ >::Result const operator<= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::sumOp_ >::Result const operator+ (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::differenceOp_ >::Result const operator- (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::productOp_ >::Result const prod (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::divisionOp_ >::Result const operator/ (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::moduloOp_ >::Result const operator% (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::minOp_ >::Result const min (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::maxOp_ >::Result const max (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::logicalAndOp_ >::Result const operator&& (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::logicalOrOp_ >::Result const operator|| (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseAndOp_ >::Result const operator& (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseOrOp_ >::Result const operator| (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseXorOp_ >::Result const operator^ (ExprBase< Rhs > const &other) const
 
UnaryOperator< OppositeOp< Type >, Derived > operator- () const
 
UnaryOperator< IsNaOp< Type >, Derived > isNA () const
 
UnaryOperator< NegOp< Type >, Derived > neg () const
 
UnaryOperator< IsFiniteOp< Type >, Derived > isFinite () const
 
UnaryOperator< IsInfiniteOp< Type >, Derived > isInfinite () const
 
UnaryOperator< AbsOp< Type >, Derived > abs () const
 
UnaryOperator< ExpOp< Type >, Derived > exp () const
 
UnaryOperator< LogOp< Type >, Derived > log () const
 
UnaryOperator< SqrtOp< Type >, Derived > sqrt () const
 
UnaryOperator< CosOp< Type >, Derived > cos () const
 
UnaryOperator< SinOp< Type >, Derived > sin () const
 
UnaryOperator< AcosOp< Type >, Derived > acos () const
 
UnaryOperator< AsinOp< Type >, Derived > asin () const
 
UnaryOperator< TanOp< Type >, Derived > tan () const
 
UnaryOperator< InverseOp< Type >, Derived > inverse () const
 
UnaryOperator< SquareOp< Type >, Derived > square () const
 
UnaryOperator< CubeOp< Type >, Derived > cube () const
 
UnaryOperator< EqualWithOp< Type >, Derived > operator== (Type const &value) const
 
UnaryOperator< NotEqualWithOp< Type >, Derived > operator!= (Type const &value) const
 
UnaryOperator< GreaterThanOp< Type >, Derived > operator> (Type const &value) const
 
UnaryOperator< LessThanOp< Type >, Derived > operator< (Type const &value) const
 
UnaryOperator< LeqThanOp< Type >, Derived > operator<= (Type const &value) const
 
UnaryOperator< GeqThanOp< Type >, Derived > operator>= (Type const &value) const
 
UnaryOperator< MinWithOp< Type >, Derived > min (Type const &value) const
 
UnaryOperator< MaxWithOp< Type >, Derived > max (Type const &value) const
 
UnaryOperator< SumWithOp< Type >, Derived > operator+ (Type const &value) const
 
UnaryOperator< DifferenceWithOp< Type >, Derived > operator- (Type const &value) const
 
UnaryOperator< ProductWithOp< Type >, Derived > operator* (Type const &value) const
 
UnaryOperator< DivisionWithOp< Type >, Derived > operator/ (Type const &value) const
 
UnaryOperator< ModuloWithOp< Type >, Derived > operator% (Type const &value) const
 
UnaryOperator< LogicalAndWithOp< Type >, Derived > operator&& (Type const &value) const
 
UnaryOperator< LogicalOrWithOp< Type >, Derived > operator|| (Type const &value) const
 
UnaryOperator< BitwiseAndWithOp< Type >, Derived > operator& (Type const &value) const
 
UnaryOperator< BitwiseOrWithOp< Type >, Derived > operator| (Type const &value) const
 
UnaryOperator< BitwiseXorWithOp< Type >, Derived > operator^ (Type const &value) const
 
UnaryOperator< PowOp< Type >, Derived > pow (Type const &value) const
 
UnaryOperator< SafeInverseOp< Type >, Derived > safeInverse (Type const &value) const
 
UnaryOperator< SafeOp< Type >, Derived > const safe (Type const value=Type()) const
 
template<typename OtherType >
UnaryOperator< CastOp< Type, OtherType >, Derived > const cast () const
 
UnaryOperator< Law::PdfOp< Type >, Derived > pdf (Law::IUnivLaw< Type > const &law) const
 compute pdf values to this using distribution law given by user
 
UnaryOperator< Law::LogPdfOp< Type >, Derived > lpdf (Law::IUnivLaw< Type > const &law) const
 compute log-pdf values to this using distribution law given by user
 
UnaryOperator< Law::CdfOp< Type >, Derived > cdf (Law::IUnivLaw< Type > const &law) const
 compute cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::LogCdfOp< Type >, Derived > lcdf (Law::IUnivLaw< Type > const &law) const
 compute log-cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::CdfcOp< Type >, Derived > cdfc (Law::IUnivLaw< Type > const &law) const
 compute complementary cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::LogCdfcOp< Type >, Derived > lcdfc (Law::IUnivLaw< Type > const &law) const
 compute complementary cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::IcdfOp< Type >, Derived > icdf (Law::IUnivLaw< Type > const &law) const
 compute inverse cumulative distribution function using distribution law given by user
 
template<template< typename > class OtherOperator>
UnaryOperator< OtherOperator< Type >, Derived > const funct0 () const
 
template<template< typename > class OtherOperator>
UnaryOperator< OtherOperator< Type >, Derived > const funct1 (Type const value) const
 
TransposeOperator< Derived > const transpose () const
 
DiagonalizeOperator< Derived > const diagonalize () const
 
DiagonalGetterOperator< Derived > const getDiagonal () const
 
UpperTriangularizeOperator< Derived > const upperTriangularize () const
 
LowerTriangularizeOperator< Derived > const lowerTriangularize () const
 
SymmetrizeOperator< Derived > const symmetrize () const
 
UpperSymmetrizeOperator< Derived > const upperSymmetrize () const
 
LowerSymmetrizeOperator< Derived > const lowerSymmetrize () const
 
template<int Size_>
SubVectorOperator< Derived, Size_ > const sub (TRange< Size_ > const &I) const
 
ColOperator< Derived > const col (int j) const
 
RowOperator< Derived > const row (int i) const
 
template<int Size_>
SubOperator< Derived, sizeRows_, Size_ > const col (TRange< Size_ > const &J) const
 
template<int Size_>
SubOperator< Derived, Size_, sizeCols_ > const row (TRange< Size_ > const &I) const
 
template<int SizeRows_, int SizeCols_>
SubOperator< Derived, SizeRows_, SizeCols_ > const sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J) const
 
template<class Rhs >
hidden::Promote< Type, typenameRhs::Type >::result_type const dot (ExprBase< Rhs > const &other) const
 
template<class Rhs >
hidden::Promote< Type, typenameRhs::Type >::result_type const dotSafe (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::ProductSelector< Derived, Rhs, hidden::Traits< Derived >::structure_, hidden::Traits< Rhs >::structure_ >::ProductType const operator* (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wsum (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wsumSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnormSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm2 (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm2Safe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wmean (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wmeanSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvariance (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvarianceSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvariance (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvarianceSafe (Type const &mean, ExprBase< Rhs > const &weights) const
 

Protected Member Functions

 IArray2D ()
 Default constructor.
 
 IArray2D (Range const &I, Range const &J)
 constructor with specified ranges
 
 IArray2D (IArray2D const &T, bool ref=false)
 Copy constructor If we want to wrap T, the main ptr will be wrapped in MemAllocator class.
 
template<class OtherDerived >
 IArray2D (IArray2D< OtherDerived > const &T, Range const &I, Range const &J)
 constructor by reference, ref_=1.
 
 ~IArray2D ()
 destructor.
 
Allocatorallocator ()
 
void transferCol (int pos1, int pos2)
 Transfer the column pos2 to the column pos1 of this.
 
void reallocCols (Range const &J)
 Method for memory reallocation and initialization of the horizontal range of the container.
 
void nullCols (ColRange const &J)
 Internal method for initializing to default values (null pointer and null range) to a range of columns.
 
- Protected Member Functions inherited from STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >
void shift (int rbeg, int cbeg)
 Set the first index of the rows and columns.
 
void setRanges (RowRange const &I=RowRange(), ColRange const &J=ColRange())
 Set the ranges of the container.
 
void setRows (RowRange const &I=RowRange())
 Set the range of the number of rows.
 
void shiftRows (int beg)
 Set the first index of the rows.
 
void incRangeRows (int inc)
 Increment the range of the number of rows.
 
void incBeginRows (int inc)
 Increment the first index of the number of rows.
 
void decBeginRows (int dec)
 Decrement the first index of the number of rows.
 
void incEndRows (int inc)
 Increment the end of the number of rows.
 
void decEndRows (int dec)
 Decrement the end of the number of rows.
 
void setCols (ColRange const &J=ColRange())
 Set the columns range.
 
void shiftCols (int beg)
 Shift the columns first index to beg.
 
void incRangeCols (int inc)
 Increment the columns range.
 
void incBeginCols (int inc)
 increment the first index of the columns.
 
void decBeginCols (int dec)
 Decrement the columns first index.
 
void incEndCols (int inc)
 Increment the last index of the columns.
 
void decEndCols (int dec)
 Decrement the last index of the columns.
 
void exchange (IContainer2D &T)
 exchange this container with T
 
void incLastIdxRows (int inc)
 Increment the end of the number of rows.
 
void decLastIdxRows (int dec)
 Decrement the end of the number of rows.
 
void incLastIdxCols (int inc)
 Increment the last index of the columns.
 
void decLastIdxCols (int dec)
 Decrement the last index of the columns.
 
 IContainer2D ()
 Default constructor.
 
 IContainer2D (RowRange const &I, ColRange const &J)
 Constructor with specified ranges.
 
 IContainer2D (IContainer2D const &T)
 Copy constructor.
 
 ~IContainer2D ()
 destructor.
 
ColRange constcols () const
 
int beginCols () const
 
int endCols () const
 
int sizeCols () const
 
RowRange constrows () const
 
int beginRows () const
 
int endRows () const
 
int sizeRows () const
 
int lastIdxCols () const
 
int lastIdxRows () const
 
bool empty () const
 
- Protected Member Functions inherited from STK::ArrayBase< Derived >
 ArrayBase ()
 Default constructor.
 
 ~ArrayBase ()
 destructor
 
template<typename Visitor >
void apply (Visitor &visitor)
 Apply the Visitor visitor to the whole coefficients of the array.
 
Derived & randUnif ()
 set random values to this using a uniform law.
 
Derived & randGauss ()
 set random values to this using a standard gaussian law.
 
Derived & rand (Law::IUnivLaw< Type > const &law)
 set random values to this using a distribution law given by the user.
 
Derived & setOnes ()
 set one to this using a Visitor.
 
Derived & setZeros ()
 set zero to this using a Visitor.
 
Derived & ones ()
 set one to this using a Visitor.
 
Derived & zeros ()
 set zero to this using a Visitor.
 
Derived & setValue (TypeConst value)
 set a value to this container.
 
void setValue (int i, TypeConst value)
 set a value to this container at index i.
 
void setValue (int i, int j, TypeConst value)
 set a value to this container at position (i,j).
 
template<class Rhs >
Derived & assign (ExprBase< Rhs > const &rhs)
 
Derived & operator= (Type const &value)
 
Derived & operator= (Derived const &rhs)
 
template<typename Rhs >
Derived & operator= (ExprBase< Rhs > const &rhs)
 
template<typename Rhs >
Derived & operator+= (ExprBase< Rhs > const &other)
 Add Rhs to this.
 
template<typename Rhs >
Derived & operator-= (ExprBase< Rhs > const &other)
 subtract a Rhs to this.
 
template<typename Rhs >
Derived & operator/= (ExprBase< Rhs > const &other)
 divide this by Rhs.
 
template<typename Rhs >
Derived & operator%= (ExprBase< Rhs > const &other)
 Take modulo of this by Rhs.
 
template<typename Rhs >
Derived & operator*= (ExprBase< Rhs > const &other)
 multiply this by Rhs.
 
Derived & operator+= (Type const &other)
 Adding a constant to this.
 
Derived & operator-= (Type const &other)
 Subtract a constant to this.
 
Derived & operator*= (Type const &other)
 product of this by a constant.
 
Derived & operator/= (Type const &other)
 dividing this by a constant.
 
Derived & operator%= (Type const &other)
 take modulo of this by a constant.
 
template<class Rhs >
Derived & copy (ExprBase< Rhs > const &rhs)
 overwrite this with src.
 
TransposeOperator< Derived > const transpose () const
 
TransposeAccessor< Derived > transpose ()
 
DiagonalizeOperator< Derived > const diagonalize () const
 
DiagonalizeAccessor< Derived > diagonalize ()
 
DiagonalGetterOperator< Derived > const getDiagonal () const
 
DiagonalGetterAccessor< Derived > getDiagonal ()
 
UpperTriangularizeOperator< Derived > const upperTriangularize () const
 
UpperTriangularizeAccessor< Derived > upperTriangularize ()
 
LowerTriangularizeOperator< Derived > const lowerTriangularize () const
 
LowerTriangularizeAccessor< Derived > lowerTriangularize ()
 
SymmetrizeOperator< Derived > const symmetrize () const
 
SymmetrizeAccessor< Derived > symmetrize ()
 
UpperSymmetrizeOperator< Derived > const upperSymmetrize () const
 
UpperSymmetrizeAccessor< Derived > upperSymmetrize ()
 
LowerSymmetrizeOperator< Derived > const lowerSymmetrize () const
 
LowerSymmetrizeAccessor< Derived > lowerSymmetrize ()
 
ColOperator< Derived > const col (int j) const
 
RowOperator< Derived > const row (int i) const
 
template<int Size_>
SubVectorOperator< Derived, Size_ > const sub (TRange< Size_ > const &I) const
 
template<int SizeRows_, int SizeCols_>
SubOperator< Derived, SizeRows_, SizeCols_ > const sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J) const
 
ColAccessor< Derived > col (int j)
 
RowAccessor< Derived > row (int i)
 
template<int Size_>
SubVectorAccessor< Derived, Size_sub (TRange< Size_ > const &I)
 
template<int SizeRows_, int SizeCols_>
SubAccessor< Derived, SizeRows_, SizeCols_sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J)
 
TypeConst operator() (int i, int j) const
 
Typeoperator() (int i, int j)
 
TypeConst operator[] (int i) const
 
Typeoperator[] (int i)
 
TypeConst operator() () const
 
Typeoperator() ()
 
ArrayInitializer< Derived > operator<< (Type const &s)
 Convenient operator to set the coefficients of a matrix.
 
template<typename Rhs >
ArrayInitializer< Derived > operator<< (ArrayBase< Rhs > const &other)
 
- Protected Member Functions inherited from STK::ExprBase< Derived >
 ExprBase ()
 Default constructor.
 
 ~ExprBase ()
 destructor
 
template<typename Visitor >
Visitor::TypeConst visit (Visitor &visitor) const
 Visit the container using a constant visitor.
 
int count () const
 compute the value of non-zero element in an expression.
 
bool const any () const
 check if there is any non-zero element in an expression.
 
bool const all () const
 check if all the elements in an expression are not zero.
 
int nbAvailableValues () const
 
Type const minElt (int &row, int &col) const
 
Type const minEltSafe (int &row, int &col) const
 
Type const maxElt (int &row, int &col) const
 
Type const maxEltSafe (int &row, int &col) const
 
Type const minElt (int &pos) const
 
Type const minEltSafe (int &pos) const
 
Type const maxElt (int &pos) const
 
Type const maxEltSafe (int &pos) const
 
Type const minElt () const
 
Type const minEltSafe () const
 
Type const maxElt () const
 
Type const maxEltSafe () const
 
Type const sum () const
 
Type const sumSafe () const
 
Type const norm () const
 
Type const normSafe () const
 
Type const norm2 () const
 
Type const norm2Safe () const
 
Type const normInf () const
 
Type const mean () const
 
Type const meanSafe () const
 
Type const variance () const
 
Type const varianceSafe () const
 
Type const variance (Type const &mean) const
 
Type const varianceSafe (Type const &mean) const
 
template<typename Rhs >
Type const wsum (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wsumSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnormSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm2 (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wnorm2Safe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wmean (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wmeanSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvariance (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvarianceSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvariance (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
Type const wvarianceSafe (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::equalOp_ >::Result const operator== (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::notEqualOp_ >::Result const operator!= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::greaterThanOp_ >::Result const operator> (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::lessThanOp_ >::Result const operator< (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::greaterThanOrEqualOp_ >::Result const operator>= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::lessThanOrEqualOp_ >::Result const operator<= (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::sumOp_ >::Result const operator+ (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::differenceOp_ >::Result const operator- (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::productOp_ >::Result const prod (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::divisionOp_ >::Result const operator/ (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::moduloOp_ >::Result const operator% (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::minOp_ >::Result const min (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::maxOp_ >::Result const max (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::logicalAndOp_ >::Result const operator&& (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::logicalOrOp_ >::Result const operator|| (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseAndOp_ >::Result const operator& (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseOrOp_ >::Result const operator| (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::OperatorSelector< Derived, Rhs, Arrays::bitwiseXorOp_ >::Result const operator^ (ExprBase< Rhs > const &other) const
 
UnaryOperator< OppositeOp< Type >, Derived > operator- () const
 
UnaryOperator< IsNaOp< Type >, Derived > isNA () const
 
UnaryOperator< NegOp< Type >, Derived > neg () const
 
UnaryOperator< IsFiniteOp< Type >, Derived > isFinite () const
 
UnaryOperator< IsInfiniteOp< Type >, Derived > isInfinite () const
 
UnaryOperator< AbsOp< Type >, Derived > abs () const
 
UnaryOperator< ExpOp< Type >, Derived > exp () const
 
UnaryOperator< LogOp< Type >, Derived > log () const
 
UnaryOperator< SqrtOp< Type >, Derived > sqrt () const
 
UnaryOperator< CosOp< Type >, Derived > cos () const
 
UnaryOperator< SinOp< Type >, Derived > sin () const
 
UnaryOperator< AcosOp< Type >, Derived > acos () const
 
UnaryOperator< AsinOp< Type >, Derived > asin () const
 
UnaryOperator< TanOp< Type >, Derived > tan () const
 
UnaryOperator< InverseOp< Type >, Derived > inverse () const
 
UnaryOperator< SquareOp< Type >, Derived > square () const
 
UnaryOperator< CubeOp< Type >, Derived > cube () const
 
UnaryOperator< EqualWithOp< Type >, Derived > operator== (Type const &value) const
 
UnaryOperator< NotEqualWithOp< Type >, Derived > operator!= (Type const &value) const
 
UnaryOperator< GreaterThanOp< Type >, Derived > operator> (Type const &value) const
 
UnaryOperator< LessThanOp< Type >, Derived > operator< (Type const &value) const
 
UnaryOperator< LeqThanOp< Type >, Derived > operator<= (Type const &value) const
 
UnaryOperator< GeqThanOp< Type >, Derived > operator>= (Type const &value) const
 
UnaryOperator< MinWithOp< Type >, Derived > min (Type const &value) const
 
UnaryOperator< MaxWithOp< Type >, Derived > max (Type const &value) const
 
UnaryOperator< SumWithOp< Type >, Derived > operator+ (Type const &value) const
 
UnaryOperator< DifferenceWithOp< Type >, Derived > operator- (Type const &value) const
 
UnaryOperator< ProductWithOp< Type >, Derived > operator* (Type const &value) const
 
UnaryOperator< DivisionWithOp< Type >, Derived > operator/ (Type const &value) const
 
UnaryOperator< ModuloWithOp< Type >, Derived > operator% (Type const &value) const
 
UnaryOperator< LogicalAndWithOp< Type >, Derived > operator&& (Type const &value) const
 
UnaryOperator< LogicalOrWithOp< Type >, Derived > operator|| (Type const &value) const
 
UnaryOperator< BitwiseAndWithOp< Type >, Derived > operator& (Type const &value) const
 
UnaryOperator< BitwiseOrWithOp< Type >, Derived > operator| (Type const &value) const
 
UnaryOperator< BitwiseXorWithOp< Type >, Derived > operator^ (Type const &value) const
 
UnaryOperator< PowOp< Type >, Derived > pow (Type const &value) const
 
UnaryOperator< SafeInverseOp< Type >, Derived > safeInverse (Type const &value) const
 
UnaryOperator< SafeOp< Type >, Derived > const safe (Type const value=Type()) const
 
template<typename OtherType >
UnaryOperator< CastOp< Type, OtherType >, Derived > const cast () const
 
UnaryOperator< Law::PdfOp< Type >, Derived > pdf (Law::IUnivLaw< Type > const &law) const
 compute pdf values to this using distribution law given by user
 
UnaryOperator< Law::LogPdfOp< Type >, Derived > lpdf (Law::IUnivLaw< Type > const &law) const
 compute log-pdf values to this using distribution law given by user
 
UnaryOperator< Law::CdfOp< Type >, Derived > cdf (Law::IUnivLaw< Type > const &law) const
 compute cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::LogCdfOp< Type >, Derived > lcdf (Law::IUnivLaw< Type > const &law) const
 compute log-cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::CdfcOp< Type >, Derived > cdfc (Law::IUnivLaw< Type > const &law) const
 compute complementary cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::LogCdfcOp< Type >, Derived > lcdfc (Law::IUnivLaw< Type > const &law) const
 compute complementary cumulative distribution function of this using distribution law given by user
 
UnaryOperator< Law::IcdfOp< Type >, Derived > icdf (Law::IUnivLaw< Type > const &law) const
 compute inverse cumulative distribution function using distribution law given by user
 
template<template< typename > class OtherOperator>
UnaryOperator< OtherOperator< Type >, Derived > const funct0 () const
 
template<template< typename > class OtherOperator>
UnaryOperator< OtherOperator< Type >, Derived > const funct1 (Type const value) const
 
TransposeOperator< Derived > const transpose () const
 
DiagonalizeOperator< Derived > const diagonalize () const
 
DiagonalGetterOperator< Derived > const getDiagonal () const
 
UpperTriangularizeOperator< Derived > const upperTriangularize () const
 
LowerTriangularizeOperator< Derived > const lowerTriangularize () const
 
SymmetrizeOperator< Derived > const symmetrize () const
 
UpperSymmetrizeOperator< Derived > const upperSymmetrize () const
 
LowerSymmetrizeOperator< Derived > const lowerSymmetrize () const
 
template<int Size_>
SubVectorOperator< Derived, Size_ > const sub (TRange< Size_ > const &I) const
 
ColOperator< Derived > const col (int j) const
 
RowOperator< Derived > const row (int i) const
 
template<int Size_>
SubOperator< Derived, sizeRows_, Size_ > const col (TRange< Size_ > const &J) const
 
template<int Size_>
SubOperator< Derived, Size_, sizeCols_ > const row (TRange< Size_ > const &I) const
 
template<int SizeRows_, int SizeCols_>
SubOperator< Derived, SizeRows_, SizeCols_ > const sub (TRange< SizeRows_ > const &I, TRange< SizeCols_ > const &J) const
 
template<class Rhs >
hidden::Promote< Type, typenameRhs::Type >::result_type const dot (ExprBase< Rhs > const &other) const
 
template<class Rhs >
hidden::Promote< Type, typenameRhs::Type >::result_type const dotSafe (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::ProductSelector< Derived, Rhs, hidden::Traits< Derived >::structure_, hidden::Traits< Rhs >::structure_ >::ProductType const operator* (ExprBase< Rhs > const &other) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wsum (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wsumSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnormSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm2 (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wnorm2Safe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wmean (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wmeanSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvariance (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvarianceSafe (ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvariance (Type const &mean, ExprBase< Rhs > const &weights) const
 
template<typename Rhs >
hidden::Traits< Derived >::Type const wvarianceSafe (Type const &mean, ExprBase< Rhs > const &weights) const
 

Protected Attributes

Allocator allocator_
 allocator of the column data set
 
Array1D< Range, sizeCols_rangeCols_
 range of the index of the columns of the container.
 

Private Member Functions

void freeMem ()
 Internal method for memory deallocation.
 
void mallocCols (ColRange const &J)
 Internal method for memory allocation and initialization of the horizontal range of the container.
 
void initializeCols (Range const &J)
 Internal method for memory allocation and initialization of a range of columns.
 
void freeCols (Range const &J)
 Internal method for releasing memory in a given range of columns.
 
void reserveRowsCols (Range const &J, int size)
 Internal method for reserving memory in a range of columns.
 
void copyCol (IArray2D const &src, int j)
 copy column j of src into column j of this
 
template<class OtherDerived >
void transferCol (IArray2D< OtherDerived > &T, int pos)
 Internal method transferring column pos of container T to column pos of this.
 
void nullCol (int col)
 Internal method setting default parameters and dimension to a column of the container.
 
void initializeCol (int col, Range const &I)
 Internal method for initializing a column.
 
void freeCol (int col)
 Internal method for memory deallocation.
 
void shiftRowCol (int col, int beg)
 internal method for translating a column.
 
void resizeRowCol (int col, Range const &I)
 Internal method for resizing a column with a specified range.
 
void reserveRowCol (int col, int size)
 Internal method for reserving rows to a specified column.
 
void insertRowsCol (int col, int pos, int n)
 Internal method for inserting rows to a specified column.
 
void eraseRowsCol (int col, int pos, int n)
 Internal method for deleting rows from a specified column.
 

Friends

template<class OtherDerived >
class IArray2D
 

Additional Inherited Members

- Protected Types inherited from STK::IContainer2D< hidden::Traits< Derived >::sizeRows_, hidden::Traits< Derived >::sizeCols_ >
typedef TRange< SizeRows_RowRange
 Type of the Range for the rows.
 
typedef TRange< SizeCols_ColRange
 Type of the Range for the columns.
 
- Protected Types inherited from STK::ArrayBase< Derived >
enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef ExprBase< Derived > Base
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 
- Protected Types inherited from STK::ExprBase< Derived >
enum  {
  structure_ = hidden::Traits<Derived>::structure_ , orient_ = hidden::Traits<Derived>::orient_ , sizeRows_ = hidden::Traits<Derived>::sizeRows_ , sizeCols_ = hidden::Traits<Derived>::sizeCols_ ,
  storage_ = hidden::Traits<Derived>::storage_
}
 
typedef ITContainer< Derived, structure_Base
 
typedef hidden::Traits< Derived >::Type Type
 
typedef hidden::Traits< Derived >::TypeConst TypeConst
 

Detailed Description

template<class Derived>
class STK::IArray2D< Derived >

template interface base class for two-dimensional arrays.

A IArray2D is an interface class for two-dimensional Arrays stored in columns and having flexible dimensions. It is possible to add, remove easily columns and rows in Derived class.

Each column has a Range stored in the array rangeCols_. It should be worth noting that we always have

(rangeCols_[j].size() <= capacityCol(j)) == true;
(rangeCols_[j].isIn(this->rows()) == true;
Array1D< Range, sizeCols_ > rangeCols_
range of the index of the columns of the container.
int capacityCol(int col) const
RowRange const & rows() const
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...

Pseudo virtual function expected by this interface in derived classes are

void setValue1D(int i, TypeConst value); // for 1D arrays
void resize1D(Range const& I); // for 1D arrays
void shift1D(beg); // for 1D arrays*
void pushBack(int n=1);
hidden::Traits< Derived >::TypeConst TypeConst
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
Template Parameters
Derivedis the name of the class that implements IArray2D.

Definition at line 77 of file STK_IArray2D.h.

Member Typedef Documentation

◆ Allocator

template<class Derived >
typedef MemAllocator<PtrCol, sizeCols_> STK::IArray2D< Derived >::Allocator

Type for the Base Class.

Definition at line 114 of file STK_IArray2D.h.

◆ Base

template<class Derived >
typedef ArrayBase<Derived> STK::IArray2D< Derived >::Base

type of the Base Container Class.

Definition at line 116 of file STK_IArray2D.h.

◆ Base2D

template<class Derived >
typedef IContainer2D<sizeRows_, sizeCols_ > STK::IArray2D< Derived >::Base2D

Type for the IContainer2D base Class.

Definition at line 112 of file STK_IArray2D.h.

◆ Col

template<class Derived >
typedef hidden::Traits<Derived>::Col STK::IArray2D< Derived >::Col

Definition at line 88 of file STK_IArray2D.h.

◆ ColRange

template<class Derived >
typedef TRange<sizeCols_> STK::IArray2D< Derived >::ColRange

Type of the Range for the columns.

Definition at line 110 of file STK_IArray2D.h.

◆ ColVector

template<class Derived >
typedef hidden::Traits<Derived>::ColVector STK::IArray2D< Derived >::ColVector

Definition at line 95 of file STK_IArray2D.h.

◆ PtrCol

template<class Derived >
typedef ColVector* STK::IArray2D< Derived >::PtrCol

Definition at line 96 of file STK_IArray2D.h.

◆ PtrColConst

template<class Derived >
typedef ColVector const* STK::IArray2D< Derived >::PtrColConst

Definition at line 97 of file STK_IArray2D.h.

◆ Row

template<class Derived >
typedef hidden::Traits<Derived>::Row STK::IArray2D< Derived >::Row

Definition at line 87 of file STK_IArray2D.h.

◆ RowRange

template<class Derived >
typedef TRange<sizeRows_> STK::IArray2D< Derived >::RowRange

Type of the Range for the rows.

Definition at line 108 of file STK_IArray2D.h.

◆ SubArray

template<class Derived >
typedef hidden::Traits<Derived>::SubArray STK::IArray2D< Derived >::SubArray

Definition at line 91 of file STK_IArray2D.h.

◆ SubCol

template<class Derived >
typedef hidden::Traits<Derived>::SubCol STK::IArray2D< Derived >::SubCol

Definition at line 90 of file STK_IArray2D.h.

◆ SubRow

template<class Derived >
typedef hidden::Traits<Derived>::SubRow STK::IArray2D< Derived >::SubRow

Definition at line 89 of file STK_IArray2D.h.

◆ SubVector

template<class Derived >
typedef hidden::Traits<Derived>::SubVector STK::IArray2D< Derived >::SubVector

Definition at line 93 of file STK_IArray2D.h.

◆ Type

template<class Derived >
typedef hidden::Traits<Derived>::Type STK::IArray2D< Derived >::Type

Definition at line 84 of file STK_IArray2D.h.

◆ TypeConst

template<class Derived >
typedef hidden::Traits<Derived>::TypeConst STK::IArray2D< Derived >::TypeConst

Definition at line 85 of file STK_IArray2D.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Derived >
anonymous enum
Enumerator
structure_ 
orient_ 
sizeRows_ 
sizeCols_ 
storage_ 

Definition at line 99 of file STK_IArray2D.h.

100 {
101 structure_ = hidden::Traits<Derived>::structure_,
102 orient_ = hidden::Traits<Derived>::orient_,
103 sizeRows_ = hidden::Traits<Derived>::sizeRows_,
104 sizeCols_ = hidden::Traits<Derived>::sizeCols_,
105 storage_ = hidden::Traits<Derived>::storage_
106 };

Constructor & Destructor Documentation

◆ IArray2D() [1/4]

template<class Derived >
STK::IArray2D< Derived >::IArray2D ( )
protected

Default constructor.

Definition at line 786 of file STK_IArray2D.h.

786 : Base2D(), Base()
787 , allocator_()
788 , rangeCols_()
789{ mallocCols(this->cols());}
void mallocCols(ColRange const &J)
Internal method for memory allocation and initialization of the horizontal range of the container.
Allocator allocator_
allocator of the column data set
IContainer2D< sizeRows_, sizeCols_ > Base2D
Type for the IContainer2D base Class.
ColRange const & cols() const
ArrayBase< Derived > Base
type of the Base Container Class.

References STK::IArray2D< Derived >::cols(), and STK::IArray2D< Derived >::mallocCols().

◆ IArray2D() [2/4]

template<class Derived >
STK::IArray2D< Derived >::IArray2D ( Range const I,
Range const J 
)
protected

constructor with specified ranges

Constructor with specified ranges.

Parameters
I,Jrows and columns range
I,Jrange of the rows and columns

Definition at line 794 of file STK_IArray2D.h.

795 : Base2D(I,J), Base()
796 , allocator_()
797 , rangeCols_()
798{ mallocCols(this->cols()); initializeCols(J);}
void initializeCols(Range const &J)
Internal method for memory allocation and initialization of a range of columns.

References STK::IArray2D< Derived >::cols(), STK::IArray2D< Derived >::initializeCols(), and STK::IArray2D< Derived >::mallocCols().

◆ IArray2D() [3/4]

template<class Derived >
STK::IArray2D< Derived >::IArray2D ( IArray2D< Derived > const T,
bool  ref = false 
)
protected

Copy constructor If we want to wrap T, the main ptr will be wrapped in MemAllocator class.

If we want to copy T, Allocator is initialized to default values.

Note
bug correction, we have to use a copy of T.rangeCols_. in case we are using the code
Array2DVector<TYPE> Dref(D.sub(J), true)
we would get an error.
Parameters
Tthe container to copy
reftrue if we wrap T

Definition at line 804 of file STK_IArray2D.h.

805 : Base2D(T), Base()
806 , allocator_(T.allocator_, ref)
807 , rangeCols_(T.rangeCols_, false) // have to be created again, in case T is a temporary
808{
809 if (!ref)
810 {
811 initializeCols(T.cols()); // initialize the Columns
812 for (int j=T.beginCols(); j<T.endCols(); j++)
813 { copyCol(T, j);}
814 }
815}
void copyCol(IArray2D const &src, int j)
copy column j of src into column j of this

References STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::cols(), STK::IArray2D< Derived >::copyCol(), STK::IArray2D< Derived >::endCols(), and STK::IArray2D< Derived >::initializeCols().

◆ IArray2D() [4/4]

template<class Derived >
template<class OtherDerived >
STK::IArray2D< Derived >::IArray2D ( IArray2D< OtherDerived > const T,
Range const I,
Range const J 
)
protected

constructor by reference, ref_=1.

Parameters
Tthe container to wrap
I,Jrows and columns to wrap

Definition at line 822 of file STK_IArray2D.h.

823 : Base2D(I,J), Base()
824 , allocator_(T.allocator_, J, true) // a reference
825 , rangeCols_(T.rangeCols_, J, false) // have to be created again, in case T is a temporary
826 // T.rangeCols_ is itself a temporary that will be deleted
827 // Tref(T.sub(J), true) for example
828{
829 for (int j=J.begin(); j<J.end(); j++)
830 { rangeCols_[j] = inf(I, T.rangeCols()[j]);}
831}
Range inf(TRange< SizeI_ > const &I, TRange< SizeJ_ > const &J)
compute inf(I,J).
Definition STK_Range.h:477

References STK::inf(), and STK::IArray2D< Derived >::rangeCols_.

◆ ~IArray2D()

template<class Derived >
STK::IArray2D< Derived >::~IArray2D ( )
protected

destructor.

Allocated horizontal memory (the array with the pointers on the columns) is liberated by the Allocator.

Definition at line 837 of file STK_IArray2D.h.

837{ if (!isRef()) freeCols(cols());}
bool isRef() const
void freeCols(Range const &J)
Internal method for releasing memory in a given range of columns.

Member Function Documentation

◆ allocator() [1/2]

template<class Derived >
Allocator & STK::IArray2D< Derived >::allocator ( )
inlineprotected
Returns
the allocator.

Definition at line 649 of file STK_IArray2D.h.

649{ return allocator_;}

References STK::IArray2D< Derived >::allocator_.

◆ allocator() [2/2]

template<class Derived >
Allocator const & STK::IArray2D< Derived >::allocator ( ) const
inline
Returns
the allocator.

Definition at line 204 of file STK_IArray2D.h.

204{ return allocator_;}

References STK::IArray2D< Derived >::allocator_.

◆ atCol()

template<class Derived >
hidden::Traits< Derived >::SubCol STK::IArray2D< Derived >::atCol ( int  j) const
Returns
the column j.
Parameters
jindex of the column

Definition at line 159 of file STK_IArray2DSlicers.h.

160{
161 if (this->beginCols() > j) { STKOUT_OF_RANGE_1ARG(IArray2D::atCol, j, beginCols() > j);}
162 if (this->endCols() <= j) { STKOUT_OF_RANGE_1ARG(IArray2D::atCol, j, endCols() <= j);}
163 return col(j);
164}
#define STKOUT_OF_RANGE_1ARG(Where, Arg, Error)
Definition STK_Macros.h:93
SubCol atCol(int j) const
int endCols() const
Col col(int j) const
access to a part of a column.
int beginCols() const

References STK::IArray2D< Derived >::atCol(), and STKOUT_OF_RANGE_1ARG.

Referenced by STK::IArray2D< Derived >::atCol().

◆ atRow()

template<class Derived >
hidden::Traits< Derived >::Row STK::IArray2D< Derived >::atRow ( int  i) const
Returns
the row i.
Parameters
ithe index of the row

Definition at line 169 of file STK_IArray2DSlicers.h.

170{
171 if (this->beginRows() > i) { STKOUT_OF_RANGE_1ARG(IArray2D::atRow, i, beginRows() > i);}
172 if (this->endRows() <= i) { STKOUT_OF_RANGE_1ARG(IArray2D::at, i, lastIdxRows() < i);}
173 return row(i);
174}
int beginRows() const
Row atRow(int i) const
int endRows() const
int lastIdxRows() const
Row row(int i) const
access to a part of a row.

References STK::IArray2D< Derived >::atRow(), and STKOUT_OF_RANGE_1ARG.

Referenced by STK::IArray2D< Derived >::atRow().

◆ availableCols()

template<class Derived >
int STK::IArray2D< Derived >::availableCols ( ) const
inline
Returns
the maximum possible number of columns without reallocation.

Definition at line 210 of file STK_IArray2D.h.

210{ return allocator_.size();}

References STK::IArray2D< Derived >::allocator_, and STK::MemAllocator< Type_, Size_ >::size().

◆ beginCols()

◆ beginRows()

template<class Derived >
int STK::IArray2D< Derived >::beginRows ( ) const
inline

◆ capacityCol()

template<class Derived >
int STK::IArray2D< Derived >::capacityCol ( int  col) const
inline
Returns
the capacity of the column col.
Parameters
colindex of the column we want the capacity

Definition at line 214 of file STK_IArray2D.h.

214{ return ptr(col) ? ptr(col)->capacity() : 0;}
PtrColConst ptr(int j) const

References STK::IArray2D< Derived >::col(), and STK::IArray2D< Derived >::ptr().

◆ clear()

template<class Derived >
void STK::IArray2D< Derived >::clear ( )

clear the object.

This will free all allocated memory and reset all range to Range(). (while freeMem() does not modify rows range (rows_)

Definition at line 844 of file STK_IArray2D.h.

845{
846 // Nothing to do for reference
847 if (isRef()) return;
848 freeMem();
849 this->setRanges();
850}
void freeMem()
Internal method for memory deallocation.
void setRanges(RowRange const &I=RowRange(), ColRange const &J=ColRange())
Set the ranges of the container.

Referenced by STK::AdditiveBSplineCoefficients< Array >::run(), STK::IQr< Derived >::setData(), and STK::Stat::Univariate< TContainer1D, Real >::setData().

◆ col() [1/3]

template<class Derived >
hidden::Traits< Derived >::Col STK::IArray2D< Derived >::col ( int  j) const
inline

access to a part of a column.

Parameters
jindex of the column
Returns
a reference in the range I of the column j of this

Definition at line 47 of file STK_IArray2DSlicers.h.

48{
49#ifdef STK_BOUNDS_CHECK
50 if (beginCols() > j) { STKOUT_OF_RANGE_1ARG(IArray::elt, j, beginCols() > j);}
51 if (endCols() <= j) { STKOUT_OF_RANGE_1ARG(IArray::elt, j, endCols() <= j);}
52#endif
53 return Col( this->asDerived(), this->rangeRowsInCol(j), j);
54}
hidden::Traits< Derived >::Col Col

References STKOUT_OF_RANGE_1ARG.

Referenced by STK::IArray2D< Derived >::capacityCol(), main(), main(), STK::IArray2D< Derived >::rangeCol(), and STK::IArray2D< Derived >::update().

◆ col() [2/3]

template<class Derived >
hidden::Traits< Derived >::SubCol STK::IArray2D< Derived >::col ( Range const I,
int  j 
) const
inline

access to a part of a column.

Parameters
Irange of the rows
jindex of the col
Returns
a reference in the range I of the column j of this

Definition at line 61 of file STK_IArray2DSlicers.h.

62{
63#ifdef STK_BOUNDS_CHECK
64 if (beginRows() > I.begin()) { STKOUT_OF_RANGE_2ARG(IArray::col, I, j, beginRows() > I.begin());}
65 if (endRows() < I.end()) { STKOUT_OF_RANGE_2ARG(IArray::col, I, j, endRows() <= I.end());}
66 if (beginCols() > j) { STKOUT_OF_RANGE_2ARG(IArray::col, I, j, beginCols() > j);}
67 if (endCols() <= j) { STKOUT_OF_RANGE_2ARG(IArray::col, I, j, endCols() <= j);}
68#endif
69 return SubCol( this->asDerived(), inf(I, this->rangeRowsInCol(j)), j);
70}
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:102
hidden::Traits< Derived >::SubCol SubCol

References STK::inf(), and STKOUT_OF_RANGE_2ARG.

◆ col() [3/3]

template<class Derived >
hidden::Traits< Derived >::SubArray STK::IArray2D< Derived >::col ( Range const J) const
inline

access to many columns.

Parameters
Jrange of the index of the cols
Returns
a 2D array containing the Container in the Horizontal range J

Definition at line 76 of file STK_IArray2DSlicers.h.

77{ return SubArray( this->asDerived(), this->rows(), J);}
hidden::Traits< Derived >::SubArray SubArray

◆ cols()

◆ colsImpl()

template<class Derived >
ColRange const & STK::IArray2D< Derived >::colsImpl ( ) const
inline
Returns
the Horizontal range

Definition at line 175 of file STK_IArray2D.h.

175{ return Base2D::cols();}

References STK::IContainer2D< SizeRows_, SizeCols_ >::cols().

◆ copyCol()

template<class Derived >
void STK::IArray2D< Derived >::copyCol ( IArray2D< Derived > const src,
int  j 
)
private

copy column j of src into column j of this

Parameters
srcsource to copy
jindex of the columns to copy

Definition at line 966 of file STK_IArray2D.h.

967{
968 PtrCol dp =allocator_.elt(j), sp =src.allocator_.elt(j);
969 dp->assign(*sp);
970}
ColVector * PtrCol
TypeConst elt(int pos) const
Get the const element number pos.

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

◆ elt2Impl() [1/2]

template<class Derived >
Type & STK::IArray2D< Derived >::elt2Impl ( int  i,
int  j 
)
inline

access to an element.

Parameters
i,jindexes of the element to get
Returns
a reference on the (i,j) element

Definition at line 235 of file STK_IArray2D.h.

235{ return allocator_.elt(j)->elt(i);}

References STK::IArray2D< Derived >::allocator_, and STK::MemAllocator< Type_, Size_ >::elt().

◆ elt2Impl() [2/2]

template<class Derived >
TypeConst STK::IArray2D< Derived >::elt2Impl ( int  i,
int  j 
) const
inline

constant access to an element.

Parameters
i,jindexes of the element to get
Returns
a constant reference on the (i,j) element

Definition at line 240 of file STK_IArray2D.h.

240{ return ptr(j)->elt(i);}

References STK::IArray2D< Derived >::ptr().

◆ empty()

template<class Derived >
bool STK::IArray2D< Derived >::empty ( ) const
inline
Returns
true if the container is empty, false otherwise

Definition at line 201 of file STK_IArray2D.h.

201{ return Base2D::empty();}

References STK::IContainer2D< SizeRows_, SizeCols_ >::empty().

◆ endCols()

◆ endRows()

template<class Derived >
int STK::IArray2D< Derived >::endRows ( ) const
inline
Returns
the ending index of the rows

Definition at line 182 of file STK_IArray2D.h.

182{ return Base2D::endRows();}

References STK::IContainer2D< SizeRows_, SizeCols_ >::endRows().

Referenced by main(), STK::IArray2D< Derived >::operator()(), STK::IArray2D< Derived >::operator()(), and STK::Qr::qr().

◆ erase()

template<class Derived >
void STK::IArray2D< Derived >::erase ( int  pos,
int  n = 1 
)

STL compatibility:Delete n elements at the pos index from the container.

Parameters
posindex where to delete elements
nnumber of elements to delete (default 1)

Definition at line 583 of file STK_IArray2DModifiers.h.

584{
586 if (structure_ == Arrays::vector_) { eraseRows(pos, n); }
587 else { eraseCols(pos, n); }
588
589}
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
void eraseRows(int pos, int n=1)
Delete n rows at the position pos.
void eraseCols(int pos, int n=1)
Delete n columns at the specified position of the array.
@ vector_
column oriented vector/array/expression

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, and STK::Arrays::vector_.

◆ eraseCols()

template<class Derived >
void STK::IArray2D< Derived >::eraseCols ( int  pos,
int  n = 1 
)

Delete n columns at the specified position of the array.

Parameters
posthe position of the deleted Columns
nthe number of column to delete (default is 1)

Definition at line 468 of file STK_IArray2DModifiers.h.

469 {
470 if (n<=0) return;
471 if (isRef())
472 { STKRUNTIME_ERROR_2ARG(IArray2D::eraseCols,pos,n,cannot operate on reference);}
473#ifdef STK_BOUNDS_CHECK
474 if (beginCols() > pos)
476 if (endCols() <= pos)
478 if (endCols() < pos+n)
480#endif
481 // delete each col
482 freeCols(Range(pos, n));
483 // update cols_, rangeCols_
484 this->decLastIdxCols(n);
485 rangeCols_.erase(pos, n);
486 allocator_.memmove(pos, Range(pos+n, endCols()-pos));
487 // liberate memory if there is no more columns (don't use clear(), as we want to preserve rows_)
488 if (sizeCols() == 0) { freeMem();}
489 }
#define STKRUNTIME_ERROR_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:120
int sizeCols() const
TRange< UnknownSize > Range
Definition STK_Range.h:59
void memmove(int pos, TRange< RangeSize_ > const &range)
function moving a part of the allocator.

Referenced by STK::IArray2D< Array2D< Type_ > >::popBackCols(), STK::IArray2D< Array2D< Type_ > >::popFrontCols(), and STK::IArray2D< Array2D< Type_ > >::pushBackCols().

◆ eraseRows()

template<class Derived >
void STK::IArray2D< Derived >::eraseRows ( int  pos,
int  n = 1 
)

Delete n rows at the position pos.

Parameters
posindex where to delete elements
nnumber of rows to delete (default is 1)

Definition at line 528 of file STK_IArray2DModifiers.h.

529 {
530 if (n<=0) return;
531 // is this structure just a pointer?
532 if (isRef())
533 { STKRUNTIME_ERROR_2ARG(IArray2D::eraseRows,pos,n,cannot operate on reference);}
534#ifdef STK_BOUNDS_CHECK
535 if (beginRows() > pos)
537 if (endRows() <= pos)
539 if (endRows() < pos+n)
541#endif
542
543 for (int j=beginCols(); j<endCols(); j++) { eraseRowsCol(j, pos, n);}
544 this->decLastIdxRows(n);
545 }
void eraseRowsCol(int col, int pos, int n)
Internal method for deleting rows from a specified column.

References STK::IArray2D< Derived >::eraseRows(), STKOUT_OF_RANGE_2ARG, and STKRUNTIME_ERROR_2ARG.

Referenced by STK::SArray2DVector< Type_ >::erase(), STK::IArray2D< Derived >::eraseRows(), and main().

◆ eraseRowsCol()

template<class Derived >
void STK::IArray2D< Derived >::eraseRowsCol ( int  col,
int  pos,
int  n 
)
private

Internal method for deleting rows from a specified column.

Delete n rows at the position pos to the column col of the array.

Note
It is possible to remove data outside the range of the column (but not outside the range of the array). In this case it is assumed that the data are zero and are not stored by the array (like for triangular or diagonal matrices).
Warning
No check is done about indexes.
Parameters
col,pos,nindex of the column, row position and number of elements to delete

Definition at line 643 of file STK_IArray2DModifiers.h.

644{
645 // check trivial cases
646 if (rangeCols_[col].lastIdx() < pos) return;
647 if (rangeCols_[col].begin()> pos+n-1)
648 { shiftRowCol( col, rangeCols_[col].begin() - n); return;}
649
650 // find the existing rows to delete
651 Range newRange(pos, n);
652 newRange.inf(rangeCols_[col]);
653 if (newRange == rangeCols_[col]) { freeCol(col); return;}
654
655 // copy remaining rows
656 allocator_.elt(col)->memmove(newRange.begin(), newRange.end(), rangeCols_[col].end() - newRange.end());
657 rangeCols_[col].decLast(newRange.size());
658
659 // shift if necessary [if pos<newRange.begin() there is a "padding" to take into account]
660 if (pos < newRange.begin())
661 { shiftRowCol( col, rangeCols_[col].begin() - (n-newRange.size()));}
662}
void shiftRowCol(int col, int beg)
internal method for translating a column.
void freeCol(int col)
Internal method for memory deallocation.

◆ exchange()

template<class Derived >
void STK::IArray2D< Derived >::exchange ( IArray2D< Derived > &  T)

exchange this container with T.

Parameters
Tthe container to exchange with this

Definition at line 872 of file STK_IArray2D.h.

873{
874 // swap MemAllocator part
875 allocator_.exchange(T.allocator_);
877 rangeCols_.exchange(T.rangeCols_);
878}
void exchange(IContainer2D &T)
exchange this container with T
void exchange(MemAllocator &T)
exchange this with T.

References STK::IArray2D< Derived >::allocator_, and STK::IArray2D< Derived >::rangeCols_.

◆ freeCol()

template<class Derived >
void STK::IArray2D< Derived >::freeCol ( int  col)
private

Internal method for memory deallocation.

Parameters
colthe number of the column to free

Definition at line 1051 of file STK_IArray2D.h.

1052{
1053#ifdef STK_DEBUG_ARRAY2D
1054 stk_cout << _T("Entering freeCol\n");
1055 stk_cout << _T("Deleting col=") << col <<_T(", rangeCols_[col]=") << rangeCols_[col] <<_T("\n");
1056 stk_cout << _T("allocator_.elt(col)=") << allocator_.elt(col) <<_T("\n");
1057#endif
1058 if (allocator_.elt(col)) // if there is a column at this position
1059 {
1060 delete allocator_.elt(col);
1061 allocator_.elt(col) =0;
1062 rangeCols_[col] = Range();
1063 }
1064}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.

References _T, and stk_cout.

◆ freeCols()

template<class Derived >
void STK::IArray2D< Derived >::freeCols ( Range const J)
private

Internal method for releasing memory in a given range of columns.

Parameters
Jrange of columns to liberate.

Definition at line 959 of file STK_IArray2D.h.

960{ for (int j=J.begin(); j<J.end(); j++) { freeCol(j);}}

◆ freeMem()

template<class Derived >
void STK::IArray2D< Derived >::freeMem ( )
private

Internal method for memory deallocation.

This method clear all allocated memory and reset ranges to default value. Do nothing if this is a reference Range of the columns is set to default. Range of the rows (rows_) remains unmodified.

Definition at line 887 of file STK_IArray2D.h.

888{
889 if (isRef()) return;
890 freeCols(cols());
891 // free memory allocated in allocator.
892 // For fixed size arrays, the size remain the same
895 // clear arrays
896 rangeCols_.resize(cols());
897}
void setCols(ColRange const &J=ColRange())
Set the columns range.
void free()
function for main ptr memory deallocation.
AllocatorRange const & range() const

◆ initializeCol()

template<class Derived >
void STK::IArray2D< Derived >::initializeCol ( int  col,
Range const I 
)
private

Internal method for initializing a column.

Method for the allocation of memory of the column col with given range I.

Parameters
col,Iindex and range of the column to initialize

Definition at line 1024 of file STK_IArray2D.h.

1025{
1026#ifdef STK_DEBUG_ARRAY2D
1027 stk_cout << _T("Entering initializeCol\n");
1028 stk_cout << _T("Initialize col=") << col <<_T(", I=") << I <<_T("\n");
1029#endif
1030 if (I.size() <=0)
1031 {
1032 allocator_.elt(col) = 0;
1033 rangeCols_[col] = I;
1034 return;
1035 }
1036 // try to allocate memory
1037 try
1038 { allocator_.elt(col) = new ColVector(I);}
1039 catch (std::bad_alloc & error) // if an alloc error occur
1040 {
1041 allocator_.elt(col) = 0;
1042 rangeCols_[col] = Range();
1043 STKRUNTIME_ERROR_2ARG(IArray2D::initializeCol,col, I,memory allocation failed.);
1044 }
1045 rangeCols_[col] = I;
1046}
void initializeCol(int col, Range const &I)
Internal method for initializing a column.
hidden::Traits< Derived >::ColVector ColVector

References _T, STK::IRunnerBase::error(), STK::IArray2D< Derived >::initializeCol(), stk_cout, and STKRUNTIME_ERROR_2ARG.

Referenced by STK::IArray2D< Derived >::initializeCol().

◆ initializeCols()

template<class Derived >
void STK::IArray2D< Derived >::initializeCols ( Range const J)
private

Internal method for memory allocation and initialization of a range of columns.

The capacity for the rows have to be set before calling this method.

Parameters
Jvertical range of the Columns to initialize

Definition at line 935 of file STK_IArray2D.h.

936{
937#ifdef STK_BOUNDS_CHECK
938if (beginCols() > J.begin())
940if (endCols() < J.end())
942#endif
943 for (int j=J.begin(); j<J.end(); j++)
944 {
945 try
946 { initializeCol(j, this->rangeRowsInCol(j));}
947 catch (Exception const& error) // if an error occur
948 {
949 // free each column allocated and throw exception
950 for (int k=J.begin(); k<j; k++) freeCol(k);
951 throw error;
952 }
953 }
954}

References STK::IRunnerBase::error(), STK::IArray2D< Derived >::initializeCols(), and STKOUT_OF_RANGE_1ARG.

Referenced by STK::IArray2D< Derived >::IArray2D(), STK::IArray2D< Derived >::IArray2D(), and STK::IArray2D< Derived >::initializeCols().

◆ insert()

template<class Derived >
void STK::IArray2D< Derived >::insert ( Range const I,
Type const v 
)

STL compatibility: insert element v in the range I of the Array.

Parameters
v,Ivalue and range of indexes

Definition at line 571 of file STK_IArray2DModifiers.h.

572{ // insert defined for vector, point and diagonal arrays
574 this->asDerived().insertElt(I.begin(), I.size());
575 for (int i=I.begin(); i<I.end(); i++) { elt(i) = v;}
576}

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ insertCols()

template<class Derived >
void STK::IArray2D< Derived >::insertCols ( int  pos,
int  n = 1 
)

Insert n columns at the index pos to the array.

Parameters
posposition to insert columns
nthe number of column to insert (default is 1)

Definition at line 440 of file STK_IArray2DModifiers.h.

441 {
442 if (n <= 0) return;
443
444 if (isRef())
445 { STKRUNTIME_ERROR_2ARG(IArray2D::insertCols,pos,n,cannot operate on reference);}
446#ifdef STK_BOUNDS_CHECK
447 if (beginCols() > pos)
449 if (endCols() < pos)
451#endif
452 // compute column range of the array after insertion
453 Range OldRange(cols()), NewRange(cols());
454 NewRange.incLast(n);
455 reallocCols(NewRange);
456 // translate and copy last Columns from Taux to this
457 for (int k=OldRange.lastIdx(); k>=pos; k--)
458 { transferCol(k+n, k);}
459 // initialize the rows in the range pos:pos+n-1
460 nullCols( Range(pos, n) );
461 initializeCols( Range(pos, n) );
462 }
void nullCols(ColRange const &J)
Internal method for initializing to default values (null pointer and null range) to a range of column...
void reallocCols(Range const &J)
Method for memory reallocation and initialization of the horizontal range of the container.
void transferCol(int pos1, int pos2)
Transfer the column pos2 to the column pos1 of this.
void insertCols(int pos, int n=1)
Insert n columns at the index pos to the array.

Referenced by main(), and STK::IArray2D< Array2D< Type_ > >::pushFrontRows().

◆ insertRows()

template<class Derived >
void STK::IArray2D< Derived >::insertRows ( int  pos,
int  n = 1 
)

Insert n rows at position pos in the array If pos is outside the range of a column, then the method do nothing (useful for triangular/diagonal/... arrays).

Parameters
posindex where to insert rows
nnumber of elements to insert (default is 1)

Definition at line 499 of file STK_IArray2DModifiers.h.

500 {
501 if (n <= 0) return;
502 if (isRef())
503 { STKRUNTIME_ERROR_2ARG(IArray2D::insertRows,pos,n,cannot operate on reference);}
504#ifdef STK_BOUNDS_CHECK
505 if (beginRows() > pos)
507 if (endRows() < pos)
509#endif
510
511 this->incLastIdxRows(n);
512 for (int j=beginCols(); j<endCols(); j++)
513 {
514 if (!allocator_.elt(j))
515 { initializeCol(j, this->rangeRowsInCol(j));}
516 else
517 {
518 if ( (pos >= rangeCols_[j].begin()) && (pos <= rangeCols_[j].end()))
519 { insertRowsCol(j, pos, n);}
520 }
521 }
522 }
void insertRowsCol(int col, int pos, int n)
Internal method for inserting rows to a specified column.
void insertRows(int pos, int n=1)
Insert n rows at position pos in the array If pos is outside the range of a column,...

Referenced by STK::IArray2D< Array2D< Type_ > >::erase(), STK::IArray2D< Array2D< Type_ > >::insert(), STK::SArray2DVector< Type_ >::insertElt(), and main().

◆ insertRowsCol()

template<class Derived >
void STK::IArray2D< Derived >::insertRowsCol ( int  col,
int  pos,
int  n 
)
private

Internal method for inserting rows to a specified column.

Insert n rows at the position pos to the column column of the array. No check is done about the index.

Parameters
col,pos,ncolumn position, row position and number of rows to insert

Definition at line 625 of file STK_IArray2DModifiers.h.

626{
627 allocator_.elt(col)->insertElt(pos, n);
628 rangeCols_[col].incLast(n);
629}

◆ isRef()

template<class Derived >
bool STK::IArray2D< Derived >::isRef ( ) const
inline
Returns
true if the container is empty, false otherwise

Definition at line 171 of file STK_IArray2D.h.

171{ return allocator_.isRef();}

References STK::IArray2D< Derived >::allocator_, and STK::MemAllocator< Type_, Size_ >::isRef().

Referenced by main(), STK::IArray2D< Derived >::merge(), and STK::IArray2D< Derived >::merge().

◆ lastIdxCols()

template<class Derived >
int STK::IArray2D< Derived >::lastIdxCols ( ) const
inline
Returns
the index of the last column

Definition at line 196 of file STK_IArray2D.h.

196{ return Base2D::lastIdxCols();}
int lastIdxCols() const

References STK::IContainer2D< SizeRows_, SizeCols_ >::lastIdxCols().

Referenced by STK::IArray2D< Derived >::update().

◆ lastIdxRows()

template<class Derived >
int STK::IArray2D< Derived >::lastIdxRows ( ) const
inline
Returns
the index of the last row

Definition at line 198 of file STK_IArray2D.h.

198{ return Base2D::lastIdxRows();}
int lastIdxRows() const

References STK::IContainer2D< SizeRows_, SizeCols_ >::lastIdxRows().

Referenced by STK::Svd< Array >::diag().

◆ mallocCols()

template<class Derived >
void STK::IArray2D< Derived >::mallocCols ( ColRange const J)
private

Internal method for memory allocation and initialization of the horizontal range of the container.

This method is called once at creation of the container.

The range of the column is not set in this method. Except if an error occur during memory allocation, cols_ will be set to default and an error thrown.

Parameters
Jhorizontal range

Definition at line 905 of file STK_IArray2D.h.

906{
907 // try to allocate memory
908 try
909 {
910 if (J.size() > availableCols())
911 {
912 // compute the necessary size
913 int size= Arrays::evalSizeCapacity(J.size());
914 allocator_.malloc(Range(J.begin(), size)); // allocate memory for the columns
915 }
916 else
917 { allocator_.shift(J.begin());}
918 rangeCols_.resize(J);
919 }
920 catch (Exception const& error) // if an error occur
921 {
922 Base2D::setCols(); // set default range
923 rangeCols_.clear(); // clear this->rangeCols_
924 allocator_.free(); // initialize with zero
925 allocator_.setValue(0); // initialize with zero
926 throw error; // throw the error
927 }
928 allocator_.setValue(0); // initialize with zero
929}
int availableCols() const
void setCols(ColRange const &J=ColRange())
Set the columns range.
int evalSizeCapacity(int m)
void malloc(TRange< OtherSize > const &I)
main method for memory allocation.
MemAllocator & shift(int first)
shift the first index of the data to first.
void setValue(TypeConst value)
This method allows to set a value to the allocator.

References STK::IRunnerBase::error(), and STK::Arrays::evalSizeCapacity().

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

◆ merge() [1/2]

template<class Derived >
template<class OtherDerived >
void STK::IArray2D< Derived >::merge ( IArray1D< OtherDerived > const other)
inline

Append the vector other to this without copying the data explicitly.

other is appended to this and other will become a reference container. The data in itself are not altered, the Array1D become a reference on its own data.

Parameters
otherthe container to merge with this

Definition at line 587 of file STK_IArray2D.h.

588 {
589 // checks
590 if (isRef())
591 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(IArray1D),*this is a reference.);}
592 if (other.isRef())
593 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(IArray1D),other is a reference.);}
594 // if there is no columns, we can safely modify the vertical range
595 if (this->sizeCols() <= 0) setRows(other.range());
596 if (this->rows() != other.range())
597 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(IArray1D),this->rows() != other.range());}
598
599 // compute horizontal range of the container after insertion
600 Range cols(this->cols());
601
602 // reallocate memory for the columns
603 cols.incLast(1);
605
606 // set column
607 allocator_.elt(cols.lastIdx()) = const_cast<OtherDerived*>(other.asPtrDerived());
608 rangeCols_[cols.lastIdx()] = other.range();
609
610 // set other as reference
611 other.setRef(true);
612 }
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
void setRows(RowRange const &I=RowRange())
Set the range of the number of rows.
void merge(IArray2D< OtherDerived > const &other)
Append the container other to this without copying the data explicitly.
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
Definition STK_Range.h:242
int lastIdx() const
get the last index of the TRange.
Definition STK_Range.h:206

References STK::IArray2D< Derived >::allocator_, STK::IArray2D< Derived >::cols(), STK::MemAllocator< Type_, Size_ >::elt(), STK::TRange< UnknownSize >::incLast(), STK::IArray2D< Derived >::isRef(), STK::TRange< Size_ >::lastIdx(), STK::IArray2D< Derived >::merge(), STK::IArray2D< Derived >::rangeCols_, STK::IArray2D< Derived >::reallocCols(), STK::IArray2D< Derived >::rows(), STK::IArray2D< Derived >::setRows(), STK::IArray2D< Derived >::sizeCols(), and STKRUNTIME_ERROR_NO_ARG.

◆ merge() [2/2]

template<class Derived >
template<class OtherDerived >
void STK::IArray2D< Derived >::merge ( IArray2D< OtherDerived > const other)
inline

Append the container other to this without copying the data explicitly.

The column of other are appended to this.

Observe that the const keyword is not respected in this method: but it is useful to define this method even for constant objects.

Note
data in itself are not altered nor duplicated, thus other and this possess the same columns.
Parameters
otherthe container to merge with this

Definition at line 548 of file STK_IArray2D.h.

549 {
550 //checks
551 if (isRef())
552 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(other),*this is a reference.);}
553 if (other.isRef())
554 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(other),other is a reference.);}
555 // if there is no columns, we can safely modify the vertical range
556 if (this->sizeCols() <= 0) setRows(other.rows());
557 if (this->rows() != other.rows())
558 { STKRUNTIME_ERROR_NO_ARG(IArray2D::merge(other),this->rows() != other.rows());}
559
560 // break const reference
561 IArray2D< OtherDerived>& Tref = const_cast<IArray2D< OtherDerived>&>(other);
562 // compute horizontal range of the container after insertion
563 Range cols(this->cols());
564
565 // save first index of the first column added before modification of cols
566 const int first = cols.end();
567 // reallocate memory for the columns
568 cols.incLast(Tref.sizeCols());
570
571 // copy data from other
572 Tref.shiftCols(first); // easiest like that
573 for (int j=first; j< cols.end(); j++)
574 { transferCol(Tref, j);}
575
576 // delete and set view on the data
577 Tref.allocator().free();
578 Tref.allocator().setPtr(allocator_.p_data(), Tref.cols(), true);
579 }
int end() const
get the ending index of the TRange.
Definition STK_Range.h:192
Type *const & p_data() const
Get constant pointer on data.

References STK::IArray2D< Derived >::allocator_, STK::IArray2D< Derived >::cols(), STK::TRange< Size_ >::end(), STK::TRange< Size_ >::incLast(), STK::IArray2D< Derived >::isRef(), STK::IArray2D< Derived >::merge(), STK::MemAllocator< Type_, Size_ >::p_data(), STK::IArray2D< Derived >::reallocCols(), STK::IArray2D< Derived >::rows(), STK::IArray2D< Derived >::setRows(), STK::IArray2D< Derived >::sizeCols(), STKRUNTIME_ERROR_NO_ARG, and STK::IArray2D< Derived >::transferCol().

Referenced by STK::AdditiveBSplineCoefficients< Array >::extrapolate(), main(), STK::IArray2D< Derived >::merge(), STK::IArray2D< Derived >::merge(), and STK::AdditiveBSplineCoefficients< Array >::run().

◆ move()

template<class Derived >
Derived & STK::IArray2D< Derived >::move ( Derived const T)

move T to this.

Note
: T is not modified but just set as a reference of the data it was responsible.
Parameters
Tthe array to move.

Definition at line 856 of file STK_IArray2D.h.

857{
858 if (this->asPtrDerived() == &T) return this->asDerived();
859 if (!isRef()) { freeCols(cols());}
860 // move Base part
861 allocator_.move(T.allocator_); // T become a reference
862 rangeCols_.move(T.rangeCols_);
863 // Set IContainer2D part
864 setCols(T.cols());
865 setRows(T.rows());
866 return this->asDerived();
867}
MemAllocator & move(MemAllocator const &T)
move the Allocator T to this.

Referenced by STK::applySort1D(), main(), STK::MultidimRegression< Array, Weight >::regressionStep(), and STK::MultidimRegression< Array, Weight >::regressionStep().

◆ nullCol()

template<class Derived >
void STK::IArray2D< Derived >::nullCol ( int  col)
private

Internal method setting default parameters and dimension to a column of the container.

Parameters
colthe position of the column to initialize to a default value.
Note
if data is allocated, it will be lost

Definition at line 1013 of file STK_IArray2D.h.

1014{
1015 allocator_.elt(col) = 0;
1016 rangeCols_[col] = Range();
1017}

◆ nullCols()

template<class Derived >
void STK::IArray2D< Derived >::nullCols ( ColRange const J)
protected

Internal method for initializing to default values (null pointer and null range) to a range of columns.

Parameters
Jhorizontal range

Definition at line 998 of file STK_IArray2D.h.

999{
1000#ifdef STK_BOUNDS_CHECK
1001 if (beginCols() > J.begin())
1003 if (endCols() < J.end())
1005#endif
1006 for (int j=J.begin(); j<J.end(); ++j) { nullCol(j);}
1007}
void nullCol(int col)
Internal method setting default parameters and dimension to a column of the container.

References STK::IArray2D< Derived >::nullCols(), and STKOUT_OF_RANGE_1ARG.

Referenced by STK::IArray2D< Derived >::nullCols().

◆ operator()() [1/7]

template<class Derived >
Type & STK::IArray2D< Derived >::operator() ( )
inline
Returns
the number

Definition at line 296 of file STK_IArray2D.h.

296{ return elt();}

◆ operator()() [2/7]

template<class Derived >
TypeConst STK::IArray2D< Derived >::operator() ( ) const
inline
Returns
a constant reference on the number

Definition at line 294 of file STK_IArray2D.h.

294{ return elt();}

◆ operator()() [3/7]

template<class Derived >
Type & STK::IArray2D< Derived >::operator() ( int  i,
int  j 
)
inline
Returns
a reference on the element (i,j) of the 2D container.
Parameters
i,jindexes of the element to get

Definition at line 259 of file STK_IArray2D.h.

260 {
261#ifdef STK_BOUNDS_CHECK
262 if (this->beginRows() > i) { STKOUT_OF_RANGE_2ARG(IArray2D::elt, i, j, beginRows() > i);}
263 if (this->endRows() <= i) { STKOUT_OF_RANGE_2ARG(IArray2D::elt, i, j, endRows() <= i);}
264 if (this->beginCols() > j) { STKOUT_OF_RANGE_2ARG(IArray2D::elt, i, j, beginCols() > j);}
265 if (this->endCols() <= j) { STKOUT_OF_RANGE_2ARG(IArray2D::elt, i, j, endCols() <= j);}
266#endif
267 return elt(i,j);
268 }

References STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::beginRows(), STK::IArray2D< Derived >::endCols(), STK::IArray2D< Derived >::endRows(), and STKOUT_OF_RANGE_2ARG.

◆ operator()() [4/7]

template<class Derived >
TypeConst STK::IArray2D< Derived >::operator() ( int  i,
int  j 
) const
inline
Returns
a constant reference on the element (i,j) of the 2D container.
Parameters
i,jrow and column indexes

Definition at line 246 of file STK_IArray2D.h.

247 {
248#ifdef STK_BOUNDS_CHECK
249 if (beginRows() > i) { STKOUT_OF_RANGE_2ARG(IArray::elt, i, j, beginRows() > i);}
250 if (endRows() <= i) { STKOUT_OF_RANGE_2ARG(IArray::elt, i, j, endRows() <= i);}
251 if (beginCols() > j) { STKOUT_OF_RANGE_2ARG(IArray::elt, i, j, beginCols() > j);}
252 if (endCols() <= j) { STKOUT_OF_RANGE_2ARG(IArray::elt, i, j, endCols() <= j);}
253#endif
254 return elt(i,j);
255 }

References STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::beginRows(), STK::IArray2D< Derived >::endCols(), STK::IArray2D< Derived >::endRows(), and STKOUT_OF_RANGE_2ARG.

◆ operator()() [5/7]

template<class Derived >
hidden::Traits< Derived >::SubRow STK::IArray2D< Derived >::operator() ( int  i,
Range const J 
) const
inline
Parameters
i,Jindex of the row and range of the columns
Returns
an Horizontal container containing the row i of this in the range J

Definition at line 147 of file STK_IArray2DSlicers.h.

147{ return this->row(i, J);}

◆ operator()() [6/7]

template<class Derived >
hidden::Traits< Derived >::SubCol STK::IArray2D< Derived >::operator() ( Range const I,
int  j 
) const
inline
Parameters
I,jrange of the rows and index of the column
Returns
a Vertical container containing the column j of this in the range I

Definition at line 131 of file STK_IArray2DSlicers.h.

132{
133#ifdef STK_BOUNDS_CHECK
134 if (beginRows() > I.begin()) { STKOUT_OF_RANGE_2ARG(IArray::operator(), I, j, beginRows() > I.begin());}
135 if (endRows() < I.end()) { STKOUT_OF_RANGE_2ARG(IArray::operator(), I, j, endRows() < I.end());}
136 if (beginCols() > j) { STKOUT_OF_RANGE_2ARG(IArrayBase::operator(), I, j, beginCols() > j);}
137 if (endCols() <= j) { STKOUT_OF_RANGE_2ARG(IArrayBase::operator(), I, j, endCols() < j);}
138#endif
139 return col(I, j);
140}

References STKOUT_OF_RANGE_2ARG.

◆ operator()() [7/7]

template<class Derived >
hidden::Traits< Derived >::SubArray STK::IArray2D< Derived >::operator() ( Range const I,
Range const J 
) const
inline
Parameters
I,Jrange of the rows and of the columns
Returns
a 2D container containing this in the range I, J

Definition at line 152 of file STK_IArray2DSlicers.h.

153{ return sub(I, J);}
SubVector sub(Range const &J) const

◆ operator[]() [1/3]

template<class Derived >
Type & STK::IArray2D< Derived >::operator[] ( int  i)
inline
Returns
a reference on the ith element
Parameters
iindex of the element to get

Definition at line 284 of file STK_IArray2D.h.

285 {
287#ifdef STK_BOUNDS_CHECK
288 if (this->asDerived().begin() > i) { STKOUT_OF_RANGE_1ARG(IArray2D::elt, i, begin() > i);}
289 if (this->asDerived().end() <= i) { STKOUT_OF_RANGE_1ARG(IArray2D::elt, i, end() <= i);}
290#endif
291 return elt(i);
292 }

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, and STKOUT_OF_RANGE_1ARG.

◆ operator[]() [2/3]

template<class Derived >
TypeConst STK::IArray2D< Derived >::operator[] ( int  i) const
inline
Returns
the ith element
Parameters
iindex of the element to get

Definition at line 272 of file STK_IArray2D.h.

273 {
275#ifdef STK_BOUNDS_CHECK
276 if (this->asDerived().begin() > i) { STKOUT_OF_RANGE_1ARG(IArray2D::elt, i, begin() > i);}
277 if (this->asDerived().end() <= i) { STKOUT_OF_RANGE_1ARG(IArray2D::elt, i, end() <= i);}
278#endif
279 return elt(i);
280 }

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, and STKOUT_OF_RANGE_1ARG.

◆ operator[]() [3/3]

template<class Derived >
hidden::Traits< Derived >::SubVector STK::IArray2D< Derived >::operator[] ( Range const I) const
inline
Returns
the sub-vector in given range
Parameters
Irange to get

Definition at line 120 of file STK_IArray2DSlicers.h.

121{
123 return sub(I);
124}

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ popBackCols()

template<class Derived >
void STK::IArray2D< Derived >::popBackCols ( int  n = 1)

Delete last columns of the array.

Parameters
nthe number of Columns to delete (default is 1)

Definition at line 371 of file STK_IArray2DModifiers.h.

372{
373 if (n<=0) return;
374 if (isRef())
375 { STKRUNTIME_ERROR_1ARG(IArray2D::popBackCols,n,cannot operate on reference);}
376#ifdef STK_BOUNDS_CHECK
377 if (sizeCols() < n)
379#endif
380
381 eraseCols(endCols()-n, n);
382}
#define STKRUNTIME_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:129
void popBackCols(int n=1)
Delete last columns of the array.

Referenced by main(), STK::IArray2D< Derived >::popFrontCols(), STK::IArray2D< Array2D< Type_ > >::reserveCols(), and STK::IArray2D< Array2D< Type_ > >::reserveRows().

◆ popBackRows()

template<class Derived >
void STK::IArray2D< Derived >::popBackRows ( int  n = 1)

Delete n latest rows of the array.

Parameters
nnumber of rows to delete (default is 1)

Definition at line 255 of file STK_IArray2DModifiers.h.

256{
257 if (n <= 0) return;
258 if (isRef())
259 { STKRUNTIME_ERROR_1ARG(IArray2D::popBackRows,n,cannot operate on reference);}
260#ifdef STK_BOUNDS_CHECK
261 if (sizeRows() < n)
263#endif
264 eraseRows(endRows()-n, n);
265}
int sizeRows() const
void popBackRows(int n=1)
Delete n latest rows of the array.

References STK::IArray2D< Derived >::popBackRows(), STKOUT_OF_RANGE_1ARG, and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IArray2D< Derived >::popBackRows().

◆ popFrontCols()

template<class Derived >
void STK::IArray2D< Derived >::popFrontCols ( int  n = 1)

Delete first columns of the array.

Parameters
nthe number of Columns to delete (default is 1)

Definition at line 355 of file STK_IArray2DModifiers.h.

356{
357 if (n<=0) return;
358 if (isRef())
359 { STKRUNTIME_ERROR_1ARG(IArray2D::popBackCols,n,cannot operate on reference);}
360#ifdef STK_BOUNDS_CHECK
361 if (sizeCols() < n)
363#endif
364
365 eraseCols(beginCols(), n);
366}

References STK::IArray2D< Derived >::popBackCols(), STKOUT_OF_RANGE_1ARG, and STKRUNTIME_ERROR_1ARG.

◆ popFrontRows()

template<class Derived >
void STK::IArray2D< Derived >::popFrontRows ( int  n = 1)

Delete n first rows of the array.

Parameters
nnumber of rows to delete (default is 1)

Definition at line 240 of file STK_IArray2DModifiers.h.

241{
242 if (n <= 0) return;
243 if (isRef())
244 { STKRUNTIME_ERROR_1ARG(IArray2D::popFrontRows,n,cannot operate on reference);}
245#ifdef STK_BOUNDS_CHECK
246 if (sizeRows() < n)
248#endif
249 eraseRows(endRows()-n, n);
250}
void popFrontRows(int n=1)
Delete n first rows of the array.

References STK::IArray2D< Derived >::popFrontRows(), STKOUT_OF_RANGE_1ARG, and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IArray2D< Derived >::popFrontRows().

◆ ptr()

template<class Derived >
PtrColConst STK::IArray2D< Derived >::ptr ( int  j) const
inline
Returns
a constant pointer on the j-th column of the container
Parameters
jthe index of the column

Definition at line 208 of file STK_IArray2D.h.

208{ return allocator_.elt(j);}

References STK::IArray2D< Derived >::allocator_, and STK::MemAllocator< Type_, Size_ >::elt().

Referenced by STK::IArray2D< Derived >::capacityCol(), and STK::IArray2D< Derived >::elt2Impl().

◆ push_back()

template<class Derived >
void STK::IArray2D< Derived >::push_back ( Type const v)

STL compatibility: append an element v.

Parameters
vvalue to append back

Definition at line 561 of file STK_IArray2DModifiers.h.

562{ // push_back defined for vector, point and diagonal arrays
564 this->asDerived().pushBack();
565 this->back() = v;
566}

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ push_front()

template<class Derived >
void STK::IArray2D< Derived >::push_front ( Type const v)

STL compatibility: push front an element.

Parameters
vvalue to push front

Definition at line 552 of file STK_IArray2DModifiers.h.

553{ // push_front defined for vector, point and diagonal arrays
555 insert(Range(this->begin(), 1), v);
556}
void insert(Range const &I, Type const &v)
STL compatibility: insert element v in the range I of the Array.

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ pushBackCols() [1/2]

template<class Derived >
template<class Other >
Derived & STK::IArray2D< Derived >::pushBackCols ( IArray1D< Other > const other)

Specialization for Array1D.

merge (by value) the array other with this

Parameters
otherthe column to add to this

Definition at line 413 of file STK_IArray2DModifiers.h.

414{
415 // check if the array is empty
416 if (empty())
417 {
418 resize(other.rows(),1);
419 for (int i=other.begin(); i<other.end(); i++)
420 (*this)(i, lastIdxCols()) = other[i];
421 return this->asDerived();
422 }
423 // not empty
424 if (other.rows() != this->rows())
425 { STKRUNTIME_ERROR_NO_ARG(IArray2D::pushBackCols(other),other.rows() != rows());}
426 int last = endCols();
427 pushBackCols();
428 for (int i=other.begin(); i<other.end(); i++)
429 (*this)(i, last) = other[i];
430 // return this
431 return this->asDerived();
432}
int lastIdxCols() const
Derived & resize(Range const &I, Range const &J)
resize the array.
void pushBackCols(int n=1)
Add n columns at the end of the array.
bool empty() const

◆ pushBackCols() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::pushBackCols ( int  n = 1)

Add n columns at the end of the array.

Parameters
nthe number of Columns to add (default is 1)

Definition at line 343 of file STK_IArray2DModifiers.h.

344{
345 if (n <= 0) return;
346 if (isRef())
347 { STKRUNTIME_ERROR_1ARG(IArray2D::pushBackCols,n,cannot operate on reference);}
348
349 insertCols(endCols(), n );
350}

References STK::IArray2D< Derived >::pushBackCols(), and STKRUNTIME_ERROR_1ARG.

Referenced by main(), and STK::IArray2D< Derived >::pushBackCols().

◆ pushBackRows() [1/2]

template<class Derived >
template<class Other >
Derived & STK::IArray2D< Derived >::pushBackRows ( ExprBase< Other > const other)

set other at the end of this (concatenate).

Perform a copy of the values stored in other to this.

Parameters
otherthe array to add back
Note
the size and the type have to match

Definition at line 302 of file STK_IArray2DModifiers.h.

303{
304 // check if the array is empty
305 if (empty())
306 {
307 this->asDerived() = other.asDerived();
308 return this->asDerived();
309 }
310 // not empty
311 if (other.cols() != this->cols())
312 STKRUNTIME_ERROR_NO_ARG(IArray2D::pushBackRows,range of the columns are different);
313 // add nbRow to existing rows
314 int nbRow = other.sizeRows();
315 pushBackRows(nbRow);
316 for (int j=beginCols(); j< endCols(); ++j)
317 {
318 // start from the end in order to avoid
319 for (int i=this->lastIdxRows(), iOther= other.lastIdxRows(); iOther>=other.beginRows(); --i, --iOther)
320 { elt(i,j) = other.elt(iOther,j);}
321 }
322 // return this
323 return this->asDerived();
324}
void pushBackRows(int n=1)
Add n rows to the array.

References STK::IArray2D< Derived >::pushBackRows(), and STKRUNTIME_ERROR_NO_ARG.

◆ pushBackRows() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::pushBackRows ( int  n = 1)

Add n rows to the array.

Parameters
nnumber of rows to add (default is 1)

Definition at line 228 of file STK_IArray2DModifiers.h.

229{
230 if (n <= 0) return;
231 if (isRef())
232 { STKRUNTIME_ERROR_1ARG(IArray2D::pushBackRows,n,cannot operate on reference);}
233
234 insertRows(endRows(), n);
235}

References STK::IArray2D< Derived >::pushBackRows(), and STKRUNTIME_ERROR_1ARG.

Referenced by main(), STK::SArray2DVector< Type_ >::pushBack(), STK::IArray2D< Derived >::pushBackRows(), STK::IArray2D< Derived >::pushBackRows(), and STK::IArray2D< Derived >::pushFrontRows().

◆ pushFrontCols() [1/2]

template<class Derived >
template<class Other >
Derived & STK::IArray2D< Derived >::pushFrontCols ( ExprBase< Other > const other)

merge (by value) the array other with this.

Parameters
otherthe array to merge to this

Definition at line 388 of file STK_IArray2DModifiers.h.

389{
390 // if the array is empty use operator=
391 if (empty())
392 {
393 this->asDerived() = other.asDerived();
394 return this->asDerived();
395 }
396 // this is not empty
397 if (other.rows() != this->rows())
398 { STKRUNTIME_ERROR_NO_ARG(IArray2D::pushFrontCols,range of the rows are different);}
399 // if the array is not empty we add the column and copy other inside
400 this->asDerived().insertCols(beginCols(), other.sizeCols());
401 for (int j= beginCols(), j1= other.beginCols(); j < endCols(); ++j, ++j1)
402 {
403 *allocator_.elt(j) = other.col(j1);
404 }
405 // return this
406 return this->asDerived();
407}
void pushFrontCols(int n=1)
Insert n columns at the beginning of the array.

◆ pushFrontCols() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::pushFrontCols ( int  n = 1)

Insert n columns at the beginning of the array.

Parameters
nthe number of column to insert (default is 1)

Definition at line 331 of file STK_IArray2DModifiers.h.

332{
333 if (n <= 0) return;
334 if (isRef())
335 { STKRUNTIME_ERROR_1ARG(IArray2D::pushFrontCols,n,cannot operate on reference);}
336
337 insertCols(beginCols(), n );
338}

References STK::IArray2D< Derived >::pushFrontCols(), and STKRUNTIME_ERROR_1ARG.

Referenced by main(), and STK::IArray2D< Derived >::pushFrontCols().

◆ pushFrontRows() [1/2]

template<class Derived >
template<class Other >
Derived & STK::IArray2D< Derived >::pushFrontRows ( ExprBase< Other > const other)

set other at the beginning of this (concatenate).

Perform a copy of the values stored in other to this.

Parameters
otherthe array to add
Note
the size and the type have to match

Definition at line 273 of file STK_IArray2DModifiers.h.

274{
275 // check if the array is empty
276 if (empty())
277 {
278 this->asDerived() = other.asDerived();
279 return this->asDerived();
280 }
281 // not empty
282 if (other.cols() != this->cols())
283 STKRUNTIME_ERROR_NO_ARG(IArray2D::pushBackRows,range of the columns are different);
284 // add nbRow to existing rows
285 int nbRow = other.sizeRows();
286 pushFrontRows(nbRow);
287 for (int j=beginCols(); j< endCols(); ++j)
288 {
289 for (int i=beginRows(), iOther= other.beginRows(); iOther<other.endRows(); ++i, ++iOther)
290 { setValue(i,j, other.elt(iOther,j));}
291 }
292 // return this
293 return this->asDerived();
294}
Derived & setValue(TypeConst value)
set a value to this container.
void pushFrontRows(int n=1)
Insert n rows in front of the array.

References STK::IArray2D< Derived >::pushBackRows(), and STKRUNTIME_ERROR_NO_ARG.

◆ pushFrontRows() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::pushFrontRows ( int  n = 1)

Insert n rows in front of the array.

Parameters
nnumber of elements to insert (default is 1)

Definition at line 216 of file STK_IArray2DModifiers.h.

217{
218 if (n <= 0) return;
219 if (isRef())
220 { STKRUNTIME_ERROR_1ARG(IArray2D::pushFrontRows,n,cannot operate on reference);}
221
222 insertRows(beginRows(), n);
223}

References STK::IArray2D< Derived >::pushFrontRows(), and STKRUNTIME_ERROR_1ARG.

Referenced by main(), and STK::IArray2D< Derived >::pushFrontRows().

◆ rangeCol()

template<class Derived >
Range const & STK::IArray2D< Derived >::rangeCol ( int  col) const
inline
Returns
the range of a column.
Parameters
colindex of the column we want the range

Definition at line 220 of file STK_IArray2D.h.

220{ return rangeCols_[col];}

References STK::IArray2D< Derived >::col(), and STK::IArray2D< Derived >::rangeCols_.

◆ rangeCols()

template<class Derived >
Array1D< Range, sizeCols_ > const & STK::IArray2D< Derived >::rangeCols ( ) const
inline
Returns
the range of each columns.

Definition at line 216 of file STK_IArray2D.h.

216{ return rangeCols_;}

References STK::IArray2D< Derived >::rangeCols_.

◆ reallocCols()

template<class Derived >
void STK::IArray2D< Derived >::reallocCols ( Range const J)
protected

Method for memory reallocation and initialization of the horizontal range of the container.

The vertical range is not set in this method. If an error occur, we set the cols_ of the container to default.

Parameters
Jhorizontal range

Definition at line 979 of file STK_IArray2D.h.

980{
981 Range oldRange(cols());
982 // try to allocate memory
983 if (J.size() > availableCols())
984 {
985 int size= Arrays::evalSizeCapacity(J.size());
986 Range newRange(J.begin(), size);
987 allocator_.realloc( newRange ); // reallocate memory for the columns
988 }
989 rangeCols_.resize(J); // initialize this->rangeCols_
990 setCols(J);
991}
void realloc(TRange< OtherSize > const &I)
function for main ptr memory reallocation.

References STK::Arrays::evalSizeCapacity().

Referenced by STK::IArray2D< Derived >::merge(), and STK::IArray2D< Derived >::merge().

◆ reserve()

template<class Derived >
void STK::IArray2D< Derived >::reserve ( int  sizeRows,
int  sizeCols 
)

function for reserving memory in all the columns

Parameters
sizeRows,sizeColsthe size to reserve for the rows and columns

Definition at line 46 of file STK_IArray2DModifiers.h.

47{
50}
void reserveRows(int size)
Reserve a certain amount of rows in all columns.
void reserveCols(int sizeCols)
Reserve a certain amount of columns.

◆ reserveCols()

template<class Derived >
void STK::IArray2D< Derived >::reserveCols ( int  sizeCols)

Reserve a certain amount of columns.

Parameters
sizeColsthe size to reserve.

Definition at line 61 of file STK_IArray2DModifiers.h.

62{
63 if (availableCols() >= sizeCols) return;
64 // is this structure just a pointer?
65 if (isRef())
66 { STKRUNTIME_ERROR_1ARG(IArray2D::reserveCols,sizeCols,cannot operate on references);}
67 // try to allocate memory
68 try
69 {
70 Range J(this->beginCols(), sizeCols);
72 rangeCols_.reserve(J.size());
73 }
74 catch (Exception const& error) // if an error occur
75 {
77 }
78}

References STK::IRunnerBase::error(), STK::IArray2D< Derived >::reserveCols(), and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IArray2D< Derived >::reserveCols().

◆ reserveRowCol()

template<class Derived >
void STK::IArray2D< Derived >::reserveRowCol ( int  col,
int  size 
)
private

Internal method for reserving rows to a specified column.

reserve size memory place to the column col of the array

Parameters
col,sizeindex of the column and size to reserve

Definition at line 95 of file STK_IArray2DModifiers.h.

96{
97 if (this->capacityCol(col) >= size) return;
98 allocator_.elt(col)->reserve(size);
99}

◆ reserveRows()

template<class Derived >
void STK::IArray2D< Derived >::reserveRows ( int  size)

Reserve a certain amount of rows in all columns.

Parameters
sizethe size to reserve

Definition at line 55 of file STK_IArray2DModifiers.h.

56{ reserveRowsCols(cols(), size);}
void reserveRowsCols(Range const &J, int size)
Internal method for reserving memory in a range of columns.

◆ reserveRowsCols()

template<class Derived >
void STK::IArray2D< Derived >::reserveRowsCols ( Range const J,
int  size 
)
private

Internal method for reserving memory in a range of columns.

Parameters
Jrange of the columns to initialize
sizethe size to reserve

Definition at line 85 of file STK_IArray2DModifiers.h.

86{
87 for (int j=J.begin(); j<J.end(); j++)
88 { reserveRowCol(j, size);}
89}
void reserveRowCol(int col, int size)
Internal method for reserving rows to a specified column.

◆ resize() [1/2]

template<class Derived >
Derived & STK::IArray2D< Derived >::resize ( Range const I)
Returns
the resized row/column/square array
Parameters
Ithe new range for the vector/point

Definition at line 208 of file STK_IArray2DModifiers.h.

209{ return this->asDerived().resize1D(I);}

◆ resize() [2/2]

template<class Derived >
Derived & STK::IArray2D< Derived >::resize ( Range const I,
Range const J 
)

resize the array.

Note
The implicit assumption made by this method is that it is easiest and faster to add column than add rows to the 2D array.
Parameters
Ithe new range for the rows of the array
Jthe new range for the columns of the array

Definition at line 172 of file STK_IArray2DModifiers.h.

173{
174 // check if there is something to do
175 if ((this->rows() == I) && (this->cols() == J)) return this->asDerived();
176 if (isRef())
177 { STKRUNTIME_ERROR_2ARG(IArray2D::resize,I,J,cannot operate on reference);}
178 // translate and check again if there is something to do
179 shift(I.begin(), J.begin());
180 if ((this->rows() == I) && (this->cols() == J)) return this->asDerived();
181 // just clear empty container
182 if (I.size()<=0 || J.size() <= 0)
183 { clear(); return this->asDerived();}
184
185 // number of rows and columns to delete or add
186 int rinc = I.end() - endRows();
187 int cinc = J.end() - endCols();
188
189 // work first on rows as we add columns
190 if ((cinc >=0))
191 {
192 if (rinc < 0) { popBackRows(-rinc);} // less rows
193 else { pushBackRows(rinc);} // more rows
194 pushBackCols(cinc); // add columns
195 }
196 else // work first on columns as we remove column
197 {
198 popBackCols(-cinc); // remove columns
199 if (rinc < 0) { popBackRows(-rinc);} // less rows
200 else { pushBackRows(rinc);} // more rows
201 }
202 return this->asDerived();
203}
void clear()
clear the object.
void shift(int rbeg, int cbeg)
Set new beginning indexes to the array.

References STK::IArray2D< Derived >::resize(), and STKRUNTIME_ERROR_2ARG.

Referenced by STK::bidiag(), STK::Law::Categorical::computeCumProb(), STK::CategoricalBase< Derived >::initializeModelImpl(), STK::LocalVariance< Array >::LocalVariance(), STK::Qr::qr(), STK::IArray2D< Derived >::resize(), STK::SArray2DVector< Type_ >::resize1D(), STK::JointBernoulliParameters::resizeImpl(), STK::JointGammaParameters::resizeImpl(), STK::JointGaussianParameters::resizeImpl(), STK::AdditiveBSplineCoefficients< Array >::run(), STK::lapack::Qr::runImpl(), and STK::MultiLaw::Normal< RowVector >::setParameters().

◆ resizeRowCol()

template<class Derived >
void STK::IArray2D< Derived >::resizeRowCol ( int  col,
Range const I 
)
private

Internal method for resizing a column with a specified range.

This method resize the column col to the desired range using:

  • shiftRow
  • either popBackRowsToCol or pushBackRowsToCol if needed.
    Parameters
    colindex of the column
    Irange to set to the column

Definition at line 601 of file STK_IArray2DModifiers.h.

602{
603 if (rangeCols_[col] == I) return;
604 shiftRowCol(col, I.begin());
605 int inc = rangeCols_[col].size() - I.size();
606 if (inc == 0) return;
607 if (inc < 0)
608 {
609 allocator_.elt(col)->pushBack(-inc);
610 rangeCols_[col].incLast(-inc);
611 }
612 else
613 {
614 rangeCols_[col].decLast(inc);
615 if (rangeCols_[col].size()==0) freeCol(col);
616 }
617}

Referenced by STK::IArray2D< Derived >::update().

◆ row() [1/3]

template<class Derived >
hidden::Traits< Derived >::Row STK::IArray2D< Derived >::row ( int  i) const
inline

access to a part of a row.

Parameters
iindex of the row
Returns
a reference of the row i.

Definition at line 84 of file STK_IArray2DSlicers.h.

85{ return Row( this->asDerived(), this->rangeColsInRow(i), i);}
hidden::Traits< Derived >::Row Row

Referenced by main(), main(), and STK::Qr::qr().

◆ row() [2/3]

template<class Derived >
hidden::Traits< Derived >::SubRow STK::IArray2D< Derived >::row ( int  i,
Range const J 
) const
inline

access to a part of a row.

Parameters
i,Jindex of the row and range of the columns
Returns
a reference of the row i.

Definition at line 92 of file STK_IArray2DSlicers.h.

93{ return SubRow( this->asDerived(), inf(J, this->rangeColsInRow(i)), i);}
hidden::Traits< Derived >::SubRow SubRow

References STK::inf().

◆ row() [3/3]

template<class Derived >
hidden::Traits< Derived >::SubArray STK::IArray2D< Derived >::row ( Range const I) const
inline

access to many rows.

Parameters
Irange of the index of the rows
Returns
a 2D array containing the Container in the vertical range I

Definition at line 99 of file STK_IArray2DSlicers.h.

100{ return SubArray(this->asDerived(), I, cols());}

◆ rows()

template<class Derived >
RowRange const & STK::IArray2D< Derived >::rows ( ) const
inline
Returns
the Vertical range

Definition at line 178 of file STK_IArray2D.h.

178{ return Base2D::rows();}
RowRange const & rows() const

References STK::IContainer2D< SizeRows_, SizeCols_ >::rows().

Referenced by STK::IArray2D< Derived >::merge(), and STK::IArray2D< Derived >::merge().

◆ rowsImpl()

template<class Derived >
RowRange const & STK::IArray2D< Derived >::rowsImpl ( ) const
inline
Returns
the Vertical range

Definition at line 173 of file STK_IArray2D.h.

173{ return Base2D::rows();}

References STK::IContainer2D< SizeRows_, SizeCols_ >::rows().

◆ setCols()

template<class Derived >
void STK::IContainer2D< SizeRows_, SizeCols_ >::setCols ( ColRange const J = ColRange())
inline

Set the columns range.

Parameters
Jthe columns range

Definition at line 143 of file STK_IContainer2D.h.

143{ cols_ = J;}

◆ setRows()

template<class Derived >
void STK::IContainer2D< SizeRows_, SizeCols_ >::setRows ( RowRange const I = RowRange())
inline

Set the range of the number of rows.

Parameters
Ithe range of the rows number

Definition at line 114 of file STK_IContainer2D.h.

114{ rows_ = I;}

Referenced by STK::IArray2D< Derived >::merge(), and STK::IArray2D< Derived >::merge().

◆ setValueImpl() [1/2]

template<class Derived >
void STK::IArray2D< Derived >::setValueImpl ( int  i,
int  j,
TypeConst  v 
)
inline

implement setValue for vector/point/diagonal arrays

Definition at line 229 of file STK_IArray2D.h.

229{ allocator_.elt(j)->setValue(i, v);}

References STK::IArray2D< Derived >::allocator_, and STK::MemAllocator< Type_, Size_ >::elt().

◆ setValueImpl() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::setValueImpl ( int  j,
TypeConst  v 
)
inline

implement setValue for vector/point/diagonal arrays

Definition at line 223 of file STK_IArray2D.h.

224 {
226 this->asDerived().setValue1D(j, v);
227 }

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ shift() [1/2]

template<class Derived >
void STK::IArray2D< Derived >::shift ( int  beg)

New first index for the object (only for vectors/points/square/... arrays)

Parameters
begthe index of the first element to set

Definition at line 116 of file STK_IArray2DModifiers.h.

117{ this->asDerived().shift1D(beg);}

◆ shift() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::shift ( int  rbeg,
int  cbeg 
)

Set new beginning indexes to the array.

Parameters
rbeg,cbegthe indexes of the first row and first column to set

Definition at line 107 of file STK_IArray2DModifiers.h.

108{
109 shiftCols(cbeg);
110 shiftRows(rbeg);
111}
void shiftCols(int cbeg)
New first index for the columns of the object.
void shiftRows(int beg)
New first index for the rows of the array.

Referenced by STK::SArray2DVector< Type_ >::shift1D().

◆ shiftCols()

template<class Derived >
void STK::IArray2D< Derived >::shiftCols ( int  cbeg)

New first index for the columns of the object.

Parameters
cbegthe index of the first column to set

Definition at line 140 of file STK_IArray2DModifiers.h.

141{
142 // if there is something to do
143 if (cbeg == this->beginCols()) return;
144 // is this structure just a pointer?
145 if (isRef())
146 { STKRUNTIME_ERROR_1ARG(IArray2D::shiftCols,cbeg,cannot operate on references);}
147 // shift beginCols()
148 allocator_.shift(cbeg); // translate data
149 rangeCols_.shift(cbeg); // translate rangeCols_
150 Base2D::shiftCols(cbeg); // adjust dimensions
151}
void shiftCols(int beg)
Shift the columns first index to beg.

References STK::IArray2D< Derived >::shiftCols(), and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IArray2D< Derived >::shiftCols().

◆ shiftRowCol()

template<class Derived >
void STK::IArray2D< Derived >::shiftRowCol ( int  col,
int  beg 
)
private

internal method for translating a column.

Method for the the allocation of memory of the column pos with the given range.

Parameters
col,begindex of the column and new begin of the column

Definition at line 159 of file STK_IArray2DModifiers.h.

160{
161 if (allocator_.elt(col)) { allocator_.elt(col)->shift(beg);}
162 rangeCols_[col].shift(beg);
163}

◆ shiftRows()

template<class Derived >
void STK::IArray2D< Derived >::shiftRows ( int  beg)

New first index for the rows of the array.

Parameters
begthe index of the first row to set

Definition at line 122 of file STK_IArray2DModifiers.h.

123{
124 // compute increment
125 int inc = beg - beginRows();
126 if (inc == 0) return;
127 // is this structure just a pointer?
128 if (isRef()) { STKRUNTIME_ERROR_1ARG(IArray2D::shiftRows,beg,cannot operate on reference);}
129
130 // translate rows
132 // if there is rows, for all cols shift
133 for (int j=beginCols(); j<endCols(); j++)
134 { shiftRowCol(j, rangeCols_[j].begin()+inc);}
135}
void shiftRows(int beg)
Set the first index of the rows.

References STK::IArray2D< Derived >::shiftRows(), and STKRUNTIME_ERROR_1ARG.

Referenced by STK::IArray2D< Derived >::shiftRows().

◆ sizeCols()

template<class Derived >
int STK::IArray2D< Derived >::sizeCols ( ) const
inline

◆ sizeRows()

template<class Derived >
int STK::IArray2D< Derived >::sizeRows ( ) const
inline
Returns
the number of rows

Definition at line 184 of file STK_IArray2D.h.

184{ return Base2D::sizeRows();}

References STK::IContainer2D< SizeRows_, SizeCols_ >::sizeRows().

Referenced by STK::MultidimRegression< Array, Weight >::computeNbFreeParameter().

◆ sub() [1/2]

template<class Derived >
hidden::Traits< Derived >::SubArray STK::IArray2D< Derived >::sub ( Range const I,
Range const J 
) const
inline

access to a sub-array.

Parameters
I,Jrange of the rows and of the columns

Definition at line 112 of file STK_IArray2DSlicers.h.

113{ return SubArray(this->asDerived(), I, J);}

◆ sub() [2/2]

template<class Derived >
hidden::Traits< Derived >::SubVector STK::IArray2D< Derived >::sub ( Range const J) const
inline
Returns
many elements.
Parameters
JRange of the elements

Definition at line 106 of file STK_IArray2DSlicers.h.

107{ return SubVector(this->asDerived(), J);}
hidden::Traits< Derived >::SubVector SubVector

Referenced by main().

◆ swap()

template<class Derived >
void STK::IArray2D< Derived >::swap ( int  i,
int  j 
)
inline

swap two elements: only for vectors and points

Parameters
i,jindexes of the elemet to swap

Definition at line 532 of file STK_IArray2D.h.

533 {
535 std::swap(elt(i), elt(j));
536 }

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

Referenced by STK::Svd< Array >::diag(), and STK::LocalVariance< Array >::prim().

◆ swapCols()

template<class Derived >
void STK::IArray2D< Derived >::swapCols ( int  pos1,
int  pos2 
)
inline

Swapping two columns.

Parameters
pos1,pos2positions of the columns to swap

Definition at line 514 of file STK_IArray2D.h.

515 {
516 #ifdef STK_BOUNDS_CHECK
517 if (this->beginCols() > pos1)
519 if (this->endCols() <= pos1)
520 { STKOUT_OF_RANGE_2ARG(IArray2D::swapCols,pos1, pos2,endCols() <= pos1);}
521 if (this->beginCols() > pos2)
523 if (this->endCols() <= pos2)
524 { STKOUT_OF_RANGE_2ARG(IArray2D::swapCols,pos1, pos2,endCols() <=pos2);}
525 #endif
526 allocator_.swap(pos1, pos2);
527 rangeCols_.swap(pos1,pos2);
528 }
void swapCols(int pos1, int pos2)
Swapping two columns.
void swap(int pos1, int pos2)
swap two elements of the Allocator.

References STK::IArray2D< Derived >::allocator_, STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::endCols(), STK::IArray2D< Derived >::rangeCols_, STKOUT_OF_RANGE_2ARG, STK::MemAllocator< Type_, Size_ >::swap(), and STK::IArray2D< Derived >::swapCols().

Referenced by STK::Svd< Array >::diag(), and STK::IArray2D< Derived >::swapCols().

◆ transferCol() [1/2]

template<class Derived >
template<class OtherDerived >
void STK::IArray2D< Derived >::transferCol ( IArray2D< OtherDerived > &  T,
int  pos 
)
inlineprivate

Internal method transferring column pos of container T to column pos of this.

Set the column pos in T to zero. The column pos in this should not exists or should be deleted previously otherwise user will experiment a memory leak.

Parameters
Tthe container with the column to transfer
posindex of the column to transfer

Definition at line 720 of file STK_IArray2D.h.

721 {
722 allocator_.elt(pos) = T.allocator_.elt(pos);
723 rangeCols_[pos] = T.rangeCols_[pos];
724 T.nullCol(pos);
725 }

References STK::IArray2D< Derived >::allocator_, STK::MemAllocator< Type_, Size_ >::elt(), and STK::IArray2D< Derived >::rangeCols_.

◆ transferCol() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::transferCol ( int  pos1,
int  pos2 
)
inlineprotected

Transfer the column pos2 to the column pos1 of this.

Parameters
pos1,pos2indexes of the columns

Definition at line 654 of file STK_IArray2D.h.

655 {
656 // copy by address pointer on column pos2 of T in pos1 of this
657 allocator_.elt(pos1) = allocator_.elt(pos2);
658 rangeCols_[pos1] = rangeCols_[pos2];
659 }

References STK::IArray2D< Derived >::allocator_, STK::MemAllocator< Type_, Size_ >::elt(), and STK::IArray2D< Derived >::rangeCols_.

Referenced by STK::IArray2D< Derived >::merge().

◆ update() [1/2]

template<class Derived >
void STK::IArray2D< Derived >::update ( int  col)
inline

Update column of the array at specified position.

Parameters
colindex of the column to update

Definition at line 630 of file STK_IArray2D.h.

631 {
632 #ifdef STK_BOUNDS_CHECK
633 if (beginCols() > col)
635 if (this->lastIdxCols() < col)
637 #endif
638 if (this->rangeRowsInCol(col) != rangeCols_[col])
639 { resizeRowCol(col, this->rangeRowsInCol(col));}
640 }
void resizeRowCol(int col, Range const &I)
Internal method for resizing a column with a specified range.
void update(Range const &J)
Update columns of the array at a specified range.

References STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::col(), STK::IArray2D< Derived >::lastIdxCols(), STK::IArray2D< Derived >::rangeCols_, STK::IArray2D< Derived >::resizeRowCol(), STKOUT_OF_RANGE_1ARG, and STK::IArray2D< Derived >::update().

◆ update() [2/2]

template<class Derived >
void STK::IArray2D< Derived >::update ( Range const J)
inline

Update columns of the array at a specified range.

Parameters
Jrange of the columns to update

Definition at line 616 of file STK_IArray2D.h.

617 {
618 #ifdef STK_BOUNDS_CHECK
619 if (beginCols() > J.begin())
621 if (endCols() < J.end())
623 #endif
624 for ( int icol = J.begin(); icol < J.end() ; ++icol)
625 { update(icol);}
626 }

References STK::IArray2D< Derived >::beginCols(), STK::IArray2D< Derived >::endCols(), STKOUT_OF_RANGE_1ARG, and STK::IArray2D< Derived >::update().

Referenced by STK::IArray2D< Derived >::update(), and STK::IArray2D< Derived >::update().

Friends And Related Symbol Documentation

◆ IArray2D

template<class Derived >
template<class OtherDerived >
friend class IArray2D
friend

Definition at line 81 of file STK_IArray2D.h.

Member Data Documentation

◆ allocator_

◆ rangeCols_


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