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 <boost/multi_array.hpp>
template <class T, int N>
typename DimArray<T, N>::ndimarr array_minus(const typename DimArray<T, N>::ndimarr& A,
const typename DimArray<T, N>::ndimarr& B)
{
typename DimArray<T, N>::ndimarr temp(A);
typedef typename DimArray<T, N>::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<T, 2>::ndimarr& MAX,
const typename DimArray<T, 2>::ndimarr& Alloc,
const typename DimArray<T, 2>::ndimarr& Need,
const typename DimArray<T, 1>::ndimarr& Available)
{
typename DimArray<T, 1>::ndimarr Work(Available);
typename DimArray<bool, 1>::ndimarr Finish(boost::extents[Need[0].size()]);
typedef typename DimArray<T, 2>::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.