49 : dimensions (dv), rep (a.rep),
50 slice_data (a.slice_data), slice_len (a.slice_len)
57 (*current_liboctave_error_handler)
58 (
"reshape: can't reshape %s array to %s array",
59 dimensions_str.c_str (), new_dims_str.c_str ());
76 slice_data = rep->data;
79 std::fill_n (slice_data, slice_len, val);
86 if (--rep->count == 0)
91 slice_data = rep->data;
101 if (--rep->count == 0)
105 slice_data = rep->
data;
106 slice_len = rep->len;
120 bool dims_changed =
false;
126 for (
int i = 0; i < ndims (); i++)
128 if (dimensions(i) == 1)
131 new_dimensions(k++) = dimensions(i);
146 new_dimensions.
resize (2);
148 new_dimensions(0) = tmp;
149 new_dimensions(1) = 1;
154 new_dimensions.
resize (k);
159 retval =
Array<T> (*
this, new_dimensions);
261 #ifdef BOUNDS_CHECKING
262 if (k < 0 || k > dimensions.numel (1))
276 #ifdef BOUNDS_CHECKING
277 if (k < 0 || k > dimensions.numel (2))
288 #ifdef BOUNDS_CHECKING
294 if (up < lo) up = lo;
314 stride (dim + n), use_blk (false)
316 assert (n == perm.
length ());
321 for (
int i = 1; i < n+1; i++) cdim[i] = cdim[i-1] * dv(i-1);
324 for (
int k = 0; k <
n; k++)
328 stride[k] = cdim[kk];
332 for (
int k = 1; k <
n; k++)
334 if (stride[k] == stride[top]*dim[top])
340 stride[
top] = stride[k];
345 use_blk = top >= 1 && stride[1] == 1 && stride[0] == dim[1];
363 if (lr == m && lc == m)
365 const T *ss = src + kc * nr + kr;
368 blk[j*m+i] = ss[j*nr + i];
369 T *dd = dest + kr * nc + kc;
372 dd[j*nc+i] = blk[i*m+j];
376 const T *ss = src + kc * nr + kr;
379 blk[j*m+i] = ss[j*nr + i];
380 T *dd = dest + kr * nc + kc;
383 dd[j*nc+i] = blk[i*m+j];
402 std::copy (src, src + len, dest);
413 else if (use_blk && lev == 1)
414 dest =
blk_trans (src, dest, dim[1], dim[0]);
420 dest =
do_permute (src + i * step, dest, lev-1);
449 int perm_vec_len = perm_vec_arg.
length ();
451 if (perm_vec_len < dv.
length ())
453 (
"%s: invalid permutation vector", inv ?
"ipermute" :
"permute");
458 dv.
resize (perm_vec_len, 1);
463 bool identity =
true;
466 for (
int i = 0; i < perm_vec_len; i++)
469 if (perm_elt >= perm_vec_len || perm_elt < 0)
471 (*current_liboctave_error_handler)
472 (
"%s: permutation vector contains an invalid element",
473 inv ?
"ipermute" :
"permute");
478 if (checked[perm_elt])
480 (*current_liboctave_error_handler)
481 (
"%s: permutation vector cannot contain identical elements",
482 inv ?
"ipermute" :
"permute");
488 checked[perm_elt] =
true;
489 identity = identity && perm_elt == i;
498 for (
int i = 0; i < perm_vec_len; i++)
499 perm_vec(perm_vec_arg(i)) = i;
502 for (
int i = 0; i < perm_vec_len; i++)
503 dv_new(i) = dv(perm_vec(i));
544 for (
int i = 1; i <
n; i++)
547 if (idx[top].maybe_reduce (dim[top], ia(i), dv(i)))
558 cdim[
top] = cdim[top-1] * dim[top-1];
572 dest += idx[0].
index (src, dim[0], dest);
578 dest =
do_index (src + d*idx[lev].xelem (i), dest, lev-1);
586 const T *
do_assign (
const T *src, T *dest,
int lev)
const
589 src += idx[0].
assign (src, dim[0], dest);
595 src =
do_assign (src, dest + d*idx[lev].xelem (i), lev-1);
603 void do_fill (
const T& val, T *dest,
int lev)
const
606 idx[0].
fill (val, dim[0], dest);
612 do_fill (val, dest + d*idx[lev].xelem (i), lev-1);
631 void fill (
const T& val, T *dest)
const {
do_fill (val, dest, top); }
652 : cext (0), sext (0), dext (0), n (0)
655 assert (odv.
length () == l);
658 for (; i < l-1 && ndv(i) == odv(i); i++) ld *= ndv(i);
667 for (
int j = 0; j <
n; j++)
669 cext[j] =
std::min (ndv(i+j), odv(i+j));
670 sext[j] = sld *= odv(i+j);
671 dext[j] = dld *= ndv(i+j);
686 std::copy (src, src+cext[0], dest);
687 std::fill_n (dest + cext[0], dext[0] - cext[0], rfv);
694 for (k = 0; k < cext[lev]; k++)
697 std::fill_n (dest + k * dd, dext[lev] - k * dd, rfv);
752 if (ndims () == 2 && n != 1 && rd.
is_vector ())
756 else if (rows () == 1)
763 retval =
Array<T> (*
this, rd, l, u);
825 const T* src = data ();
829 dest += i.
index (src + r * j.
xelem (k), r, dest);
845 retval = index (ia(0));
847 retval = index (ia(0), ia(1));
854 bool all_colons =
true;
855 for (
int i = 0; i < ial; i++)
857 if (ia(i).extent (dv(i)) != dv(i))
860 all_colons = all_colons && ia(i).is_colon ();
874 for (
int i = 0; i < ial; i++) rdv(i) = ia(i).
length (dv(i));
883 retval =
Array<T> (*
this, rdv, l, u);
904 static T zero = T ();
915 if (n >= 0 && ndims () == 2)
925 bool invalid =
false;
926 if (rows () == 0 || rows () == 1)
928 else if (columns () == 1)
938 if (n == nx - 1 && n > 0)
942 slice_data[slice_len-1] = T ();
946 else if (n == nx + 1 && nx > 0)
950 && slice_data + slice_len < rep->data + rep->len)
952 slice_data[slice_len++] = rfv;
962 std::copy (data (), data () + nx, dest);
975 std::copy (data (), data () + n0, dest);
976 std::fill_n (dest + n0, n1, rfv);
990 if (r >= 0 && c >= 0 && ndims () == 2)
994 if (r != rx || c != cx)
1003 const T *src = data ();
1006 std::copy (src, src + r * c0, dest);
1013 std::copy (src, src + r0, dest);
1016 std::fill_n (dest, r1, rfv);
1021 std::fill_n (dest, r * c1, rfv);
1037 resize2 (dv(0), dv(1), rfv);
1038 else if (dimensions != dv)
1040 if (dimensions.length () <= dvl && ! dv.
any_neg ())
1072 if (tmp.
numel () != nx)
1076 return tmp.
index (i);
1082 bool resize_ok,
const T& rfv)
const
1092 if (r != rx || c != cx)
1104 return tmp.
index (i, j);
1110 bool resize_ok,
const T& rfv)
const
1118 for (
int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv (i));
1121 bool all_scalars =
true;
1122 for (
int i = 0; i < ial; i++)
1123 all_scalars = all_scalars && ia(i).is_scalar ();
1134 return tmp.
index (ia);
1145 if (rhl == 1 || i.
length (n) == rhl)
1153 if (dimensions.zero_by_zero () && colon)
1172 *
this = rhs.
reshape (dimensions);
1177 i.
fill (rhs(0), n, fortran_vec ());
1191 bool initial_dims_all_zero = dimensions.all_zero ();
1205 if (initial_dims_all_zero)
1209 rdv(0) = i.
extent (dv(0));
1210 rdv(1) = j.
extent (dv(1));
1213 bool isfill = rhs.
numel () == 1;
1217 bool match = (isfill
1218 || (rhdv.
length () == 2 && il == rhdv(0) && jl == rhdv(1)));
1219 match = match || (il == 1 && jl == rhdv(0) && rhdv(1) == 1);
1248 *
this = rhs.
reshape (dimensions);
1258 const T* src = rhs.
data ();
1259 T *dest = fortran_vec ();
1265 ii.
fill (*src, n, dest);
1267 ii.
assign (src, n, dest);
1274 i.
fill (*src, r, dest + r * j.
xelem (k));
1297 assign (ia(0), rhs, rfv);
1299 assign (ia(0), ia(1), rhs, rfv);
1302 bool initial_dims_all_zero = dimensions.all_zero ();
1316 if (initial_dims_all_zero)
1321 for (
int i = 0; i < ial; i++)
1322 rdv(i) = ia(i).extent (dv(i));
1327 bool all_colons =
true;
1328 bool isfill = rhs.
numel () == 1;
1332 int rhdvl = rhdv.
length ();
1333 for (
int i = 0; i < ial; i++)
1335 all_colons = all_colons && ia(i).is_colon_equiv (rdv(i));
1337 if (l == 1)
continue;
1338 match = match && j < rhdvl && l == rhdv(j++);
1341 match = match && (j == rhdvl || rhdv(j) == 1);
1342 match = match || isfill;
1370 *
this = rhs.
reshape (dimensions);
1381 rh.
fill (rhs(0), fortran_vec ());
1400 else if (i.
length (n) != 0)
1406 bool col_vec = ndims () == 2 && columns () == 1 && rows () != 1;
1407 if (i.
is_scalar () && i(0) == n-1 && dimensions.is_vector ())
1417 const T *src = data ();
1419 std::copy (src, src + l, dest);
1420 std::copy (src + u, src + n, dest + l);
1435 if (dim < 0 || dim >= ndims ())
1437 (*current_liboctave_error_handler)
1438 (
"invalid dimension in delete_elements");
1447 else if (i.
length (n) != 0)
1462 for (
int k = 0; k < dim; k++) dl *= dimensions(k);
1463 for (
int k = dim + 1; k < ndims (); k++) du *= dimensions(k);
1467 const T *src = data ();
1469 l *= dl; u *= dl; n *= dl;
1472 std::copy (src, src + l, dest);
1474 std::copy (src + u, src + n, dest);
1498 delete_elements (ia(0));
1502 for (k = 0; k < ial; k++)
1504 if (! ia(k).is_colon ())
1520 delete_elements (dim, ia(dim));
1535 bool empty_assignment =
false;
1537 int num_non_colon_indices = 0;
1541 for (
int i = 0; i < ial; i++)
1545 if (ia(i).
length (dim_len) == 0)
1547 empty_assignment =
true;
1551 if (! ia(i).is_colon_equiv (dim_len))
1553 num_non_colon_indices++;
1555 if (num_non_colon_indices == 2)
1560 if (! empty_assignment)
1561 (*current_liboctave_error_handler)
1562 (
"a null assignment can only have one non-colon index");
1574 if (ndims () == 2 && a.
ndims () == 2)
1581 for (
int k = 2; k < a.
ndims (); k++)
1597 idx(k) =
idx_vector (ra_idx (k), ra_idx (k) + dva(k));
1609 assert (ndims () == 2);
1614 if (nr >= 8 && nc >= 8)
1624 else if (nr > 1 && nc > 1)
1630 result.
xelem (j, i) = xelem (i, j);
1652 assert (ndims () == 2);
1660 if (nr >= 8 && nc >= 8)
1671 for (jj = 0; jj < (nc - 8 + 1); jj += 8)
1673 for (ii = 0; ii < (nr - 8 + 1); ii += 8)
1677 j < jj + 8; j++, idxj += nr)
1679 buf[k++] = xelem (i + idxj);
1686 result.
xelem (j + idxi) = fcn (buf[k]);
1692 result.
xelem (j, i) = fcn (xelem (i, j));
1697 result.
xelem (j, i) = fcn (xelem (i, j));
1707 result.
xelem (j, i) = fcn (xelem (i, j));
1770 (*current_liboctave_error_handler)
1771 (
"sort: invalid dimension");
1789 for (
int i = 0; i < dim; i++)
1793 const T *ov = data ();
1813 if (sort_isnan<T> (tmp))
1825 std::reverse (v + ku, v + ns);
1827 std::rotate (v, v + ku, v + ns);
1843 while (offset >= stride)
1849 offset += offset2 * stride * ns;
1857 T tmp = ov[i*stride + offset];
1858 if (sort_isnan<T> (tmp))
1865 lsort.
sort (buf, kl);
1870 std::reverse (buf + ku, buf + ns);
1872 std::rotate (buf, buf + ku, buf + ns);
1877 v[i*stride + offset] = buf[i];
1889 if (dim < 0 || dim >= ndims ())
1891 (*current_liboctave_error_handler)
1892 (
"sort: invalid dimension");
1910 for (
int i = 0; i < dim; i++)
1914 const T *ov = data ();
1937 if (sort_isnan<T> (tmp))
1952 lsort.
sort (v, vi, kl);
1957 std::reverse (v + ku, v + ns);
1958 std::reverse (vi + ku, vi + ns);
1961 std::rotate (v, v + ku, v + ns);
1962 std::rotate (vi, vi + ku, vi + ns);
1981 while (offset >= stride)
1987 offset += offset2 * stride * ns;
1995 T tmp = ov[i*stride + offset];
1996 if (sort_isnan<T> (tmp))
2011 lsort.
sort (buf, bufi, kl);
2016 std::reverse (buf + ku, buf + ns);
2017 std::reverse (bufi + ku, bufi + ns);
2020 std::rotate (buf, buf + ku, buf + ns);
2021 std::rotate (bufi, bufi + ku, bufi + ns);
2027 v[i*stride + offset] = buf[i];
2029 vi[i*stride + offset] = bufi[i];
2063 compare_fcn_type compare
2066 if (compare (
elem (n-1),
elem (0)))
2112 if (r <= 1 || c == 0)
2118 compare_fcn_type compare
2122 for (i = 0; i < cols (); i++)
2125 T u =
elem (rows () - 1, i);
2136 else if (compare (u, l))
2147 if (mode ==
UNSORTED && i == cols ())
2182 return lsort.
lookup (data (), n, value);
2207 static const double ratio = 1.0;
2211 if (nval > ratio * n /
xlog2 (n + 1.0))
2215 if ((vmode ==
ASCENDING && sort_isnan<T> (values(nval-1)))
2216 || (vmode ==
DESCENDING && sort_isnan<T> (values(0))))
2222 idx.fortran_vec (), vmode != mode);
2224 lsort.
lookup (data (), n, values.
data (), nval, idx.fortran_vec ());
2233 const T *src = data ();
2236 const T zero = T ();
2249 const T *src = data ();
2251 const T zero = T ();
2252 if (n < 0 || n >= nel)
2258 cnt += src[i] != zero;
2260 retval.
clear (cnt, 1);
2263 if (src[i] != zero) *dest++ = i;
2270 retval.
clear (n, 1);
2278 for (; l >= 0 && src[l] == zero; l--) ;
2287 std::reverse (rdata, rdata + k);
2296 for (; l != nel && src[l] == zero; l++) ;
2316 if ((numel () == 1 && retval.
is_empty ())
2317 || (rows () == 0 && dims ().numel (1) == 0))
2319 else if (rows () == 1 && ndims () == 2)
2331 (*current_liboctave_error_handler)
2332 (
"nth_element: invalid dimension");
2350 if (m.numel () == 0)
2382 (*current_liboctave_error_handler)
2383 (
"nth_element: n must be a scalar or a contiguous range");
2389 if (lo < 0 || up > ns)
2391 (*current_liboctave_error_handler)
2392 (
"nth_element: invalid element index");
2399 for (
int i = 0; i < dim; i++)
2402 T *v = m.fortran_vec ();
2403 const T *ov = data ();
2422 if (sort_isnan<T> (tmp))
2437 T tmp = ov[offset + i*stride];
2438 if (sort_isnan<T> (tmp))
2444 if (offset == stride-1)
2458 std::rotate (buf, buf + ku, buf + ns);
2472 v[offset + stride * i] = buf[lo + i];
2473 if (offset == stride-1)
2481 #define NO_INSTANTIATE_ARRAY_SORT(T) \
2483 template <> Array<T> \
2484 Array<T>::sort (int, sortmode) const { return *this; } \
2486 template <> Array<T> \
2487 Array<T>::sort (Array<octave_idx_type> &sidx, int, sortmode) const \
2488 { sidx = Array<octave_idx_type> (); return *this; } \
2490 template <> sortmode \
2491 Array<T>::is_sorted (sortmode) const \
2492 { return UNSORTED; } \
2494 Array<T>::compare_fcn_type \
2495 safe_comparator (sortmode, const Array<T>&, bool) \
2498 template <> Array<octave_idx_type> \
2499 Array<T>::sort_rows_idx (sortmode) const \
2500 { return Array<octave_idx_type> (); } \
2502 template <> sortmode \
2503 Array<T>::is_sorted_rows (sortmode) const \
2504 { return UNSORTED; } \
2506 template <> octave_idx_type \
2507 Array<T>::lookup (T const &, sortmode) const \
2509 template <> Array<octave_idx_type> \
2510 Array<T>::lookup (const Array<T>&, sortmode) const \
2511 { return Array<octave_idx_type> (); } \
2513 template <> octave_idx_type \
2514 Array<T>::nnz (void) const\
2516 template <> Array<octave_idx_type> \
2517 Array<T>::find (octave_idx_type, bool) const\
2518 { return Array<octave_idx_type> (); } \
2520 template <> Array<T> \
2521 Array<T>::nth_element (const idx_vector&, int) const { return Array<T> (); }
2533 (*current_liboctave_error_handler) (
"Matrix must be 2-dimensional");
2539 if (nnr == 0 && nnc == 0)
2541 else if (nnr != 1 && nnc != 1)
2549 if (nnr > 0 && nnc > 0)
2618 if (ndims () == 2 && (rows () == 1 || cols () == 1))
2623 retval.
xelem (i, i) = xelem (i);
2627 (
"cat: invalid dimension");
2639 if (dim == -1 || dim == -2)
2645 (*current_liboctave_error_handler)
2646 (
"cat: invalid dimension");
2649 return array_list[0];
2676 if (n > 2 && dim > 1)
2696 if (! (dv.*concat_rule) (array_list[i].
dims (), dim))
2697 (*current_liboctave_error_handler)
2698 (
"cat: dimension mismatch");
2702 if (retval.is_empty ())
2717 if (array_list[i].is_empty ())
2723 if (dim < array_list[i].ndims ())
2724 u = l + array_list[i].
dims ()(dim);
2730 retval.assign (idxa, array_list[i]);
2742 os << prefix <<
"rep address: " << rep <<
'\n'
2743 << prefix <<
"rep->len: " << rep->len <<
'\n'
2744 << prefix <<
"rep->data: " <<
static_cast<void *
> (rep->data) <<
'\n'
2745 << prefix <<
"rep->count: " << rep->count <<
'\n'
2746 << prefix <<
"slice_data: " << static_cast<void *> (slice_data) <<
'\n'
2747 << prefix <<
"slice_len: " << slice_len <<
'\n';
2758 bool retval = dimensions == dv;
2773 #define INSTANTIATE_ARRAY(T, API) \
2774 template <> void Array<T>::instantiation_guard () { } \
2775 template class API Array<T>
2781 operator << (std::ostream& os, const Array<T>& a)
2785 int n_dims = a_dims.
length ();
2787 os << n_dims <<
"-dimensional array";
2790 os <<
" (" << a_dims.
str () <<
")";
2803 for (
int i = 2; i < n_dims; i++)
2823 os <<
" " << a.elem (ra_idx);
2835 os <<
" " << a.elem (ra_idx);
2847 for (
int i = 0; i < m; i++)
2851 for (
int j = 2; j < n_dims - 1; j++)
2852 os <<
ra_idx(j) + 1 <<
",";
2854 os <<
ra_idx(n_dims - 1) + 1 <<
") = \n";
2863 os <<
" " << a.elem (ra_idx);
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
bool is_cont_range(octave_idx_type &l, octave_idx_type &u) const
bool is_empty(void) const
octave_idx_type length(octave_idx_type n=0) const
void resize_fill(const T *src, T *dest, const T &rfv) const
std::string str(char sep= 'x') const
Array(void)
Empty ctor (0 by 0).
void sort_rows(const T *data, octave_idx_type *idx, octave_idx_type rows, octave_idx_type cols)
ref_param< T >::type crefT
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_idx_type lookup(const T *data, octave_idx_type nel, const T &value)
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
bool is_vector(void) const
void permute(const T *src, T *dest) const
static const idx_vector colon
octave_idx_type assign(const T *src, octave_idx_type n, T *dest) const
octave_idx_type numel(void) const
Number of elements in the array.
static octave_idx_type nn
void delete_elements(const idx_vector &i)
Deleting elements.
dim_vector zero_dims_inquire(const Array< idx_vector > &ia, const dim_vector &rhdv)
void assign(const T *src, T *dest) const
octave_idx_type compute_index(octave_idx_type i, octave_idx_type j) const
void set_compare(compare_fcn_type comp)
void do_fill(const T &val, T *dest, int lev) const
void resize(int n, int fill_value=0)
rec_permute_helper & operator=(const rec_permute_helper &)
Array< T >::compare_fcn_type safe_comparator(sortmode mode, const Array< T > &, bool)
octave_idx_type xelem(octave_idx_type n) const
T * do_permute(const T *src, T *dest, int lev) const
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
void resize2(octave_idx_type nr, octave_idx_type nc, const T &rfv)
Resizing (with fill).
Array< T > page(octave_idx_type k) const
Extract page: A(:,:,k+1).
octave_idx_type fill(const T &val, octave_idx_type n, T *dest) const
T & elem(octave_idx_type n)
~rec_permute_helper(void)
rec_permute_helper(const dim_vector &dv, const Array< octave_idx_type > &perm)
void gripe_assignment_dimension_mismatch(void)
The real representation of all arrays.
void gripe_invalid_index(void)
octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
octave_idx_type rows(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
F77_RET_T const double const double double * d
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
bool optimize_dimensions(const dim_vector &dv)
Returns true if this->dims () == dv, and if so, replaces this->dimensions by a shallow copy of dv...
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
static void instantiation_guard()
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
static T no_op_fcn(const T &x)
dim_vector orig_dimensions(void) const
liboctave_error_handler current_liboctave_error_handler
virtual T resize_fill_value(void) const
octave_idx_type safe_numel(void) const
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
idx_vector complement(octave_idx_type n) const
bool sort_isnan(typename ref_param< T >::type)
octave_idx_type index(const T *src, octave_idx_type n, T *dest) const
static void gripe_index_out_of_range(void)
static Array< T > cat(int dim, octave_idx_type n, const Array< T > *array_list)
Concatenation along a specified (0-based) dimension, equivalent to cat().
rec_resize_helper & operator=(const rec_resize_helper &)
void resize1(octave_idx_type n, const T &rfv)
void chop_all_singletons(void)
Array< T > 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).
static T * blk_trans(const T *src, T *dest, octave_idx_type nr, octave_idx_type nc)
void print_info(std::ostream &os, const std::string &prefix) const
Array< T > transpose(void) const
const T * data(void) const
void gripe_invalid_resize(void)
void resize(const dim_vector &dv, const T &rfv)
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Array< T > column(octave_idx_type k) const
Extract column: A(:,k+1).
dim_vector redim(int n) const
void fill(const T &val, T *dest) const
static bool descending_compare(typename ref_param< T >::type, typename ref_param< T >::type)
bool is_cont_range(octave_idx_type n, octave_idx_type &l, octave_idx_type &u) const
const T * do_assign(const T *src, T *dest, int lev) const
static dim_vector alloc(int n)
octave_idx_type nnz(void) const
Count nonzero elements.
bool is_sorted_rows(const T *data, octave_idx_type rows, octave_idx_type cols)
bool is_sorted(const T *data, octave_idx_type nel)
rec_index_helper(const dim_vector &dv, const Array< idx_vector > &ia)
if_then_else< is_class_type< T >::no, T, T const & >::result type
T & xelem(octave_idx_type n)
bool is_colon_equiv(octave_idx_type n) const
sortmode is_sorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Handles the reference counting for all the derived classes.
charNDArray max(char d, const charNDArray &m)
idx_class_type idx_class(void) const
octave_idx_type length(void) const
Number of elements in the array.
octave_idx_type extent(octave_idx_type n) const
void sort(T *data, octave_idx_type nel)
void gripe_invalid_assignment_size(void)
T & checkelem(octave_idx_type n)
octave_refcount< int > count
bool zero_by_zero(void) const
void lookup_sorted(const T *data, octave_idx_type nel, const T *values, octave_idx_type nvalues, octave_idx_type *idx, bool rev=false)
Array< T > hermitian(T(*fcn)(const T &)=0) const
rec_index_helper & operator=(const rec_index_helper &)
bool is_scalar(void) const
rec_resize_helper(const dim_vector &ndv, const dim_vector &odv)
void index(const T *src, T *dest) const
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Array< octave_idx_type > find(octave_idx_type n=-1, bool backward=false) const
Find indices of (at most n) nonzero elements.
bool maybe_reduce(octave_idx_type n, const idx_vector &j, octave_idx_type nj)
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
Array< T > nth_element(const idx_vector &n, int dim=0) const
Returns the n-th element in increasing order, using the same ordering as used for sort...
static bool match(const std::string &filename_arg, const std::string &path_elt_arg)
static MArray< double > const octave_idx_type const octave_idx_type octave_idx_type octave_idx_type octave_idx_type c1
void nth_element(T *data, octave_idx_type nel, octave_idx_type lo, octave_idx_type up=-1)
static MArray< double > const octave_idx_type const octave_idx_type octave_idx_type r1
void gripe_del_index_out_of_range(bool is1d, octave_idx_type idx, octave_idx_type ext)
const T * fortran_vec(void) const
void do_resize_fill(const T *src, T *dest, const T &rfv, int lev) const
void chop_trailing_singletons(void)
octave_idx_type increment(void) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
octave_idx_type columns(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
bool is_colon(void) const
F77_RET_T const double * x
charNDArray min(char d, const charNDArray &m)
Array< T >::ArrayRep * rep
T * do_index(const T *src, T *dest, int lev) const