// -*- C++ -*- #include "ma_functional.h" namespace MultiArrayTools { template IndexMapFunction:: IndexMapFunction(const MultiArrayBase& ma, const OutRange& outRange, const Name& inName, const Name& outName) : mMap(ma, inName), mOutRange(new OutRange( outRange )), mOIndex(mOutRange->begin()) { //CHECK; mOIndex.name(outName); } template void IndexMapFunction::linkIndicesTo(IndefinitIndexBase* target) { mMap.linkIndicesTo(target); } template void IndexMapFunction::eval() const { mOIndex.copyPos( mMap.get() ); } template IndefinitIndexBase& IndexMapFunction::index() const { return mOIndex; } vec3d2Function::vec3d2Function(const OutRange& outRange) : mOutRange(new OutRange( outRange )), out(mOutRange->begin()) {} 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; } 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; } }