...
This commit is contained in:
parent
54dfcdb85d
commit
5bc469296b
3 changed files with 15 additions and 2 deletions
|
@ -32,6 +32,7 @@ namespace MultiArrayHelper
|
|||
static OpFunc f;
|
||||
if(mRes.size() == 0) { mRes.assign(arg.size(), static_cast<T>(0)); }
|
||||
assert(mRes.size() == arg.size());
|
||||
VCHECK(arg);
|
||||
for(size_t i = 0; i != arg.size(); ++i){
|
||||
mRes[i] = f(mRes[i], arg[i]);
|
||||
}
|
||||
|
|
13
src/block.h
13
src/block.h
|
@ -56,7 +56,7 @@ namespace MultiArrayHelper
|
|||
};
|
||||
|
||||
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];
|
||||
for(size_t i = 1; i != block.size(); ++i){
|
||||
|
@ -65,6 +65,17 @@ namespace MultiArrayHelper
|
|||
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>
|
||||
class MutableBlockBase : public BlockBase<T>
|
||||
{
|
||||
|
|
|
@ -355,8 +355,9 @@ namespace MultiArrayTools
|
|||
template <typename T, class Op, class IndexType>
|
||||
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)){
|
||||
VCHECK(mInd->pos());
|
||||
f(mOp.get());
|
||||
}
|
||||
return mRes;
|
||||
|
|
Loading…
Reference in a new issue