2017-03-27 11:33:40 +02:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#include "ma_functional.h"
|
|
|
|
|
|
|
|
namespace MultiArrayTools
|
|
|
|
{
|
|
|
|
|
2017-03-27 19:29:51 +02:00
|
|
|
template <class InRange, class OutRange>
|
|
|
|
IndexMapFunction<InRange,OutRange>::
|
|
|
|
IndexMapFunction(const MultiArrayBase<typename OutRange::IndexType,InRange>& ma,
|
|
|
|
const OutRange& outRange,
|
|
|
|
const Name& inName, const Name& outName) : mMap(ma, inName),
|
|
|
|
mOutRange(new OutRange( outRange )),
|
|
|
|
mOIndex(mOutRange->begin())
|
|
|
|
{
|
2017-03-28 17:55:12 +02:00
|
|
|
//CHECK;
|
2017-03-27 19:29:51 +02:00
|
|
|
mOIndex.name(outName);
|
|
|
|
}
|
2017-03-27 11:33:40 +02:00
|
|
|
|
2017-03-27 19:29:51 +02:00
|
|
|
template <class InRange, class OutRange>
|
|
|
|
void IndexMapFunction<InRange,OutRange>::linkIndicesTo(IndefinitIndexBase* target)
|
2017-03-27 11:33:40 +02:00
|
|
|
{
|
2017-03-27 19:29:51 +02:00
|
|
|
mMap.linkIndicesTo(target);
|
2017-03-27 11:33:40 +02:00
|
|
|
}
|
|
|
|
|
2017-03-27 19:29:51 +02:00
|
|
|
template <class InRange, class OutRange>
|
|
|
|
void IndexMapFunction<InRange,OutRange>::eval() const
|
2017-03-27 11:33:40 +02:00
|
|
|
{
|
2017-03-27 19:29:51 +02:00
|
|
|
mOIndex.copyPos( mMap.get() );
|
2017-03-27 11:33:40 +02:00
|
|
|
}
|
|
|
|
|
2017-03-27 19:29:51 +02:00
|
|
|
template <class InRange, class OutRange>
|
|
|
|
IndefinitIndexBase& IndexMapFunction<InRange,OutRange>::index() const
|
2017-03-27 11:33:40 +02:00
|
|
|
{
|
|
|
|
return mOIndex;
|
|
|
|
}
|
2017-03-27 19:29:51 +02:00
|
|
|
|
|
|
|
|
2017-03-28 17:55:12 +02:00
|
|
|
|
|
|
|
vec3d2Function::vec3d2Function(const OutRange& outRange) : mOutRange(new OutRange( outRange )),
|
|
|
|
out(mOutRange->begin()) {}
|
|
|
|
|
2017-03-27 19:29:51 +02:00
|
|
|
vec3d2Function::OutIndex vec3d2Function::operator()(const InIndex& i) const
|
|
|
|
{
|
|
|
|
OutSubIndex& osi = out.template getIndex<0>();
|
|
|
|
|
|
|
|
osi.atMeta( i.template getIndex<0>().getMetaPos() * i.template getIndex<0>().getMetaPos() +
|
|
|
|
i.template getIndex<1>().getMetaPos() * i.template getIndex<1>().getMetaPos() +
|
|
|
|
i.template getIndex<2>().getMetaPos() * i.template getIndex<2>().getMetaPos() );
|
|
|
|
return out;
|
|
|
|
}
|
2017-03-30 21:42:53 +02:00
|
|
|
|
|
|
|
pyProjFunction::pyProjFunction(const OutRange& outRange) : mOutRange(new OutRange( outRange )),
|
|
|
|
out(mOutRange->begin()) {}
|
|
|
|
|
|
|
|
pyProjFunction::OutIndex pyProjFunction::operator()(const InIndex& i) const
|
|
|
|
{
|
|
|
|
DistIndex& di = out.template getIndex<0>();
|
|
|
|
ScalProdIndex& si = out.template getIndex<1>();
|
|
|
|
di.atMeta( i.template getIndex<1>().getMetaPos() * i.template getIndex<1>().getMetaPos() +
|
|
|
|
i.template getIndex<2>().getMetaPos() * i.template getIndex<2>().getMetaPos() +
|
|
|
|
i.template getIndex<3>().getMetaPos() * i.template getIndex<3>().getMetaPos() );
|
|
|
|
|
|
|
|
si.atMeta( i.template getIndex<1>().getMetaPos() * i.template getIndex<0>().getMetaPos()[0]
|
|
|
|
i.template getIndex<2>().getMetaPos() * i.template getIndex<0>().getMetaPos()[1]
|
|
|
|
i.template getIndex<3>().getMetaPos() * i.template getIndex<0>().getMetaPos()[2] );
|
|
|
|
return out;
|
|
|
|
}
|
2017-03-27 11:33:40 +02:00
|
|
|
}
|