76template <
class Derived>
77class IArray2D:
protected IContainer2D<hidden::Traits<Derived>::sizeRows_, hidden::Traits<Derived>::sizeCols_>
81 template <
class OtherDerived>
friend class IArray2D;
146 template<
class OtherDerived>
163 Derived&
move(Derived
const& T);
226 this->asDerived().setValue1D(
j,
v);
248#ifdef STK_BOUNDS_CHECK
261#ifdef STK_BOUNDS_CHECK
275#ifdef STK_BOUNDS_CHECK
287#ifdef STK_BOUNDS_CHECK
444 template<
class Other>
451 template<
class Other>
483 template<
class Other>
488 template<
class Other>
508 void erase(
int pos,
int n=1);
516 #ifdef STK_BOUNDS_CHECK
535 std::swap(elt(
i), elt(
j));
547 template<
class OtherDerived>
557 if (this->
rows() != other.rows())
572 Tref.shiftCols(first);
577 Tref.allocator().free();
586 template<
class OtherDerived>
596 if (this->
rows() != other.range())
618 #ifdef STK_BOUNDS_CHECK
632 #ifdef STK_BOUNDS_CHECK
719 template<
class OtherDerived>
785template <
class Derived >
793template <
class Derived >
803template <
class Derived >
806 , allocator_(T.allocator_, ref)
807 , rangeCols_(T.rangeCols_,
false)
820template <
class Derived >
821template<
class OtherDerived>
824 , allocator_(T.allocator_,
J,
true)
825 , rangeCols_(T.rangeCols_,
J,
false)
829 for (
int j=
J.begin();
j<
J.end();
j++)
836template <
class Derived >
843template <
class Derived >
855template <
class Derived >
858 if (this->asPtrDerived() == &T)
return this->asDerived();
859 if (!isRef()) { freeCols(cols());}
861 allocator_.move(T.allocator_);
862 rangeCols_.move(T.rangeCols_);
866 return this->asDerived();
871template <
class Derived >
886template<
class Derived>
894 setCols(allocator_.range());
896 rangeCols_.resize(cols());
904template<
class Derived>
910 if (
J.size() > availableCols())
914 allocator_.malloc(
Range(
J.begin(), size));
917 { allocator_.shift(
J.begin());}
918 rangeCols_.resize(
J);
925 allocator_.setValue(0);
928 allocator_.setValue(0);
934template<
class Derived>
937#ifdef STK_BOUNDS_CHECK
938if (beginCols() >
J.begin())
940if (endCols() <
J.end())
943 for (
int j=
J.begin();
j<
J.end();
j++)
946 { initializeCol(
j, this->rangeRowsInCol(
j));}
950 for (
int k=
J.begin(); k<
j; k++) freeCol(k);
958template<
class Derived>
960{
for (
int j=
J.begin();
j<
J.end();
j++) { freeCol(
j);}}
965template<
class Derived>
978template<
class Derived>
983 if (
J.size() > availableCols())
989 rangeCols_.resize(
J);
997template<
class Derived>
1000#ifdef STK_BOUNDS_CHECK
1001 if (beginCols() >
J.begin())
1003 if (endCols() <
J.end())
1006 for (
int j=
J.begin();
j<
J.end(); ++
j) { nullCol(
j);}
1012template<
class Derived>
1015 allocator_.elt(col) = 0;
1016 rangeCols_[col] =
Range();
1023template<
class Derived>
1026#ifdef STK_DEBUG_ARRAY2D
1028 stk_cout <<
_T(
"Initialize col=") << col <<
_T(
", I=") <<
I <<
_T(
"\n");
1032 allocator_.elt(col) = 0;
1033 rangeCols_[col] =
I;
1039 catch (std::bad_alloc &
error)
1041 allocator_.elt(col) = 0;
1042 rangeCols_[col] =
Range();
1045 rangeCols_[col] =
I;
1050template<
class Derived>
1053#ifdef STK_DEBUG_ARRAY2D
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");
1058 if (allocator_.elt(col))
1060 delete allocator_.elt(col);
1061 allocator_.elt(col) =0;
1062 rangeCols_[col] =
Range();
In this file we define and implement the final class Array1D.
In this file we define the base class for Arrays.
In this file we define the IContainer2D interface classes.
#define STKOUT_OF_RANGE_1ARG(Where, Arg, Error)
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
#define STKRUNTIME_ERROR_2ARG(Where, Arg1, Arg2, Error)
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
base class for template arrays.
Sdk class for all library Exceptions.
template one dimensional Array.
template interface base class for two-dimensional arrays.
IArray2D(Range const &I, Range const &J)
constructor with specified ranges
void shiftRowCol(int col, int beg)
internal method for translating a column.
ColRange const & colsImpl() const
Array1D< Range, sizeCols_ > rangeCols_
range of the index of the columns of the container.
void mallocCols(ColRange const &J)
Internal method for memory allocation 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 column...
TypeConst operator()(int i, int j) const
void reserveRowsCols(Range const &J, int size)
Internal method for reserving memory in a range of columns.
void reallocCols(Range const &J)
Method for memory reallocation and initialization of the horizontal range of the container.
void setRows(RowRange const &I=RowRange())
Set the range of the number of rows.
hidden::Traits< Derived >::SubCol SubCol
RowRange const & rowsImpl() const
Type & elt2Impl(int i, int j)
access to an element.
TypeConst operator[](int i) const
void insertRowsCol(int col, int pos, int n)
Internal method for inserting rows to a specified column.
int capacityCol(int col) const
void swap(int i, int j)
swap two elements: only for vectors and points
void exchange(IArray2D &T)
exchange this container with T.
void initializeCol(int col, Range const &I)
Internal method for initializing a column.
void reserveRows(int size)
Reserve a certain amount of rows in all columns.
SubVector sub(Range const &J) const
void erase(int pos, int n=1)
STL compatibility:Delete n elements at the pos index from the container.
RowRange const & rows() const
SubCol atCol(int j) const
void nullCol(int col)
Internal method setting default parameters and dimension to a column of the container.
void pushFrontCols(int n=1)
Insert n columns at the beginning of the array.
hidden::Traits< Derived >::Col Col
void transferCol(int pos1, int pos2)
Transfer the column pos2 to the column pos1 of this.
TypeConst operator()() const
IArray2D(IArray2D< OtherDerived > const &T, Range const &I, Range const &J)
constructor by reference, ref_=1.
Allocator allocator_
allocator of the column data set
void insertCols(int pos, int n=1)
Insert n columns at the index pos to the array.
IContainer2D< sizeRows_, sizeCols_ > Base2D
Type for the IContainer2D base Class.
hidden::Traits< Derived >::Row Row
void setValueImpl(int j, TypeConst v)
implement setValue for vector/point/diagonal arrays
Derived & resize(Range const &I, Range const &J)
resize the array.
hidden::Traits< Derived >::ColVector ColVector
void pushBackCols(int n=1)
Add n columns at the end of the array.
void merge(IArray2D< OtherDerived > const &other)
Append the container other to this without copying the data explicitly.
Derived & move(Derived const &T)
move T to this.
void resizeRowCol(int col, Range const &I)
Internal method for resizing a column with a specified range.
void swapCols(int pos1, int pos2)
Swapping two columns.
void reserve(int sizeRows, int sizeCols)
function for reserving memory in all the columns
void transferCol(IArray2D< OtherDerived > &T, int pos)
Internal method transferring column pos of container T to column pos of this.
hidden::Traits< Derived >::TypeConst TypeConst
void initializeCols(Range const &J)
Internal method for memory allocation and initialization of a range of columns.
void popBackCols(int n=1)
Delete last columns of the array.
ColVector const * PtrColConst
void insert(Range const &I, Type const &v)
STL compatibility: insert element v in the range I of the Array.
hidden::Traits< Derived >::SubVector SubVector
Allocator const & allocator() const
void popFrontCols(int n=1)
Delete first columns of the array.
int availableCols() const
void update(Range const &J)
Update columns of the array at a specified range.
void freeCol(int col)
Internal method for memory deallocation.
IArray2D()
Default constructor.
void pushBackRows(int n=1)
Add n rows to the array.
void reserveRowCol(int col, int size)
Internal method for reserving rows to a specified column.
void push_back(Type const &v)
STL compatibility: append an element v.
Col col(int j) const
access to a part of a column.
void merge(IArray1D< OtherDerived > const &other)
Append the vector other to this without copying the data explicitly.
Type & operator()(int i, int j)
void shiftCols(int cbeg)
New first index for the columns of the object.
void clear()
clear the object.
ColRange const & cols() const
Row row(int i) const
access to a part of a row.
void eraseRows(int pos, int n=1)
Delete n rows at the position pos.
void popBackRows(int n=1)
Delete n latest rows of the array.
void freeMem()
Internal method for memory deallocation.
PtrColConst ptr(int j) const
void pushFrontRows(int n=1)
Insert n rows in front of the array.
hidden::Traits< Derived >::SubRow SubRow
Range const & rangeCol(int col) const
TRange< sizeCols_ > ColRange
Type of the Range for the columns.
Array1D< Range, sizeCols_ > const & rangeCols() const
void reserveCols(int sizeCols)
Reserve a certain amount of columns.
void shift(int rbeg, int cbeg)
Set new beginning indexes to the array.
MemAllocator< PtrCol, sizeCols_ > Allocator
Type for the Base Class.
void shiftRows(int beg)
New first index for the rows of the array.
void eraseRowsCol(int col, int pos, int n)
Internal method for deleting rows from a specified column.
void push_front(Type const &v)
STL compatibility: push front an element.
void popFrontRows(int n=1)
Delete n first rows of the array.
void setValueImpl(int i, int j, TypeConst v)
implement setValue for vector/point/diagonal arrays
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,...
ArrayBase< Derived > Base
type of the Base Container Class.
hidden::Traits< Derived >::Type Type
void copyCol(IArray2D const &src, int j)
copy column j of src into column j of this
IArray2D(IArray2D const &T, bool ref=false)
Copy constructor If we want to wrap T, the main ptr will be wrapped in MemAllocator class.
void update(int col)
Update column of the array at specified position.
void freeCols(Range const &J)
Internal method for releasing memory in a given range of columns.
TRange< sizeRows_ > RowRange
Type of the Range for the rows.
void eraseCols(int pos, int n=1)
Delete n columns at the specified position of the array.
hidden::Traits< Derived >::SubArray SubArray
TypeConst elt2Impl(int i, int j) const
constant access to an element.
Interface base class for 2D containers.
void setRows(RowRange const &I=RowRange())
Set the range of the number of rows.
RowRange const & rows() const
ColRange const & cols() const
void setCols(ColRange const &J=ColRange())
Set the columns range.
String const & error() const
get the last error message.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
int end() const
get the ending index of the TRange.
int lastIdx() const
get the last index of the TRange.
int evalSizeCapacity(int m)
Range inf(TRange< SizeI_ > const &I, TRange< SizeJ_ > const &J)
compute inf(I,J).
The namespace STK is the main domain space of the Statistical ToolKit project.
TRange< UnknownSize > Range
Type *const & p_data() const
Get constant pointer on data.
void swap(int pos1, int pos2)
swap two elements of the Allocator.
TypeConst elt(int pos) const
Get the const element number pos.