40template <
typename T,
typename Alloc>
50template <
typename T,
typename Alloc>
52 : m_dimensions (dv), m_rep (a.m_rep),
53 m_slice_data (a.m_slice_data), m_slice_len (a.m_slice_len)
60 (*current_liboctave_error_handler)
61 (
"reshape: can't reshape %s array to %s array",
62 dimensions_str.c_str (), new_dims_str.c_str ());
71template <
typename T,
typename Alloc>
75 if (m_rep->m_count > 1)
79 m_slice_data = m_rep->m_data;
82 std::fill_n (m_slice_data, m_slice_len, val);
85template <
typename T,
typename Alloc>
89 if (--m_rep->m_count == 0)
94 m_slice_data = m_rep->m_data;
95 m_slice_len = m_rep->m_len;
100template <
typename T,
typename Alloc>
104 if (--m_rep->m_count == 0)
108 m_slice_data = m_rep->m_data;
109 m_slice_len = m_rep->m_len;
115template <
typename T,
typename Alloc>
123 bool dims_changed =
false;
129 for (
int i = 0; i < ndims (); i++)
131 if (m_dimensions(i) == 1)
134 new_dimensions(k++) = m_dimensions(i);
149 new_dimensions.
resize (2);
151 new_dimensions(0) = tmp;
152 new_dimensions(1) = 1;
157 new_dimensions.
resize (k);
168template <
typename T,
typename Alloc>
175template <
typename T,
typename Alloc>
183template <
typename T,
typename Alloc>
190template <
typename T,
typename Alloc>
197 if (n >= m_slice_len)
203template <
typename T,
typename Alloc>
210template <
typename T,
typename Alloc>
217template <
typename T,
typename Alloc>
224template <
typename T,
typename Alloc>
231 if (n >= m_slice_len)
237template <
typename T,
typename Alloc>
244template <
typename T,
typename Alloc>
252template <
typename T,
typename Alloc>
259template <
typename T,
typename Alloc>
268template <
typename T,
typename Alloc>
279template <
typename T,
typename Alloc>
303 for (
int i = 1; i <
m_n+1; i++) cdim[i] = cdim[i-1] * dv(i-1);
306 for (
int k = 0; k <
m_n; k++)
314 for (
int k = 1; k <
m_n; k++)
339 template <
typename T>
343 template <
typename T>
354 if (lr == m && lc == m)
356 const T *ss = src + kc * nr + kr;
359 blk[j*m+i] = ss[j*nr + i];
360 T *dd = dest + kr * nc + kc;
363 dd[j*nc+i] = blk[i*m+j];
367 const T *ss = src + kc * nr + kr;
370 blk[j*m+i] = ss[j*nr + i];
371 T *dd = dest + kr * nc + kc;
374 dd[j*nc+i] = blk[i*m+j];
384 template <
typename T>
393 std::copy_n (src,
len, dest);
411 dest =
do_permute (src + i * step, dest, lev-1);
429template <
typename T,
typename Alloc>
439 int perm_vec_len = perm_vec_arg.
numel ();
441 if (perm_vec_len < dv.
ndims ())
442 (*current_liboctave_error_handler)
443 (
"%s: invalid permutation vector", inv ?
"ipermute" :
"permute");
448 dv.
resize (perm_vec_len, 1);
453 bool identity =
true;
456 for (
int i = 0; i < perm_vec_len; i++)
459 if (perm_elt >= perm_vec_len || perm_elt < 0)
460 (*current_liboctave_error_handler)
461 (
"%s: permutation vector contains an invalid element",
462 inv ?
"ipermute" :
"permute");
464 if (checked[perm_elt])
465 (*current_liboctave_error_handler)
466 (
"%s: permutation vector cannot contain identical elements",
467 inv ?
"ipermute" :
"permute");
470 checked[perm_elt] =
true;
471 identity = identity && perm_elt == i;
480 for (
int i = 0; i < perm_vec_len; i++)
481 perm_vec(perm_vec_arg(i)) = i;
484 for (
int i = 0; i < perm_vec_len; i++)
485 dv_new(i) = dv(perm_vec(i));
517 for (
int i = 1; i <
m_n; i++)
544 template <
typename T>
547 template <
typename T>
550 template <
typename T>
561 template <
typename T>
562 T *
do_index (
const T *src, T *dest,
int lev)
const
578 template <
typename T>
579 const T *
do_assign (
const T *src, T *dest,
int lev)
const
595 template <
typename T>
596 void do_fill (
const T& val, T *dest,
int lev)
const
630 int l = ndv.
ndims ();
634 for (; i < l-1 && ndv(i) == odv(i); i++) ld *= ndv(i);
643 for (
int j = 0; j <
m_n; j++)
646 m_sext[j] = sld *= odv(i+j);
647 m_dext[j] = dld *= ndv(i+j);
660 template <
typename T>
667 template <
typename T>
672 std::copy_n (src,
m_cext[0], dest);
680 for (k = 0; k <
m_cext[lev]; k++)
683 std::fill_n (dest + k * dd,
m_dext[lev] - k * dd, rfv);
695template <
typename T,
typename Alloc>
733 if (n != 1 && is_nd_vector () && idx_len != 1
762template <
typename T,
typename Alloc>
790 if (ii.maybe_reduce (r, j, c))
793 if (ii.length () > 0 && ii.is_cont_range (n, l, u))
809 const T *src = data ();
813 dest += i.
index (src + r * j.
xelem (k), r, dest);
820template <
typename T,
typename Alloc>
824 int ial = ia.
numel ();
829 retval = index (ia(0));
831 retval = index (ia(0), ia(1));
838 bool all_colons =
true;
839 for (
int i = 0; i < ial; i++)
841 if (ia(i).extent (dv(i)) != dv(i))
845 all_colons = all_colons && ia(i).is_colon ();
858 for (
int i = 0; i < ial; i++) rdv(i) = ia(i).length (dv(i));
884template <
typename T,
typename Alloc>
888 static T zero = T ();
895template <
typename T,
typename Alloc>
899 if (n < 0 || ndims () != 2)
910 bool invalid =
false;
911 if (rows () == 0 || rows () == 1)
913 else if (columns () == 1)
922 if (n == nx - 1 && n > 0)
925 if (m_rep->m_count == 1)
926 m_slice_data[m_slice_len-1] = T ();
930 else if (n == nx + 1 && nx > 0)
933 if (m_rep->m_count == 1
934 && m_slice_data + m_slice_len < m_rep->m_data + m_rep->m_len)
936 m_slice_data[m_slice_len++] = rfv;
946 std::copy_n (data (), nx, dest);
959 std::copy_n (data (), n0, dest);
960 std::fill_n (dest + n0, n1, rfv);
966template <
typename T,
typename Alloc>
970 if (r < 0 || c < 0 || ndims () != 2)
975 if (r != rx || c != cx)
984 const T *src = data ();
987 std::copy_n (src, r * c0, dest);
994 std::copy_n (src, r0, dest);
997 std::fill_n (dest, r1, rfv);
1002 std::fill_n (dest, r * c1, rfv);
1008template <
typename T,
typename Alloc>
1012 int dvl = dv.
ndims ();
1014 resize2 (dv(0), dv(1), rfv);
1015 else if (m_dimensions != dv)
1017 if (m_dimensions.ndims () > dvl || dv.
any_neg ())
1030template <
typename T,
typename Alloc>
1047 if (tmp.
numel () != nx)
1051 return tmp.
index (i);
1054template <
typename T,
typename Alloc>
1057 bool resize_ok,
const T& rfv)
const
1067 if (r != rx || c != cx)
1079 return tmp.
index (i, j);
1082template <
typename T,
typename Alloc>
1085 bool resize_ok,
const T& rfv)
const
1090 int ial = ia.
numel ();
1093 for (
int i = 0; i < ial; i++)
1094 dvx(i) = ia(i).extent (dv(i));
1097 bool all_scalars =
true;
1098 for (
int i = 0; i < ial; i++)
1099 all_scalars = all_scalars && ia(i).is_scalar ();
1110 return tmp.
index (ia);
1113template <
typename T,
typename Alloc>
1120 if (rhl != 1 && i.
length (n) != rhl)
1129 if (m_dimensions.zero_by_zero () && colon)
1148 *
this = rhs.
reshape (m_dimensions);
1153 i.
fill (rhs(0), n, fortran_vec ());
1160template <
typename T,
typename Alloc>
1165 bool initial_dims_all_zero = m_dimensions.all_zero ();
1179 if (initial_dims_all_zero)
1183 rdv(0) = i.
extent (dv(0));
1184 rdv(1) = j.
extent (dv(1));
1187 bool isfill = rhs.
numel () == 1;
1191 bool match = (isfill
1192 || (rhdv.
ndims () == 2 && il == rhdv(0) && jl == rhdv(1)));
1193 match = match || (il == 1 && jl == rhdv(0) && rhdv(1) == 1);
1222 *
this = rhs.
reshape (m_dimensions);
1232 const T *src = rhs.
data ();
1233 T *dest = fortran_vec ();
1239 ii.
fill (*src, n, dest);
1241 ii.
assign (src, n, dest);
1248 i.
fill (*src, r, dest + r * j.
xelem (k));
1259 else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0))
1264template <
typename T,
typename Alloc>
1269 int ial = ia.
numel ();
1273 assign (ia(0), rhs, rfv);
1275 assign (ia(0), ia(1), rhs, rfv);
1278 bool initial_dims_all_zero = m_dimensions.all_zero ();
1292 if (initial_dims_all_zero)
1297 for (
int i = 0; i < ial; i++)
1298 rdv(i) = ia(i).extent (dv(i));
1303 bool all_colons =
true;
1304 bool isfill = rhs.
numel () == 1;
1308 int rhdvl = rhdv.
ndims ();
1309 for (
int i = 0; i < ial; i++)
1311 all_colons = all_colons && ia(i).is_colon_equiv (rdv(i));
1313 if (l == 1)
continue;
1314 match = match && j < rhdvl && l == rhdv(j++);
1317 match = match && (j == rhdvl || rhdv(j) == 1);
1318 match = match || isfill;
1346 *
this = rhs.
reshape (m_dimensions);
1357 rh.
fill (rhs(0), fortran_vec ());
1365 bool lhsempty, rhsempty;
1366 lhsempty = rhsempty =
false;
1368 for (
int i = 0; i < ial; i++)
1372 lhsempty = lhsempty || (l == 0);
1373 rhsempty = rhsempty || (rhdv(j++) == 0);
1375 if (! lhsempty || ! rhsempty)
1392template <
typename T,
typename Alloc>
1401 else if (i.
length (n) != 0)
1407 bool col_vec = ndims () == 2 && columns () == 1 && rows () != 1;
1408 if (i.
is_scalar () && i(0) == n-1 && m_dimensions.isvector ())
1418 const T *src = data ();
1420 std::copy_n (src, l, dest);
1421 std::copy (src + u, src + n, dest + l);
1432template <
typename T,
typename Alloc>
1436 if (dim < 0 || dim >= ndims ())
1437 (*current_liboctave_error_handler) (
"invalid dimension in delete_elements");
1444 else if (i.
length (n) != 0)
1459 for (
int k = 0; k < dim; k++) dl *= m_dimensions(k);
1460 for (
int k = dim + 1; k < ndims (); k++) du *= m_dimensions(k);
1464 const T *src = data ();
1466 l *= dl; u *= dl; n *= dl;
1469 std::copy_n (src, l, dest);
1471 std::copy (src + u, src + n, dest);
1488template <
typename T,
typename Alloc>
1492 int ial = ia.
numel ();
1495 delete_elements (ia(0));
1499 for (k = 0; k < ial; k++)
1501 if (! ia(k).is_colon ())
1517 delete_elements (dim, ia(dim));
1532 bool empty_assignment =
false;
1534 int num_non_colon_indices = 0;
1538 for (
int i = 0; i < ial; i++)
1542 if (ia(i).length (dim_len) == 0)
1544 empty_assignment =
true;
1548 if (! ia(i).is_colon_equiv (dim_len))
1550 num_non_colon_indices++;
1552 if (num_non_colon_indices == 2)
1557 if (! empty_assignment)
1558 (*current_liboctave_error_handler)
1559 (
"a null assignment can only have one non-colon index");
1565template <
typename T,
typename Alloc>
1571 if (ndims () == 2 && a.
ndims () == 2)
1578 for (
int k = 2; k < a.
ndims (); k++)
1586template <
typename T,
typename Alloc>
1601template <
typename T,
typename Alloc>
1605 assert (ndims () == 2);
1610 if (nr >= 8 && nc >= 8)
1620 else if (nr > 1 && nc > 1)
1626 result.
xelem (j, i) = xelem (i, j);
1637template <
typename T>
1644template <
typename T,
typename Alloc>
1648 assert (ndims () == 2);
1656 if (nr >= 8 && nc >= 8)
1665 for (jj = 0; jj < (nc - 8 + 1); jj += 8)
1668 for (ii = 0; ii < (nr - 8 + 1); ii += 8)
1672 j < jj + 8; j++, idxj += nr)
1674 buf[k++] = xelem (i + idxj);
1681 result.
xelem (j + idxi) = fcn (buf[k]);
1687 result.
xelem (j, i) = fcn (xelem (i, j));
1692 result.
xelem (j, i) = fcn (xelem (i, j));
1702 result.
xelem (j, i) = fcn (xelem (i, j));
1742template <
typename T,
typename Alloc>
1748 return m_slice_data;
1752template <
typename T>
1759template <
typename T,
typename Alloc>
1764 (*current_liboctave_error_handler) (
"sort: invalid dimension");
1773 if (dim >= dv.
ndims ())
1780 for (
int i = 0; i < dim; i++)
1783 T *v = m.fortran_vec ();
1784 const T *ov = data ();
1808 if (sort_isnan<T> (tmp))
1820 std::reverse (v + ku, v + ns);
1822 std::rotate (v, v + ku, v + ns);
1837 offset += n_strides * stride * (ns - 1);
1844 T tmp = ov[i*stride + offset];
1845 if (sort_isnan<T> (tmp))
1852 lsort.
sort (buf, kl);
1857 std::reverse (buf + ku, buf + ns);
1859 std::rotate (buf, buf + ku, buf + ns);
1864 v[i*stride + offset] = buf[i];
1871template <
typename T,
typename Alloc>
1876 if (dim < 0 || dim >= ndims ())
1877 (*current_liboctave_error_handler) (
"sort: invalid dimension");
1893 for (
int i = 0; i < dim; i++)
1896 T *v = m.fortran_vec ();
1897 const T *ov = data ();
1921 if (sort_isnan<T> (tmp))
1936 lsort.
sort (v, vi, kl);
1941 std::reverse (v + ku, v + ns);
1942 std::reverse (vi + ku, vi + ns);
1945 std::rotate (v, v + ku, v + ns);
1946 std::rotate (vi, vi + ku, vi + ns);
1964 offset += n_strides * stride * (ns - 1);
1971 T tmp = ov[i*stride + offset];
1972 if (sort_isnan<T> (tmp))
1987 lsort.
sort (buf, bufi, kl);
1992 std::reverse (buf + ku, buf + ns);
1993 std::reverse (bufi + ku, bufi + ns);
1996 std::rotate (buf, buf + ku, buf + ns);
1997 std::rotate (bufi, bufi + ku, bufi + ns);
2003 v[i*stride + offset] = buf[i];
2005 vi[i*stride + offset] = bufi[i];
2012template <
typename T,
typename Alloc>
2025template <
typename T,
typename Alloc>
2039 compare_fcn_type compare
2042 if (compare (
elem (n-1),
elem (0)))
2057template <
typename T,
typename Alloc>
2075template <
typename T,
typename Alloc>
2084 if (r <= 1 || c == 0)
2090 compare_fcn_type compare
2094 for (i = 0; i < cols (); i++)
2097 T u =
elem (rows () - 1, i);
2108 else if (compare (u, l))
2119 if (mode ==
UNSORTED && i == cols ())
2136template <
typename T,
typename Alloc>
2154 return lsort.
lookup (data (), n, value);
2157template <
typename T,
typename Alloc>
2179 static const double ratio = 1.0;
2187 if ((vmode ==
ASCENDING && sort_isnan<T> (values(nval-1)))
2188 || (vmode ==
DESCENDING && sort_isnan<T> (values(0))))
2201template <
typename T,
typename Alloc>
2205 const T *src = data ();
2208 const T zero = T ();
2216template <
typename T,
typename Alloc>
2221 const T *src = data ();
2223 const T zero = T ();
2224 if (n < 0 || n >= nel)
2230 cnt += src[i] != zero;
2232 retval.
clear (cnt, 1);
2235 if (src[i] != zero) *dest++ = i;
2242 retval.
clear (n, 1);
2250 for (; l >= 0 && src[l] == zero; l--) ;
2259 std::reverse (rdata, rdata + k);
2268 for (; l != nel && src[l] == zero; l++) ;
2289 || (rows () == 0 && dims ().
numel (1) == 0))
2291 else if (rows () == 1 && ndims () == 2)
2297template <
typename T,
typename Alloc>
2302 (*current_liboctave_error_handler) (
"nth_element: invalid dimension");
2305 if (dim >= dv.ndims ())
2306 dv.resize (dim+1, 1);
2313 dv.chop_trailing_singletons ();
2348 if (n(1) - n(0) == 1)
2353 else if (n(1) - n(0) == -1)
2360 if ((mode ==
ASCENDING && n(i) - n(i-1) != 1)
2361 || (mode ==
DESCENDING && n(i) - n(i-1) != -1))
2369 (*current_liboctave_error_handler)
2370 (
"nth_element: n must be a scalar or a contiguous range");
2374 if (lo < 0 || up > ns)
2375 (*current_liboctave_error_handler) (
"nth_element: invalid element index");
2380 for (
int i = 0; i < dim; i++)
2384 const T *ov = data ();
2402 if (sort_isnan<T> (tmp))
2416 T tmp = ov[offset + i*stride];
2417 if (sort_isnan<T> (tmp))
2423 if (offset == stride-1)
2437 std::rotate (buf, buf + ku, buf + ns);
2451 v[offset + stride * i] = buf[lo + i];
2452 if (offset == stride-1)
2460#define NO_INSTANTIATE_ARRAY_SORT_API(T, API) \
2461 template <> API Array<T> \
2462 Array<T>::sort (int, sortmode) const \
2466 template <> API Array<T> \
2467 Array<T>::sort (Array<octave_idx_type> &sidx, int, sortmode) const \
2469 sidx = Array<octave_idx_type> (); \
2472 template <> API sortmode \
2473 Array<T>::issorted (sortmode) const \
2477 API Array<T>::compare_fcn_type \
2478 safe_comparator (sortmode, const Array<T>&, bool) \
2482 template <> API Array<octave_idx_type> \
2483 Array<T>::sort_rows_idx (sortmode) const \
2485 return Array<octave_idx_type> (); \
2487 template <> API sortmode \
2488 Array<T>::is_sorted_rows (sortmode) const \
2492 template <> API octave_idx_type \
2493 Array<T>::lookup (T const &, sortmode) const \
2497 template <> API Array<octave_idx_type> \
2498 Array<T>::lookup (const Array<T>&, sortmode) const \
2500 return Array<octave_idx_type> (); \
2502 template <> API octave_idx_type \
2503 Array<T>::nnz (void) const \
2507 template <> API Array<octave_idx_type> \
2508 Array<T>::find (octave_idx_type, bool) const \
2510 return Array<octave_idx_type> (); \
2512 template <> API Array<T> \
2513 Array<T>::nth_element (const octave::idx_vector&, int) const { \
2514 return Array<T> (); \
2517#define NO_INSTANTIATE_ARRAY_SORT(T) NO_INSTANTIATE_ARRAY_SORT_API (T,)
2519template <
typename T,
typename Alloc>
2528 (*current_liboctave_error_handler) (
"Matrix must be 2-dimensional");
2533 if (nnr == 0 && nnc == 0)
2535 else if (nnr != 1 && nnc != 1)
2543 if (nnr > 0 && nnc > 0)
2552 d.xelem (i) =
elem (i, i+k);
2557 d.xelem (i) =
elem (i-k, i);
2562 d.xelem (i) =
elem (i, i);
2590 d.xelem (i+roff, i+coff) =
elem (0, i);
2598 d.xelem (i+roff, i+coff) =
elem (i, 0);
2605template <
typename T,
typename Alloc>
2609 if (ndims () != 2 || (rows () != 1 && cols () != 1))
2610 (*current_liboctave_error_handler) (
"cat: invalid dimension");
2616 retval.xelem (i, i) = xelem (i);
2621template <
typename T,
typename Alloc>
2628 if (dim == -1 || dim == -2)
2634 (*current_liboctave_error_handler) (
"cat: invalid dimension");
2637 return array_list[0];
2664 if (n > 2 && dim > 1)
2684 if (! (dv.*concat_rule) (array_list[i].
dims (), dim))
2685 (*current_liboctave_error_handler) (
"cat: dimension mismatch");
2689 if (retval.isempty ())
2704 if (array_list[i].isempty ())
2710 if (dim < array_list[i].ndims ())
2711 u = l + array_list[i].
dims ()(dim);
2717 retval.assign (idxa, array_list[i]);
2725template <
typename T,
typename Alloc>
2729 os << prefix <<
"m_rep address: " << m_rep <<
'\n'
2730 << prefix <<
"m_rep->m_len: " << m_rep->m_len <<
'\n'
2731 << prefix <<
"m_rep->m_data: " <<
static_cast<void *
> (m_rep->m_data) <<
'\n'
2732 << prefix <<
"m_rep->m_count: " << m_rep->m_count <<
'\n'
2733 << prefix <<
"m_slice_data: " <<
static_cast<void *
> (m_slice_data) <<
'\n'
2734 << prefix <<
"m_slice_len: " << m_slice_len <<
'\n';
2742template <
typename T,
typename Alloc>
2745 bool retval = m_dimensions == dv;
2752template <
typename T,
typename Alloc>
2760#if defined (__clang__)
2761# define INSTANTIATE_ARRAY(T, API) \
2762 template <> API void \
2763 Array<T>::instantiation_guard () { } \
2765 template class API Array<T>
2767# define INSTANTIATE_ARRAY(T, API) \
2768 template <> API void \
2769 Array<T>::instantiation_guard () { } \
2771 template class Array<T>
2776template <
typename T,
typename Alloc>
2782 int n_dims = a_dims.
ndims ();
2784 os << n_dims <<
"-dimensional array";
2787 os <<
" (" << a_dims.
str () <<
')';
2800 for (
int i = 2; i < n_dims; i++)
2844 for (
int i = 0; i < m; i++)
2848 for (
int j = 2; j < n_dims - 1; j++)
2849 os <<
ra_idx(j) + 1 <<
',';
2851 os <<
ra_idx(n_dims - 1) + 1 <<
") = \n";
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
dim_vector zero_dims_inquire(const Array< octave::idx_vector > &ia, const dim_vector &rhdv)
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
bool sort_isnan(typename ref_param< T >::type)
Array< T, Alloc >::compare_fcn_type safe_comparator(sortmode mode, const Array< T, Alloc > &, bool)
std::ostream & operator<<(std::ostream &os, const Array< T, Alloc > &a)
static T no_op_fcn(const T &x)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
The real representation of all arrays.
octave::refcount< octave_idx_type > m_count
N Dimensional Array with copy-on-write semantics.
Array< T, Alloc >::ArrayRep * m_rep
OCTARRAY_API Array< T, Alloc > transpose(void) const
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_API void clear(void)
OCTARRAY_API Array< T, Alloc > squeeze(void) const
Chop off leading singleton dimensions.
OCTARRAY_API Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
octave_idx_type numel(void) const
Number of elements in the array.
friend class Array
Size of the specified dimension.
OCTARRAY_API void assign(const octave::idx_vector &i, const Array< T, Alloc > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_API Array< T, Alloc > nth_element(const octave::idx_vector &n, int dim=0) const
Returns the n-th element in increasing order, using the same ordering as used for sort.
OCTARRAY_API octave_idx_type nnz(void) const
Count nonzero elements.
OCTARRAY_API Array< T, Alloc > hermitian(T(*fcn)(const T &)=nullptr) const
Size of the specified dimension.
octave_idx_type dim2(void) const
OCTARRAY_API void resize1(octave_idx_type n, const T &rfv)
Size of the specified dimension.
T & elem(octave_idx_type n)
Size of the specified dimension.
ref_param< T >::type crefT
octave_idx_type rows(void) const
static OCTARRAY_API void instantiation_guard()
Size of the specified dimension.
OCTARRAY_API Array< T, Alloc > column(octave_idx_type k) const
Extract column: A(:,k+1).
bool isempty(void) const
Size of the specified dimension.
OCTARRAY_API Array< T, Alloc > linear_slice(octave_idx_type lo, octave_idx_type up) const
Extract a slice from this array as a column vector: A(:)(lo+1:up).
OCTARRAY_API bool optimize_dimensions(const dim_vector &dv)
Returns true if this->dims () == dv, and if so, replaces this->m_dimensions by a shallow copy of dv.
OCTARRAY_API Array< T, Alloc > page(octave_idx_type k) const
Extract page: A(:,:,k+1).
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_API Array< T, Alloc > & insert(const Array< T, Alloc > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
octave_idx_type columns(void) const
static OCTARRAY_API Array< T, Alloc >::ArrayRep * nil_rep(void)
const T * data(void) const
Size of the specified dimension.
octave_idx_type dim1(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_API void delete_elements(const octave::idx_vector &i)
Deleting elements.
OCTARRAY_API Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
OCTARRAY_API Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
OCTARRAY_API Array< T, Alloc > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Size of the specified dimension.
OCTARRAY_API Array< T, Alloc > sort(int dim=0, sortmode mode=ASCENDING) const
Size of the specified dimension.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
OCTARRAY_API void print_info(std::ostream &os, const std::string &prefix) const
Size of the specified dimension.
int ndims(void) const
Size of the specified dimension.
OCTARRAY_API sortmode issorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
virtual OCTARRAY_API T resize_fill_value(void) const
Size of the specified dimension.
OCTARRAY_API T & checkelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_API sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
OCTARRAY_API void fill(const T &val)
OCTARRAY_API Array< T, Alloc > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
OCTARRAY_API octave_idx_type compute_index(octave_idx_type i, octave_idx_type j) const
Size of the specified dimension.
OCTARRAY_API octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
OCTARRAY_API void resize2(octave_idx_type nr, octave_idx_type nc, const T &rfv)
Resizing (with fill).
static OCTARRAY_API Array< T, Alloc > cat(int dim, octave_idx_type n, const Array< T, Alloc > *array_list)
Concatenation along a specified (0-based) dimension, equivalent to cat().
Vector representing the dimensions (size) of an Array.
OCTAVE_API bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
OCTAVE_API void chop_all_singletons(void)
OCTAVE_API std::string str(char sep='x') const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool zero_by_zero(void) const
void resize(int n, int fill_value=0)
static dim_vector alloc(int n)
OCTAVE_API bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
void chop_trailing_singletons(void)
octave_idx_type ndims(void) const
Number of dimensions.
bool is_nd_vector(void) const
OCTAVE_API dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
OCTAVE_API octave_idx_type safe_numel(void) const
The following function will throw a std::bad_alloc () exception if the requested size is larger than ...
dim_vector make_nd_vector(octave_idx_type n) const
bool is_colon(void) const
octave_idx_type extent(octave_idx_type n) const
octave_idx_type xelem(octave_idx_type n) const
idx_class_type idx_class(void) const
OCTAVE_API idx_vector complement(octave_idx_type n) const
octave_idx_type assign(const T *src, octave_idx_type n, T *dest) const
bool is_scalar(void) const
OCTAVE_API bool maybe_reduce(octave_idx_type n, const idx_vector &j, octave_idx_type nj)
octave_idx_type index(const T *src, octave_idx_type n, T *dest) const
OCTAVE_API bool is_cont_range(octave_idx_type n, octave_idx_type &l, octave_idx_type &u) const
static const idx_vector colon
dim_vector orig_dimensions(void) const
octave_idx_type fill(const T &val, octave_idx_type n, T *dest) const
OCTAVE_API octave_idx_type increment(void) const
octave_idx_type length(octave_idx_type n=0) const
bool is_colon_equiv(octave_idx_type n) const
virtual octave_idx_type numel(void) const
void set_compare(const compare_fcn_type &comp)
void sort_rows(const T *data, octave_idx_type *idx, octave_idx_type rows, octave_idx_type cols)
static bool descending_compare(typename ref_param< T >::type, typename ref_param< T >::type)
bool issorted(const T *data, octave_idx_type nel)
octave_idx_type lookup(const T *data, octave_idx_type nel, const T &value)
void sort(T *data, octave_idx_type nel)
void nth_element(T *data, octave_idx_type nel, octave_idx_type lo, octave_idx_type up=-1)
bool is_sorted_rows(const T *data, octave_idx_type rows, octave_idx_type cols)
void lookup_sorted(const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx, bool rev=false)
void assign(const T *src, T *dest) const
octave::idx_vector * m_idx
const T * do_assign(const T *src, T *dest, int lev) const
rec_index_helper(const rec_index_helper &)=delete
rec_index_helper(const dim_vector &dv, const Array< octave::idx_vector > &ia)
void index(const T *src, T *dest) const
void do_fill(const T &val, T *dest, int lev) const
rec_index_helper & operator=(const rec_index_helper &)=delete
void fill(const T &val, T *dest) const
bool is_cont_range(octave_idx_type &l, octave_idx_type &u) const
T * do_index(const T *src, T *dest, int lev) const
~rec_permute_helper(void)
static T * blk_trans(const T *src, T *dest, octave_idx_type nr, octave_idx_type nc)
void permute(const T *src, T *dest) const
T * do_permute(const T *src, T *dest, int lev) const
octave_idx_type * m_stride
rec_permute_helper(const dim_vector &dv, const Array< octave_idx_type > &perm)
rec_permute_helper(const rec_permute_helper &)=delete
rec_permute_helper & operator=(const rec_permute_helper &)=delete
rec_resize_helper & operator=(const rec_resize_helper &)=delete
rec_resize_helper(const rec_resize_helper &)=delete
void do_resize_fill(const T *src, T *dest, const T &rfv, int lev) const
void resize_fill(const T *src, T *dest, const T &rfv) const
rec_resize_helper(const dim_vector &ndv, const dim_vector &odv)
if_then_else< is_class_type< T >::no, T, Tconst & >::result type
octave::idx_vector idx_vector
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
Complex log2(const Complex &x)
static OCTAVE_NORETURN void err_index_out_of_range(void)
void err_invalid_index(const std::string &idx, octave_idx_type nd, octave_idx_type dim, const std::string &)
void err_del_index_out_of_range(bool is1d, octave_idx_type idx, octave_idx_type ext)
void err_invalid_resize(void)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
T::size_type numel(const T &str)
const octave_base_value const Array< octave_idx_type > & ra_idx