This commit is contained in:
Christian Zimmermann 2017-11-15 17:35:44 +01:00
parent 54dfcdb85d
commit 5bc469296b
3 changed files with 15 additions and 2 deletions

View file

@ -32,6 +32,7 @@ namespace MultiArrayHelper
static OpFunc f; static OpFunc f;
if(mRes.size() == 0) { mRes.assign(arg.size(), static_cast<T>(0)); } if(mRes.size() == 0) { mRes.assign(arg.size(), static_cast<T>(0)); }
assert(mRes.size() == arg.size()); assert(mRes.size() == arg.size());
VCHECK(arg);
for(size_t i = 0; i != arg.size(); ++i){ for(size_t i = 0; i != arg.size(); ++i){
mRes[i] = f(mRes[i], arg[i]); mRes[i] = f(mRes[i], arg[i]);
} }

View file

@ -56,7 +56,7 @@ namespace MultiArrayHelper
}; };
template <typename T> template <typename T>
std::ostream& operator<<(std::ostream& out, const BlockBase<T>& block) std::ostream& operator<<(std::ostream& out, const MBlock<T>& block)
{ {
out << block[0]; out << block[0];
for(size_t i = 1; i != block.size(); ++i){ for(size_t i = 1; i != block.size(); ++i){
@ -65,6 +65,17 @@ namespace MultiArrayHelper
return out; return out;
} }
template <typename T>
std::ostream& operator<<(std::ostream& out, const BlockResult<T>& block)
{
out << block[0];
for(size_t i = 1; i != block.size(); ++i){
out << ", " << block[i];
}
return out;
}
template <typename T> template <typename T>
class MutableBlockBase : public BlockBase<T> class MutableBlockBase : public BlockBase<T>
{ {

View file

@ -355,8 +355,9 @@ namespace MultiArrayTools
template <typename T, class Op, class IndexType> template <typename T, class Op, class IndexType>
const BlockResult<T>& Contraction<T,Op,IndexType>::get() const const BlockResult<T>& Contraction<T,Op,IndexType>::get() const
{ {
BlockBinaryOpSelf<T,std::plus<T>,BlockResult<T> > f(mRes); BlockBinaryOpSelf<T,std::plus<T>,decltype(mOp.get())> f(mRes);
for(*mInd = 0; mInd->pos() != mInd->max(); ++(*mInd)){ for(*mInd = 0; mInd->pos() != mInd->max(); ++(*mInd)){
VCHECK(mInd->pos());
f(mOp.get()); f(mOp.get());
} }
return mRes; return mRes;