1#ifndef __FIBER_DIRECTPRODUCT_HPP
2#define __FIBER_DIRECTPRODUCT_HPP
4#ifndef DONT_USE_PRAGMA_ONCE
9#include "CoordinateAxisArray.hpp"
47template <
class T,
class Category,
int MDIMS>
57#ifdef HAVE_OLD_MEMARRAY
102 for(
int i=0; i<
Dims; i++)
121 for(
int i=0; i<
Dims; i++)
128 : MemArrayBase<MDIMS>(FiberType<T>::getFiberType()->getFiberTypeIndex(), theCreator)
132 if (Src.Components[i] )
133 Components[i] =
new CoordinateAxisArray_t( *Src.Components[i] );
148#ifdef HAVE_OLD_MEMARRAY
150 RefPtr<MemBase> newMemArray()
const
152 return new MemArray<MDIMS, T>( this->
Size() );
156 bool copyFrom(
const RefPtr<MemCore::ChunkBase>&theChunk)
override
196 for(
int i=0; i<
Dims; i++)
205 retval[ component ] = (*that)(
I[i] );
224 for(
int i=0; i<
Dims; i++)
243 bool locate(T&pos) const
245 for(
int i=0; i<
Dims; i++)
253 const RefPtr<CoordinateAxisArray_t>&that =
Components[ component ];
258 if (!that->locate( pos[ component ] ) )
272 for(
int i=0; i<
Dims; i++)
281 Sz[i] = that->Length();
291 for(
int i=0; i<
Dims; i++)
304 for(
int i=0; i<
Dims; i++)
323 const type_info&getType() const override
329 const FiberTypeBase&getFiberType() const override
331 return FiberType<T>::getFiberType();
365template <
class T,
class Category = LinearCoordinateAxisArray,
int MDIMS = T::SIZE>
401 template <
class TBase>
413 DirectProductMemArray(
const DirectProductMemArray&DPM,
const MemBase::Creator_t&C =
MemCore::NullPtr() )
414 : MemBase(FiberType<T>::getFiberType()->getFiberTypeIndex(), C)
415 , DirectProductMemArrayBase_t(DPM, C)
419 T operator[](
const MultiIndex<Dims>&I)
const
426 T getElement(
const index_t i)
const
428 const MultiIndex<Dims> I(i, this->
Size(), CreateFromLinear{} );
432 std::string getElementAsString(
size_t index)
const override
434 const MultiIndex<Dims> I(index, this->
Size(), CreateFromLinear{} );
435 if (I.isWithin( this->Size() ))
455 typename MemArray_t::MultiArray_t&dst = *M;
472 while( idx.inc(
Sz ) );
482 RefPtr<MemBase> createSubMemArray(
const MultiIndex<Dims>&,
const MultiIndex<Dims>&,
const MemBase::Creator_t&C)
const override
519 const void*
OriginPtr()
const override {
return nullptr; }
520 const void*
DeltaPtr()
const override {
return nullptr; }
550template <
class T,
class DeltaT = T,
int MDIMS = T::SIZE>
564 enum { COMPONENTS = T::SIZE };
576 const void*
OriginPtr()
const override {
return &Origin(); }
577 const void*
DeltaPtr()
const override {
return &Delta(); }
579 const T&Origin()
const {
return baseValue; }
580 const DeltaT&Delta()
const {
return deltaValue; }
598 for(
int c=0; c<COMPONENTS; c++)
617 for(
int c=0; c<COMPONENTS; c++)
632 bool resize(
int component, index_t newSize)
636 LA->resize( newSize );
655 for(
unsigned i = 0; i <
MDIMS; ++i )
657 if ( (pos[i] - baseValue[i]) / deltaValue[i] >= 0)
659 index[i] = size_t(
floor( ( pos[i] - baseValue[i] ) / deltaValue[i] ) );
663 Verbose( 51 ) <<
"LinearDirectProductMemArray::getFlooredMultiIndex() Fragment Index " << i <<
" negative";
664 Verbose( 51 ) <<
"'crds: " << pos <<
", origin: " << baseValue <<
", delta: " << deltaValue;
669 int component = this->ComponentMap[ i ];
670 if( index[i] >= this->Components[ component ]->Length() )
672 Verbose( 51 ) <<
"LinearDirectProductMemArray::getFlooredMultiIndex() Fragment Index " << i <<
" too large: " << index[i] <<
">=" << this->ComponentMap[i];
673 Verbose( 51 ) <<
"'crds: " << pos <<
", origin: " << baseValue <<
", delta: " << deltaValue;
687 for(
unsigned i = 0; i <
MDIMS; ++i )
689 if ( (pos[i] - baseValue[i]) / deltaValue[i] >= 0)
691 index[i] = size_t(
round( ( pos[i] - baseValue[i] ) / deltaValue[i] ) );
695 Verbose(51) <<
"LinearDirectProductMemArray::getNearestMultiIndex() Fragment Index " << i <<
" negative";
696 Verbose(51) <<
"'crds: " << pos <<
", origin: " << baseValue <<
", delta: " << deltaValue;
700 int component = this->ComponentMap[ i ];
701 if( index[i] >= this->Components[ component ]->Length() )
703 Verbose(51) <<
"LinearDirectProductMemArray::getNearestMultiIndex() Fragment Index " << i <<
" too large: " << index[i] <<
">=" << this->ComponentMap[i];
704 Verbose(51) <<
"'crds: " << pos <<
", origin: " << baseValue <<
", delta: " << deltaValue;
constexpr __enable_if_is_duration< _ToDur > floor(const duration< _Rep, _Period > &__d)
constexpr enable_if_t< __and_< __is_duration< _ToDur >, __not_< treat_as_floating_point< typename _ToDur::rep > > >::value, _ToDur > round(const duration< _Rep, _Period > &__d)
void resize(size_t __size, _Tp __c=_Tp())
valarray< size_t > size() const
basic_string< char > string
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Class for creating structured types as direct product of one-dimensional arrays.
Definition DirectProductArray.hpp:49
RefPtr< CoordinateAxisArray_t > Components[COMPONENTS]
The respective components of the array.
Definition DirectProductArray.hpp:79
@ Dims
The dimensionality of the base manifold.
Definition DirectProductArray.hpp:75
@ COMPONENTS
The number of components of the value type.
Definition DirectProductArray.hpp:73
Eagle::Vector< int, Dims > ComponentMap
Mapping from manifold dimension to component array.
Definition DirectProductArray.hpp:86
MultiIndex< Dims > firstIndex() const
Return a multidimensional index for the 1st data element, which is just all components to be zero.
Definition DirectProductArray.hpp:288
FloatIndex_t getIndex(const T &PointCoordinates) const
Given the coordinates of a point, yield the index where it resides in the array.
Definition DirectProductArray.hpp:221
T::value_type component_type
The components of the structured type T.
Definition DirectProductArray.hpp:66
void * getPtr() override
Implementation of the virtual MemArray function.
Definition DirectProductArray.hpp:342
RefPtr< MemArray< MDIMS, T > > createMemArray(const RefPtr< MemCore::ChunkBase > &Data, const MemBase::Creator_t &C) const
Create a memory array of the same dimensions as the current array, but with data as provided by the S...
Definition DirectProductArray.hpp:166
RefPtr< MemBase > createEquallySizedMemArray(const RefPtr< MemCore::ChunkBase > &Storage, const MemBase::Creator_t &C) const override
Create a memory array of the same dimensions as the current array, but with data as provided by the S...
Definition DirectProductArray.hpp:181
MultiIndex< Dims > Size() const override
Return the multidimensional number of points covered by this array.
Definition DirectProductArray.hpp:269
void retrieve(T &retval, const MultiIndex< Dims > &I) const
Evaluate an index, deliver the coordinate value.
Definition DirectProductArray.hpp:194
void DeferredConstructor() override
Virtual deferred reference pointer construction pointer Don't overload if you don't know exactly what...
Definition DirectProductArray.hpp:138
DirectProductMemArrayBase(const MemBase::Creator_t &C=MemCore::NullPtr())
The constructor sets the component map such that the dimensions of the manifold are mapped to the fir...
Definition DirectProductArray.hpp:98
FixedArray< double, MDIMS > FloatIndex_t
A multidimensional floating-point index.
Definition DirectProductArray.hpp:91
RefPtr< MemBase > getSlice(index_t i, const MemBase::Creator_t &C) const override
For a multidimensional array retrieve the nth slice.
Definition DirectProductArray.hpp:336
MultiIndex< Dims > lastIndex() const
Return a multidimensional index for the last data element, which is just the largest index in each di...
Definition DirectProductArray.hpp:300
Definition DirectProductArray.hpp:367
T value_type
The type of values that are delivered here.
Definition DirectProductArray.hpp:376
T::value_type component_type
The type of the elements of each component.
Definition DirectProductArray.hpp:379
const void * OriginPtr() const override
Get pointer to origin of linearly procedural array, if it is linear.
Definition DirectProductArray.hpp:519
DirectProductMemArray(const DirectProductMemArrayCreateBaseArray &, const DirectProductMemArray< TBase, Category > &D, const MemBase::Creator_t &C=MemCore::NullPtr())
The base value which is used as default for each component when the ComponentMap does not specify a m...
Definition DirectProductArray.hpp:402
CreativeIterator< T > * creativeIterator() override
Procedural arrays return 0 here.
Definition DirectProductArray.hpp:502
const void * DeltaPtr() const override
Get pointer to delta of linearly procedural array, if it is linear.
Definition DirectProductArray.hpp:520
MultiIndex< Dims > Size() const override
Return the multidimensional number of points covered by this array.
Definition DirectProductArray.hpp:269
T last() const override
Get the data value at the lastIndex()
Definition DirectProductArray.hpp:530
const type_info & getType() const override
Return the element type of the certain array.
Definition DirectProductArray.hpp:496
RefPtr< MemCore::TypedChunk< T > > myChunk() const override
Procedural arrays return a NullPtr here.
Definition DirectProductArray.hpp:514
T first() const override
Get the data value at the firstIndex()
Definition DirectProductArray.hpp:524
RefPtr< MemBase > copy(const MemBase::Creator_t &C=nullptr) const override
Create a copy of the current array, duplicating all data and allocating new memory for it.
Definition DirectProductArray.hpp:441
const CreativeIterator< T > * creativeIterator() const override
Procedural arrays return 0 here.
Definition DirectProductArray.hpp:508
RefPtr< MemBase > makeMemArray(const MemBase::Creator_t &C) const override
Create an actual memory-occupying array from the procedural data here.
Definition DirectProductArray.hpp:450
Description of types, which is meta-information like what is the number of elements of some array-lik...
Definition FiberType.hpp:61
static WeakPtr_t getFiberType()
Get the fiber type information for the current type.
Definition FiberType.hpp:126
A set of integer values which describes how to iterate over a certain set of values.
Definition HyperslabParameters.hpp:34
Convenience class - a Direct Product array which uses linear expressions for each index dimension.
Definition DirectProductArray.hpp:552
bool getNearestMultiIndex(const T &pos, MultiIndex< MDIMS > &index) const
Get an index of the linear array (MultiIndex) from a given global float coordinate.
Definition DirectProductArray.hpp:685
T::value_type component_type
The components of the structured type T.
Definition DirectProductArray.hpp:567
bool getFlooredMultiIndex(const T &pos, MultiIndex< MDIMS > &index) const
Get an index of the linear array (MultiIndex) from a given global float coordinate.
Definition DirectProductArray.hpp:647
const void * OriginPtr() const override
Get pointer to origin of linearly procedural array, if it is linear.
Definition DirectProductArray.hpp:576
LinearDirectProductMemArray(const MultiIndex< MDIMS > &dims, const T &base, const DeltaT &delta, const MemBase::Creator_t &C=MemCore::NullPtr())
Constructor via multidimensional array with base and delta information on the field/array data values...
Definition DirectProductArray.hpp:609
const void * DeltaPtr() const override
Get pointer to delta of linearly procedural array, if it is linear.
Definition DirectProductArray.hpp:577
LinearDirectProductMemArray(const index_t dims[MDIMS], const T &base, const DeltaT &delta, const MemBase::Creator_t &C=MemCore::NullPtr())
Constructor, initializes the Components members.
Definition DirectProductArray.hpp:590
Abstract class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArrayBase.hpp:37
Base class for multidimensional arrays with MemCore memory management.
Definition MemBase.hpp:70
An intermediate class that allows to operate on the pure type information of some memory array.
Definition TypedArray.hpp:58
MemSizeConfig< sizeof(void *)>::memsize_t memsize_t
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
StrongPtr< Object, ObjectBase > RefPtr
string to_string(const Eagle::FixedArray< ElementType, N > &A, const char *OpenBrace="{", const char *CloseBrace="}", const char *Separator=",")
Definition DirectProductArray.hpp:360
Definition CoordinateAxisArray.hpp:18