Commit bc639623 authored by Martin Reinecke's avatar Martin Reinecke

add warnings are arrays have bad strides

parent 954f7419
......@@ -112,6 +112,14 @@ template<typename T, size_t ndim> class mav
ptrdiff_t stride(size_t i) const { return str[i]; }
T *data() const
{ return d; }
bool last_contiguous() const
{ return (str[ndim-1]==1) || (str[ndim-1]==0); }
void check_storage(const char *name) const
{
if (!last_contiguous())
cout << "Array '" << name << "': last dimension is not contiguous.\n"
"This may slow down computation significantly!\n";
}
bool contiguous() const
{
ptrdiff_t stride=1;
......@@ -954,6 +962,8 @@ template<class T, class T2> class MsServ
: baselines(baselines_), idx(idx_), ms(ms_), wgt(wgt_),
nvis(idx.shape(0)), have_wgt(wgt.size()!=0)
{
wgt.check_storage("wgt");
ms.check_storage("ms");
checkShape(ms.shape(), {baselines.Nrows(), baselines.Nchannels()});
if (have_wgt) checkShape(wgt.shape(), ms.shape());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment