71 (*current_liboctave_error_handler)
72 (
"Sparse::SparseRep::elem (octave_idx_type, octave_idx_type): sparse matrix filled");
74 for (i =
c[_c]; i <
c[_c + 1]; i++)
83 (*current_liboctave_error_handler)
84 (
"Sparse::SparseRep::elem (octave_idx_type, octave_idx_type): sparse matrix filled");
105 template <
typename T>
116 template <
typename T>
137 change_length (c[ncols]);
140 template <
typename T>
148 nz = (nz > 0 ? nz : 1);
151 static const int frac = 5;
152 if (nz > nzmx || nz < nzmx - nzmx/frac)
158 std::copy_n (
r, min_nzmx, new_ridx);
163 T *new_data =
new T [nz];
164 std::copy_n (
d, min_nzmx, new_data);
173 template <
typename T>
180 template <
typename T>
193 template <
typename T>
221 template <
typename T>
223 : rep (new typename
Sparse<T>::
SparseRep (a.rows (), a.cols (), a.rows ())),
224 dimensions (
dim_vector (a.rows (), a.cols ()))
239 template <
typename T>
241 : rep (nullptr), dimensions (dv)
243 if (dv.
ndims () != 2)
244 (*current_liboctave_error_handler)
245 (
"Sparse::Sparse (const dim_vector&): dimension mismatch");
250 template <
typename T>
252 : rep (nullptr), dimensions (dv)
256 unsigned long long a_nel =
static_cast<unsigned long long>(a.
rows ()) *
257 static_cast<unsigned long long>(a.
cols ());
258 unsigned long long dv_nel =
static_cast<unsigned long long>(dv(0)) *
259 static_cast<unsigned long long>(dv(1));
262 (*current_liboctave_error_handler)
263 (
"Sparse::Sparse (const Sparse&, const dim_vector&): dimension mismatch");
289 xcidx (k+1) = new_nzmx;
292 template <
typename T>
297 : rep (nullptr), dimensions ()
301 else if (
r.extent (nr) > nr)
302 (*current_liboctave_error_handler)
303 (
"sparse: row index %" OCTAVE_IDX_TYPE_FORMAT
"out of bound "
304 "%" OCTAVE_IDX_TYPE_FORMAT,
r.extent (nr), nr);
308 else if (c.
extent (nc) > nc)
310 (
"sparse: column index %" OCTAVE_IDX_TYPE_FORMAT
" out of bound "
311 "%" OCTAVE_IDX_TYPE_FORMAT,
r.extent (nc), nc);
318 bool a_scalar =
n == 1;
327 if ((rl != 1 && rl !=
n) || (cl != 1 && cl !=
n))
328 (*current_liboctave_error_handler) (
"sparse: dimension mismatch");
333 if (rl <= 1 && cl <= 1)
335 if (
n == 1 && a(0) != T ())
340 std::fill_n (
xcidx () + c(0) + 1, nc - c(0), 1);
362 new_nz += rd[i-1] != rd[i];
366 std::fill_n (
xcidx () + c(0) + 1, nc - c(0), new_nz);
431 sidx[ci[cd[i]+1]++] = rd[0];
433 sidx[ci[cd[i]+1]++] = rd[i];
439 std::sort (sidx + ci[j], sidx + ci[j+1]);
511 new_nz += rd[i-1] != rd[i];
515 std::fill_n (
xcidx () + c(0) + 1, nc - c(0), new_nz);
531 if (rd[i] != rd[i-1])
545 if (rd[i] != rd[i-1])
574 typedef std::pair<octave_idx_type, octave_idx_type> idx_pair;
579 idx_pair& p = spairs[ci[cd[i]+1]++];
591 std::sort (spairs + ci[j], spairs + ci[j+1]);
626 rrd[++jj] = a(spairs[i].second);
630 rrd[jj] += a(spairs[i].second);
644 rrd[jj] = a(spairs[i].second);
659 template <
typename T>
661 : rep (nullptr), dimensions (a.dims ())
664 (*current_liboctave_error_handler)
665 (
"Sparse::Sparse (const Array<T>&): dimension mismatch");
684 if (a.
elem (i,j) != T ())
693 template <
typename T>
696 if (--rep->count == 0)
700 template <
typename T>
706 if (--rep->count == 0)
718 template <
typename T>
725 (*current_liboctave_error_handler)
726 (
"Sparse<T>::compute_index: invalid ra_idxing operation");
741 template <
typename T>
745 (*current_liboctave_error_handler) (
"%s (%" OCTAVE_IDX_TYPE_FORMAT
"): "
746 "range error", fcn,
n);
749 template <
typename T>
753 (*current_liboctave_error_handler) (
"%s (%" OCTAVE_IDX_TYPE_FORMAT
"): "
754 "range error", fcn,
n);
757 template <
typename T>
762 (*current_liboctave_error_handler)
763 (
"%s (%" OCTAVE_IDX_TYPE_FORMAT
", %" OCTAVE_IDX_TYPE_FORMAT
"): "
764 "range error", fcn, i, j);
767 template <
typename T>
771 (*current_liboctave_error_handler)
772 (
"%s (%" OCTAVE_IDX_TYPE_FORMAT
", %" OCTAVE_IDX_TYPE_FORMAT
"): "
773 "range error", fcn, i, j);
776 template <
typename T>
781 std::ostringstream buf;
793 buf <<
"): range error";
795 std::string buf_str = buf.str ();
797 (*current_liboctave_error_handler) (
"%s", buf_str.c_str ());
800 template <
typename T>
804 std::ostringstream buf;
816 buf <<
"): range error";
818 std::string buf_str = buf.str ();
820 (*current_liboctave_error_handler) (
"%s", buf_str.c_str ());
823 template <
typename T>
830 if (dims2.
ndims () > 2)
832 (*current_liboctave_warning_with_id_handler)
833 (
"Octave:reshape-smashes-dims",
834 "reshape: sparse reshape to N-D array smashes dims");
837 dims2(1) *= dims2(i);
842 if (dimensions != dims2)
844 if (dimensions.numel () == dims2.
numel ())
862 if (i_old_rm >= new_nr)
864 i_old_qu += i_old_rm / new_nr;
865 i_old_rm = i_old_rm % new_nr;
870 ii = (i_old_rm + ridx (j)) % new_nr;
871 jj = i_old_qu + (i_old_rm + ridx (j)) / new_nr;
879 retval.xdata (j) = data (j);
884 retval.xcidx (k+1) = new_nnz;
888 std::string dimensions_str = dimensions.str ();
889 std::string new_dims_str = new_dims.
str ();
891 (*current_liboctave_error_handler)
892 (
"reshape: can't reshape %s array to %s array",
893 dimensions_str.c_str (), new_dims_str.c_str ());
902 template <
typename T>
911 if (perm_vec.
numel () == 2)
913 if (perm_vec(0) == 0 && perm_vec(1) == 1)
915 else if (perm_vec(0) == 1 && perm_vec(1) == 0)
924 (*current_liboctave_error_handler)
925 (
"permutation vector contains an invalid element");
927 return trans ? this->
transpose () : *
this;
930 template <
typename T>
940 resize (nr, (
n + nr - 1) / nr);
949 template <
typename T>
956 (*current_liboctave_error_handler) (
"sparse array must be 2-D");
958 resize (dv(0), dv(1));
961 template <
typename T>
966 (*current_liboctave_error_handler) (
"can't resize to negative dimension");
968 if (
r == dim1 () && c == dim2 ())
985 xdata (k) = xdata (i);
986 xridx (k++) = xridx (i);
992 rep->nrows = dimensions(0) =
r;
997 std::copy_n (rep->c,
std::min (c, rep->ncols) + 1, new_cidx);
1002 std::fill_n (rep->c + rep->ncols + 1, c - rep->ncols,
1003 rep->c[rep->ncols]);
1006 rep->ncols = dimensions(1) = c;
1008 rep->change_length (rep->nnz ());
1011 template <
typename T>
1020 if (r < 0 || r + a_rows > rows () || c < 0 || c + a_cols > cols ())
1021 (*current_liboctave_error_handler) (
"range error for insert");
1026 if (c + a_cols < nc)
1027 nel += cidx (nc) - cidx (c + a_cols);
1031 if (ridx (j) <
r || ridx (j) >=
r + a_rows)
1040 data (i) = tmp.
data (i);
1041 ridx (i) = tmp.
ridx (i);
1044 cidx (i) = tmp.
cidx (i);
1053 if (tmp.
ridx (j) <
r)
1055 data (ii) = tmp.
data (j);
1056 ridx (ii++) = tmp.
ridx (j);
1063 data (ii) = a.
data (j);
1064 ridx (ii++) =
r + a.
ridx (j);
1070 if (tmp.
ridx (j) >=
r + a_rows)
1072 data (ii) = tmp.
data (j);
1073 ridx (ii++) = tmp.
ridx (j);
1083 data (ii) = tmp.
data (j);
1084 ridx (ii++) = tmp.
ridx (j);
1092 template <
typename T>
1098 (*current_liboctave_error_handler) (
"range error for insert");
1103 template <
typename T>
1107 assert (ndims () == 2);
1115 retval.xcidx (ridx (i) + 1)++;
1131 retval.xdata (q) = data (k);
1133 assert (nnz () ==
retval.xcidx (nr));
1150 for (l = 0; l < nr; l++)
1156 return std::lower_bound (ridx, ridx + nr, ri) - ridx;
1159 template <
typename T>
1165 assert (ndims () == 2);
1175 if (idx.
extent (nel) > nel)
1193 *
this =
Sparse<T> (nr - (ub - lb), 1, nz_new);
1194 std::copy_n (tmp.
data (), li, data ());
1195 std::copy_n (tmp.
ridx (), li, xridx ());
1196 std::copy (tmp.
data () + ui, tmp.
data () + nz, xdata () + li);
1212 for (; j < sl && sj[j] <
r; j++) ;
1213 if (j == sl || sj[j] >
r)
1215 data_new[nz_new] = tmp.
data (i);
1216 ridx_new[nz_new++] =
r - j;
1221 std::copy_n (ridx_new, nz_new, ridx ());
1222 std::copy_n (data_new, nz_new, xdata ());
1236 *
this =
Sparse<T> (1, nc - (ub - lb), new_nz);
1237 std::copy_n (tmp.
data (), lbi, data ());
1238 std::copy (tmp.
data () + ubi, tmp.
data () + nz, xdata () + lbi);
1240 std::copy_n (tmp.
cidx () + 1, lb, cidx () + 1);
1247 else if (idx.
length (nel) != 0)
1254 delete_elements (idx);
1260 template <
typename T>
1264 assert (ndims () == 2);
1274 if (idx_j.
extent (nc) > nc)
1278 if (lb == 0 && ub == nc)
1295 *
this =
Sparse<T> (nr, nc - (ub - lb), new_nz);
1296 std::copy_n (tmp.
data (), lbi, data ());
1297 std::copy_n (tmp.
ridx (), lbi, ridx ());
1298 std::copy (tmp.
data () + ubi, tmp.
data () + nz, xdata () + lbi);
1299 std::copy (tmp.
ridx () + ubi, tmp.
ridx () + nz, xridx () + lbi);
1300 std::copy_n (tmp.
cidx () + 1, lb, cidx () + 1);
1302 tmp.
cidx () + ub + 1, ubi - lbi);
1306 *
this = index (idx_i, idx_j.
complement (nc));
1312 if (idx_i.
extent (nr) > nr)
1316 if (lb == 0 && ub == nr)
1332 tmpl.
nnz () + tmpu.
nnz ());
1338 xdata (k) = tmpl.
data (i);
1339 xridx (k++) = tmpl.
ridx (i);
1344 xdata (k) = tmpu.
data (i);
1345 xridx (k++) = tmpu.
ridx (i) + lb;
1370 bool empty_assignment
1373 if (! empty_assignment)
1374 (*current_liboctave_error_handler)
1375 (
"a null assignment can only have one non-colon index");
1379 template <
typename T>
1391 template <
typename T>
1397 assert (ndims () == 2);
1420 retval.xdata (j) = data (j);
1421 retval.xridx (j) = ridx (j) + i * nr;
1429 else if (idx.
extent (nel) > nel)
1440 else if (nr == 1 && nc == 1)
1446 retval = (
Sparse<T> (idx_dims(0), idx_dims(1), nz ? data (0) : T ()));
1457 if (i < nz && ridx (i) == idx(0))
1471 std::copy_n (data () + li, nz_new,
retval.
data ());
1473 retval.xcidx (1) = nz_new;
1482 retval.ridx (j) = nr - ridx (nz - j - 1) - 1;
1484 std::copy_n (cidx (), 2,
retval.cidx ());
1485 std::reverse_copy (data (), data () + nz,
retval.
data ());
1490 tmp = tmp.
index (idx);
1523 if (l < nz && ridx (l) == idxa(i, j))
1526 lidx.
xelem (i, j) = nz;
1559 std::copy_n (data () + lbi, new_nz,
retval.
data ());
1583 if (idx_dims(0) == 1 && idx_dims(1) != 1)
1591 template <
typename T>
1594 bool resize_ok)
const
1598 assert (ndims () == 2);
1616 tmp.
resize (ext_i, ext_j);
1619 else if (idx_i.
extent (nr) > nr)
1624 else if (nr == 1 && nc == 1)
1645 std::copy_n (data () + lbi, new_nz,
retval.
data ());
1646 std::copy_n (ridx () + lbi, new_nz,
retval.ridx ());
1656 retval.xcidx (j+1) =
retval.xcidx (j) + (cidx (jj+1) - cidx (jj));
1668 std::copy_n (data () + ljj, nzj,
retval.
data () + lj);
1669 std::copy_n (ridx () + ljj, nzj,
retval.ridx () + lj);
1696 if (i < nzj && ridx (i+lj) == ii)
1711 if (
retval.xcidx (j+1) > i)
1714 retval.xdata (i) = data (ij[j]);
1732 li[j] = lij =
lblookup (ridx () + lj, nzj, lb) + lj;
1733 ui[j] = uij =
lblookup (ridx () + lj, nzj, ub) + lj;
1745 retval.xdata (k) = data (i);
1746 retval.xridx (k++) = ridx (i) - lb;
1758 retval.xcidx (j+1) =
retval.xcidx (j) + (cidx (jj+1) - cidx (jj));
1778 retval.xdata (li + i) = data (uj - i);
1779 retval.xridx (li + i) = nr - 1 - ridx (uj - i);
1802 scb[rri[li + i] = iinv[ridx (lj + i)]] = data (lj + i);
1807 std::sort (rri + li, rri + li + nzj);
1811 retval.xdata (li + i) = scb[rri[li + i]];
1835 template <
typename T>
1841 assert (ndims () == 2);
1869 *
this = rhs.
reshape (dimensions);
1871 else if (nc == 1 && rhs.
cols () == 1)
1885 if (new_nz >= nz && new_nz <= nzmax ())
1892 std::copy_backward (data () + ui, data () + nz,
1893 data () + nz + rnz);
1894 std::copy_backward (ridx () + ui, ridx () + nz,
1895 ridx () + nz + rnz);
1899 std::copy_n (rhs.
data (), rnz, data () + li);
1910 std::copy_n (tmp.
data (), li, data ());
1911 std::copy_n (tmp.
ridx (), li, ridx ());
1914 std::copy_n (rhs.
data (), rnz, data () + li);
1918 std::copy (tmp.
data () + ui, tmp.
data () + nz,
1919 data () + li + rnz);
1920 std::copy (tmp.
ridx () + ui, tmp.
ridx () + nz,
1921 ridx () + li + rnz);
1935 else if (rhs.
nnz () == 0)
1943 if (li != nz && ri[li] == iidx)
1947 maybe_compress (
true);
1972 *
this = reshape (save_dims);
1978 if (rhs.
nnz () != 0)
1987 template <
typename T>
1994 assert (ndims () == 2);
2006 bool orig_zero_by_zero = (nr == 0 && nc == 0);
2008 if (orig_zero_by_zero || (idx_i.
length (nr) ==
n && idx_j.
length (nc) ==
m))
2013 if (orig_zero_by_zero)
2042 if (nrx != nr || ncx != nc)
2050 if (
n == 0 ||
m == 0)
2068 if (new_nz >= nz && new_nz <= nzmax ())
2075 std::copy_backward (data () + ui, data () + nz,
2077 std::copy_backward (ridx () + ui, ridx () + nz,
2083 std::copy_n (rhs.
data (), rnz, data () + li);
2084 std::copy_n (rhs.
ridx (), rnz, ridx () + li);
2088 assert (nnz () == new_nz);
2098 std::copy_n (tmp.
data (), li, data ());
2099 std::copy_n (tmp.
ridx (), li, ridx ());
2100 std::copy_n (tmp.
cidx () + 1, lb, cidx () + 1);
2103 std::copy_n (rhs.
data (), rnz, data () + li);
2104 std::copy_n (rhs.
ridx (), rnz, ridx () + li);
2109 std::copy (tmp.
data () + ui, tmp.
data () + nz,
2110 data () + li + rnz);
2111 std::copy (tmp.
ridx () + ui, tmp.
ridx () + nz,
2112 ridx () + li + rnz);
2114 tmp.
cidx () + ub + 1, new_nz - nz);
2116 assert (nnz () == new_nz);
2122 assign (idx_i, idx_j.
sorted (),
2137 xcidx (i+1) = tmp.
cidx (i+1) - tmp.
cidx (i);
2143 xcidx (j+1) = rhs.
cidx (i+1) - rhs.
cidx (i);
2148 xcidx (i+1) += xcidx (i);
2150 change_capacity (nnz ());
2162 std::copy_n (rhs.
data () + k, u - l, xdata () + l);
2163 std::copy_n (rhs.
ridx () + k, u - l, xridx () + l);
2169 std::copy_n (tmp.
data () + k, u - l, xdata () + l);
2170 std::copy_n (tmp.
ridx () + k, u - l, xridx () + l);
2179 assign (idx_i, rhs);
2206 else if (
m == 1 &&
n == 1)
2210 if (rhs.
nnz () != 0)
2216 && (
n == 1 ||
m == 1))
2218 assign (idx_i, idx_j, rhs.
transpose ());
2226 template <
typename T>
2234 template <
typename T>
2242 template <
typename T>
2251 if (
m.numel () < 1 || dim > 1)
2269 (
"Sparse<T>::sort: invalid MODE");
2283 for (i = 0; i < ns; i++)
2284 if (sparse_ascending_compare<T> (
static_cast<T
> (0), v[i]))
2289 for (i = 0; i < ns; i++)
2290 if (sparse_descending_compare<T> (
static_cast<T
> (0), v[i]))
2296 mridx[k] = k - ns + nr;
2308 template <
typename T>
2318 if (
m.numel () < 1 || dim > 1)
2334 indexed_sort.
set_compare (sparse_ascending_compare<T>);
2336 indexed_sort.
set_compare (sparse_descending_compare<T>);
2339 (
"Sparse<T>::sort: invalid MODE");
2356 sidx (offset + k) = k;
2363 indexed_sort.
sort (v, vi, ns);
2368 for (i = 0; i < ns; i++)
2369 if (sparse_ascending_compare<T> (
static_cast<T
> (0), v[i]))
2374 for (i = 0; i < ns; i++)
2375 if (sparse_descending_compare<T> (
static_cast<T
> (0), v[i]))
2383 if (ii < ns && mridx[ii] == k)
2386 sidx (offset + jj++) = k;
2391 sidx (k + offset) = vi[k];
2397 sidx (k - ns + nr + offset) = vi[k];
2398 mridx[k] = k - ns + nr;
2415 template <
typename T>
2423 if (nnr == 0 || nnc == 0)
2425 else if (nnr != 1 && nnc != 1)
2432 if (nnr > 0 && nnc > 0)
2441 if (
elem (i, i+k) != 0.)
2447 if (
elem (i-k, i) != 0.)
2453 if (
elem (i, i) != 0.)
2466 T tmp =
elem (i, i+k);
2478 T tmp =
elem (i-k, i);
2490 T tmp =
elem (i, i);
2541 d.xdata (i) = data (i);
2542 d.xridx (i) = j + roff;
2544 d.xcidx (j + coff + 1) = cidx (j+1);
2570 d.xdata (ii) = data (ii);
2571 d.xridx (ii++) = ir + roff;
2576 d.xcidx (i + coff + 1) = ii;
2588 template <
typename T>
2595 if (dim == -1 || dim == -2)
2601 (*current_liboctave_error_handler) (
"cat: invalid dimension");
2605 if (dim != 0 && dim != 1)
2606 (*current_liboctave_error_handler)
2607 (
"cat: invalid dimension for sparse concatenation");
2610 return sparse_list[0];
2614 if (! (dv.*concat_rule) (sparse_list[i].
dims (), dim))
2615 (*current_liboctave_error_handler) (
"cat: dimension mismatch");
2617 total_nz += sparse_list[i].
nnz ();
2652 rcum += spi.
rows ();
2668 if (sparse_list[i].isempty ())
2686 template <
typename T>
2710 template <
typename T>
2713 T (*read_fcn) (std::istream&))
2719 if (nr > 0 && nc > 0)
2741 std::string err_field;
2743 (*current_liboctave_error_handler)
2744 (
"invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT
": "
2745 "Symbols '%s' is not an integer format",
2746 i+1, err_field.c_str ());
2749 if (itmp < 0 || itmp >= nr)
2751 is.setstate (std::ios::failbit);
2753 (*current_liboctave_error_handler)
2754 (
"invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT
": "
2755 "row index = %" OCTAVE_IDX_TYPE_FORMAT
" out of range",
2759 if (jtmp < 0 || jtmp >= nc)
2761 is.setstate (std::ios::failbit);
2763 (*current_liboctave_error_handler)
2764 (
"invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT
": "
2765 "column index = %" OCTAVE_IDX_TYPE_FORMAT
" out of range",
2771 is.setstate (std::ios::failbit);
2773 (*current_liboctave_error_handler)
2774 (
"invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT
":"
2775 "column indices must appear in ascending order "
2776 "(%" OCTAVE_IDX_TYPE_FORMAT
" < %" OCTAVE_IDX_TYPE_FORMAT
")",
2779 else if (jtmp > jold)
2784 else if (itmp < iold)
2786 is.setstate (std::ios::failbit);
2788 (*current_liboctave_error_handler)
2789 (
"invalid sparse matrix: element %" OCTAVE_IDX_TYPE_FORMAT
": "
2790 "row indices must appear in ascending order in each column "
2791 "(%" OCTAVE_IDX_TYPE_FORMAT
" < %" OCTAVE_IDX_TYPE_FORMAT
")",
2798 tmp = read_fcn (is);
2804 a.
ridx (ii++) = itmp;
3012 template <
typename T>
3016 os << prefix <<
"rep address: " << rep <<
"\n"
3017 << prefix <<
"rep->nzmx: " << rep->nzmx <<
"\n"
3018 << prefix <<
"rep->nrows: " << rep->nrows <<
"\n"
3019 << prefix <<
"rep->ncols: " << rep->ncols <<
"\n"
3020 << prefix <<
"rep->data: " <<
static_cast<void *
> (rep->d) <<
"\n"
3021 << prefix <<
"rep->ridx: " <<
static_cast<void *
> (rep->r) <<
"\n"
3022 << prefix <<
"rep->cidx: " <<
static_cast<void *
> (rep->c) <<
"\n"
3023 << prefix <<
"rep->count: " << rep->count <<
"\n";
3026 #define INSTANTIATE_SPARSE(T, API) \
3027 template class API Sparse<T>; \
3028 template std::istream& \
3029 read_sparse_matrix<T> (std::istream& is, Sparse<T>& a, \
3030 T (*read_fcn) (std::istream&));
template class OCTAVE_API Array< octave_idx_type >
bool sparse_descending_compare(typename ref_param< T >::type a, typename ref_param< T >::type b)
static octave_idx_type lblookup(const octave_idx_type *ridx, octave_idx_type nr, octave_idx_type ri)
std::istream & read_sparse_matrix(std::istream &is, Sparse< T > &a, T(*read_fcn)(std::istream &))
bool sparse_ascending_compare(typename ref_param< T >::type a, typename ref_param< T >::type b)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
Array< T > as_matrix(void) const
Return the array as a matrix.
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
T & elem(octave_idx_type n)
Size of the specified dimension.
const T * data(void) const
Size of the specified dimension.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
Array< T > transpose(void) const
Size of the specified dimension.
const T * fortran_vec(void) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
const Array< octave_idx_type > & col_perm_vec(void) const
octave_idx_type rows(void) const
octave::refcount< octave_idx_type > count
bool indices_ok(void) const
void change_length(octave_idx_type nz)
void maybe_compress(bool remove_zeros)
T celem(octave_idx_type _r, octave_idx_type _c) const
T & elem(octave_idx_type _r, octave_idx_type _c)
bool any_element_is_nan(void) const
void change_capacity(octave_idx_type nz)
static Sparse< T > cat(int dim, octave_idx_type n, const Sparse< T > *sparse_list)
Sparse< T > transpose(void) const
octave_idx_type numel(void) const
Sparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
Array< T > array_value(void) const
Sparse< T > sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
octave_idx_type cols(void) const
static Sparse< T >::SparseRep * nil_rep(void)
octave_idx_type * xridx(void)
void resize1(octave_idx_type n)
Sparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
OCTAVE_NORETURN T range_error(const char *fcn, octave_idx_type n) const
void print_info(std::ostream &os, const std::string &prefix) const
void assign(const idx_vector &i, const Sparse< T > &rhs)
octave_idx_type * cidx(void)
Sparse< T > diag(octave_idx_type k=0) const
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type nzmax(void) const
Amount of storage for nonzero elements.
void resize(octave_idx_type r, octave_idx_type c)
Sparse< T >::SparseRep * rep
octave_idx_type rows(void) const
octave_idx_type columns(void) const
dim_vector dims(void) const
void delete_elements(const idx_vector &i)
octave_idx_type * xcidx(void)
Sparse< T > reshape(const dim_vector &new_dims) const
octave_idx_type compute_index(const Array< octave_idx_type > &ra_idx) const
Sparse< T > maybe_compress(bool remove_zeros=false)
Sparse< T > index(const idx_vector &i, bool resize_ok=false) const
octave_idx_type * ridx(void)
Sparse< T > & operator=(const Sparse< T > &a)
Vector representing the dimensions (size) of an Array.
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
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.
void resize(int n, int fill_value=0)
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
octave_idx_type ndims(void) const
Number of dimensions.
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
octave_idx_type safe_numel(void) const
The following function will throw a std::bad_alloc () exception if the requested size is larger than ...
const octave_idx_type * raw(void)
bool is_colon(void) const
idx_vector sorted(bool uniq=false) const
static const idx_vector colon
bool isvector(void) const
void copy_data(octave_idx_type *data) const
octave_idx_type length(octave_idx_type n=0) const
bool is_scalar(void) const
bool is_cont_range(octave_idx_type n, octave_idx_type &l, octave_idx_type &u) const
idx_vector complement(octave_idx_type n) const
dim_vector orig_dimensions(void) const
bool is_permutation(octave_idx_type n) const
bool is_range(void) const
Array< octave_idx_type > as_array(void) const
idx_vector inverse_permutation(octave_idx_type n) const
octave_idx_type increment(void) const
octave_idx_type extent(octave_idx_type n) const
bool is_colon_equiv(octave_idx_type n) const
virtual octave_idx_type numel(void) const
void set_compare(compare_fcn_type comp)
void sort(T *data, octave_idx_type nel)
if_then_else< is_class_type< T >::no, T, T const & >::result type
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
void mx_inline_add2(size_t n, R *r, const X *x)
void mx_inline_add(size_t n, R *r, const X *x, const Y *y)
void mx_inline_sub(size_t n, R *r, const X *x, const Y *y)
void err_del_index_out_of_range(bool is1d, octave_idx_type idx, octave_idx_type ext)
void err_invalid_resize(void)
void err_index_out_of_range(int nd, int dim, octave_idx_type idx, octave_idx_type ext, const dim_vector &dv)
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
octave_value::octave_value(const Array< char > &chm, char type) return retval
bool sparse_indices_ok(octave_idx_type *r, octave_idx_type *c, octave_idx_type nrows, octave_idx_type ncols, octave_idx_type nnz)
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)