2 question:
Hi, i would like to know are there any easy way to do multi_array math
operation on ones of same dimension and size..
#include
template
typename DimArray::ndimarr array_minus(const typename DimArray::ndimarr& A,
const typename DimArray::ndimarr&
B)
{
typename DimArray::ndimarr temp(A);
typedef typename DimArray::size TDS;
const TDS outer_sz(A.size());
const TDS inner_sz(A[0].size());
for (TDS i = 0; i < outer_sz; ++i)
{
for (TDS j = 0; j < inner_sz; ++j)
{
temp[i][j] -= B[i][j];
}
}
return temp;
}
question 2: How do you find a index of an item where a specify condition is
true.
given this...
template <class T>
bool isSafe(const typename DimArray::ndimarr& MAX,
const typename DimArray::ndimarr& Alloc,
const typename DimArray::ndimarr& Need,
const typename DimArray::ndimarr& Available)
{
typename DimArray::ndimarr Work(Available);
typename DimArray::ndimarr
Finish(boost::extents[Need[0].size()]);
typedef typename DimArray::size TDS;
const TDS outer_sz(MAX.size());
const TDS inner_sz(MAX[0].size());
for(TDS i = 0; i < inner_sz; ++i)
Finish[i] = false;
}
Is there a effective and safe way to find i such that Need[i] <= Work other
than a loop.
Thanks for the help.