146 template<
class T,
int N>
176 template<
class OtherT>
181 return stride ==
sizeof(T)*N;
187 template<
class OtherT>
193 for(
int i=0;i<dim;++i){
194 for(
int j=0;j<N;++j){
195 if(fabs((
float)(
operator[](i)[j] - dst[i][j])) > tollerance)
return false;
212 for(
int i=0;i<dim;++i){
213 for(
int j=0;j<N;++j){
223 inline void fill(Fill vecValue){
225 for(
int i=0;i<dim;++i){
248 template<
class T,
class OtherT,
int N>
249 struct DataSegmentDeepCopyUtil{
250 static void copy(
const DataSegment<T,N> &src, DataSegment<OtherT,N> &dst){
251 const int dim = src.getDim();
252 const bool sp = src.isPacked(), dp = dst.isPacked();
254 const T *s = (
const T*)src.begin();
255 T *d = (T*)dst.begin();
256 std::transform(s,s+dim*N,d,icl::utils::clipped_cast<T,OtherT>);
258 const math::FixedColVector<T,N> *srcpacked = &src[0];
259 for(
int i=0;i<dim;++i){
260 dst[i] = srcpacked[i];
263 math::FixedColVector<OtherT,N> *dstpacked = &dst[0];
264 for(
int i=0;i<dim;++i){
265 dstpacked[i] = src[i];
268 for(
int i=0;i<dim;++i){
275 template<
class T,
int N>
276 struct DataSegmentDeepCopyUtil<T,T,N>{
277 static void copy(
const DataSegment<T,N> &src, DataSegment<T,N> &dst){
278 const int dim = src.getDim();
279 const bool sp = src.isPacked(), dp = dst.isPacked();
281 memcpy(dst.getDataPointer(),src.getDataPointer(),dim*
sizeof(T)*N);
283 const math::FixedColVector<T,N> *srcpacked = &src[0];
284 for(
int i=0;i<dim;++i){
285 dst[i] = srcpacked[i];
288 math::FixedColVector<T,N> *dstpacked = &dst[0];
289 for(
int i=0;i<dim;++i){
290 dstpacked[i] = src[i];
293 for(
int i=0;i<dim;++i){
300 template<
class T,
int N>
template<
class OtherT>
303 utils::ICLException(
"error in DataSegment::deepCopy " 304 "(source and destination dim differ)"));
327 return *reinterpret_cast<T*>(
data +idx*
stride);
346 template<
class OtherT>
350 "(source and destination dim differ)"));
352 for(
int i=0;i<dim;++i){
356 template<
class OtherT>
362 for(
int i=0;i<dim;++i){
363 if(fabs((
float)(
operator[](i) - dst[i])) > tollerance)
return false;
373 for(
int i=0;i<dim;++i){
380 inline void fill(Fill vecValue){
382 for(
int i=0;i<dim;++i){
389 template<
class T,
int N>
393 return (DataSegment<T,N> &)(*this);
static DataSegment< T, N > fromVector(std::vector< T > &v)
wrapps a data-segment around an std::vector
Definition: DataSegment.h:233
const math::FixedColVector< T, N > & operator[](int idx) const
linear index operator (const)
Definition: DataSegment.h:161
void fillScalar(Fill scalarValue)
fills each scalar value of each entry with given value
Definition: DataSegment.h:210
T & operator[](int idx)
linear index operator (specialized to return a T& directly)
Definition: DataSegment.h:326
undocument this line if you encounter any issues!
Definition: Any.h:37
DataSegment(T *data=0, size_t stride=0, size_t numElements=0, icl32s organizedWidth=-1)
Constructor (basically passes all parameters to the Base class)
Definition: DataSegment.h:152
bool equals(DataSegment< OtherT, N > dst, float tollerance=1.0e-5) const
compares two data segments element wise given given maximun tollerance
Definition: DataSegment.h:188
icl32s organizedWidth
if > 0 , the data is 2D-organized
Definition: DataSegmentBase.h:126
T VectorType
vector typedef
Definition: DataSegment.h:319
core::depth dataDepth
underlying data depth
Definition: DataSegmentBase.h:129
size_t numElements
number of vector elements contained
Definition: DataSegmentBase.h:123
bool equals(DataSegment< OtherT, 1 > dst, float tollerance=1.0e-5) const
Definition: DataSegment.h:357
static const DataSegment< T, N > fromVector(const std::vector< T > &v)
wrapps a data-segment around an std::vector (const version)
Definition: DataSegment.h:240
Abstract data segment class.
Definition: DataSegmentBase.h:99
core::depth getDepth() const
returns the actual core::depth (data type) of the entries
Definition: DataSegmentBase.h:158
math::FixedColVector< T, N > & operator[](int idx)
linear index operator
Definition: DataSegment.h:156
const DataSegment< T, N > & as() const
shallow and save cast from data segment base to special data segment version
Ipp32s icl32s
32bit signed integer type for the ICL
Definition: BasicTypes.h:58
math::FixedColVector< T, N > & operator()(int x, int y)
2D-index operator (only for organized data segments)
Definition: DataSegment.h:166
void fill(Fill vecValue)
fills each vector entry with given value
Definition: DataSegment.h:223
void fill(Fill vecValue)
fills each vector entry with given value
Definition: DataSegment.h:380
bool isPacked() const
returns whether the data is packed in memory (stride is sizeof(T)*N)
Definition: DataSegment.h:180
size_t stride
stride between elements
Definition: DataSegmentBase.h:120
void deepCopy(DataSegment< OtherT, 1 > dst) const
copies the data segment to into another element-wise
Definition: DataSegment.h:347
T & operator()(int x, int y)
2D-index operator (only for organized data segments, specialized to return a T& directly)
Definition: DataSegment.h:336
void deepCopy(DataSegment< OtherT, N > dst) const
copies the data segment to into another element-wise
utils::Size getSize() const
returns the ordred size of the segment of utils::Size::null if it's not organized
Definition: DataSegmentBase.h:141
template specialization for data-segments, where each entry is just 1D
Definition: DataSegment.h:317
DataSegment(T *data=0, size_t stride=0, size_t numElements=0, icl32s organizedWidth=-1)
Constructor (basically passes all parameters to the Base class)
Definition: DataSegment.h:322
Definition: FixedVector.h:40
Base class for Exception handling in the ICL.
Definition: Exception.h:42
size_t elemDim
vector element dim
Definition: DataSegmentBase.h:132
void fillScalar(Fill scalarValue)
fills each scalar value of each entry with given value
Definition: DataSegment.h:371
const T & operator[](int idx) const
linear index operator (specialized to return a T& directly, const)
Definition: DataSegment.h:331
bool isOrganized() const
returns, whether the segment is 2D-organized
Definition: DataSegmentBase.h:136
math::FixedColVector< T, N > VectorType
vector typedef
Definition: DataSegment.h:149
const T & operator()(int x, int y) const
2D-index operator (only for organized data segments, specialized to return a T& directly,...
Definition: DataSegment.h:341
void copy(const T *src, const T *srcEnd, T *dst)
moves data from source to destination array (no casting possible)
Definition: CoreFunctions.h:216
icl8u * data
data pointer orign
Definition: DataSegmentBase.h:111
The DataSegment class defines a strided data segment (or 1D or 2D ordred array of vectors)
Definition: DataSegment.h:147
const math::FixedColVector< T, N > & operator()(int x, int y) const
2D-index operator (only for organized data segments, const)
Definition: DataSegment.h:171
#define ICLASSERT_THROW(X, OBJ)
Definition: Macros.h:155
int getDim() const
returns the number of elements
Definition: DataSegmentBase.h:153