This commit is contained in:
madrocketsci committed 2025-06-22 16:48:23 -04:00
commit cad98f8211
64 files changed
+5157

No files matched your search

@@ -0,0 +1,44 @@
#ifndef __AMSCPPNARRAY_IMPLSUBARRAY_HPP__
#define __AMSCPPNARRAY_IMPLSUBARRAY_HPP__
namespace ams
{
namespace narray
{
template<typename T> narray<T> narray<T>::subarray(const narray_size_t ind1, const narray_size_t ind2) const
{
int res;
narray<T> ret;
T defval = T();
narray_size_t I,J;
int nl = ind2-ind1;
if(nl<=0)
{
ret.resize(0);
return ret;
}
ret.resize(nl);
for(I=0;I<nl;I++)
{
J = I + ind1;
if(J<0 || J>=this->length)
{
ret.data[I] = defval;
}
else
{
ret.data[I] = this->data[J];
}
}
return ret;
}
};
};
#endif