26#if defined (HAVE_CONFIG_H)
94 int nargin = args.length ();
96 if (nargin < 1 || nargin > 2)
99 int dim = (nargin == 1 ? -1
100 : args(1).xint_value (
"all: DIM must be an integer")-1);
103 error (
"all: invalid dimension argument = %d", dim + 1);
105 return ovl (args(0).all (dim));
159 int nargin = args.length ();
161 if (nargin < 1 || nargin > 2)
164 int dim = (nargin == 1 ? -1
165 : args(1).xint_value (
"any: DIM must be an integer")-1);
168 error (
"any: invalid dimension argument = %d", dim + 1);
170 return ovl (args(0).any (dim));
210 if (args.length () != 2)
215 if (! args(0).isnumeric ())
218 if (! args(1).isnumeric ())
221 if (args(0).iscomplex () || args(1).iscomplex ())
222 error (
"atan2: not defined for complex numbers");
224 if (args(0).is_single_type () || args(1).is_single_type ())
226 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
227 retval = atan2f (args(0).float_value (), args(1).float_value ());
232 retval = binmap<float> (a0, a1, std::atan2,
"atan2");
237 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
238 retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
239 else if (args(0).issparse ())
243 retval = binmap<double> (m0, m1, std::atan2,
"atan2");
247 NDArray a0 = args(0).array_value ();
248 NDArray a1 = args(1).array_value ();
249 retval = binmap<double> (a0, a1, std::atan2,
"atan2");
342 retval = binmap<float> (a0, a1, std::hypot,
"hypot");
353 retval = binmap<double> (m0, m1, std::hypot,
"hypot");
359 retval = binmap<double> (a0, a1, std::hypot,
"hypot");
388 int nargin = args.length ();
396 retval =
do_hypot (args(0), args(1));
401 for (
int i = 1; i < nargin; i++)
402 retval =
do_hypot (retval, args(i));
447template <
typename T,
typename ET>
500 if (args.length () != 1)
506 retval =
ovl (args(0).
log2 ());
507 else if (args(0).is_single_type ())
509 if (args(0).isreal ())
518 else if (args(0).iscomplex ())
528 else if (args(0).isreal ())
537 else if (args(0).iscomplex ())
610 if (args.length () != 2)
615 if (! args(0).isnumeric ())
618 if (! args(1).isnumeric ())
621 if (args(0).iscomplex () || args(1).iscomplex ())
622 error (
"rem: not defined for complex numbers");
634 error (
"rem: cannot combine %s and %s",
635 args(0).class_name ().c_str (),
636 args(1).class_name ().c_str ());
640#define MAKE_INT_BRANCH(X) \
643 X##NDArray a0 = args(0).X##_array_value (); \
644 X##NDArray a1 = args(1).X##_array_value (); \
645 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
658#undef MAKE_INT_BRANCH
664 else if (args(0).is_single_type () || args(1).is_single_type ())
666 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
667 retval =
math::rem (args(0).float_value (), args(1).float_value ());
672 retval = binmap<float> (a0, a1, math::rem<float>,
"rem");
677 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
678 retval =
math::rem (args(0).scalar_value (), args(1).scalar_value ());
679 else if (args(0).issparse () || args(1).issparse ())
683 retval = binmap<double> (m0, m1, math::rem<double>,
"rem");
687 NDArray a0 = args(0).array_value ();
688 NDArray a1 = args(1).array_value ();
689 retval = binmap<double> (a0, a1, math::rem<double>,
"rem");
792 if (args.length () != 2)
797 if (! args(0).isnumeric ())
800 if (! args(1).isnumeric ())
803 if (args(0).iscomplex () || args(1).iscomplex ())
804 error (
"mod: not defined for complex numbers");
816 error (
"mod: cannot combine %s and %s",
817 args(0).class_name ().c_str (),
818 args(1).class_name ().c_str ());
822#define MAKE_INT_BRANCH(X) \
825 X##NDArray a0 = args(0).X##_array_value (); \
826 X##NDArray a1 = args(1).X##_array_value (); \
827 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
840#undef MAKE_INT_BRANCH
846 else if (args(0).is_single_type () || args(1).is_single_type ())
848 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
849 retval =
math::mod (args(0).float_value (), args(1).float_value ());
854 retval = binmap<float> (a0, a1, math::mod<float>,
"mod");
859 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
860 retval =
math::mod (args(0).scalar_value (), args(1).scalar_value ());
861 else if (args(0).issparse () || args(1).issparse ())
865 retval = binmap<double> (m0, m1, math::mod<double>,
"mod");
869 NDArray a0 = args(0).array_value ();
870 NDArray a1 = args(1).array_value ();
871 retval = binmap<double> (a0, a1, math::mod<double>,
"mod");
932#define DATA_REDUCTION(FCN) \
934 int nargin = args.length (); \
936 if (nargin < 1 || nargin > 2) \
939 octave_value retval; \
941 octave_value arg = args(0); \
943 int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
946 error (#FCN ": invalid dimension argument = %d", dim + 1); \
950 if (arg.issparse ()) \
952 SparseMatrix tmp = arg.sparse_matrix_value (); \
954 retval = tmp.FCN (dim); \
956 else if (arg.is_single_type ()) \
958 FloatNDArray tmp = arg.float_array_value (); \
960 retval = tmp.FCN (dim); \
964 NDArray tmp = arg.array_value (); \
966 retval = tmp.FCN (dim); \
969 else if (arg.iscomplex ()) \
971 if (arg.issparse ()) \
973 SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
975 retval = tmp.FCN (dim); \
977 else if (arg.is_single_type ()) \
979 FloatComplexNDArray tmp \
980 = arg.float_complex_array_value (); \
982 retval = tmp.FCN (dim); \
986 ComplexNDArray tmp = arg.complex_array_value (); \
988 retval = tmp.FCN (dim); \
992 err_wrong_type_arg (#FCN, arg); \
996DEFUN (cumprod, args, ,
1039DEFUN (cumsum, args, ,
1064 int nargin = args.length ();
1066 bool isnative =
false;
1067 bool isdouble =
false;
1069 if (nargin > 1 && args(nargin - 1).is_string ())
1071 std::string str = args(nargin - 1).string_value ();
1073 if (str ==
"native")
1075 else if (str ==
"double")
1078 error (
"cumsum: unrecognized string argument");
1083 if (nargin < 1 || nargin > 2)
1089 dim = args(1).int_value () - 1;
1091 error (
"cumsum: invalid dimension argument = %d", dim + 1);
1124#define MAKE_INT_BRANCH(X) \
1127 retval = arg.X ## _array_value ().cumsum (dim); \
1129 retval = arg.array_value ().cumsum (dim); \
1141#undef MAKE_INT_BRANCH
1148 retval = (cs != 0.0);
1156 retval = (cs != 0.0);
1222 int nargin = args.length ();
1224 if (nargin < 1 || nargin > 3)
1230 retval = args(0).
diag ();
1231 else if (nargin == 2)
1233 octave_idx_type k = args(1).xidx_type_value (
"diag: invalid argument K");
1235 retval = args(0).
diag (k);
1242 error (
"diag: V must be a vector");
1244 octave_idx_type m = args(1).xidx_type_value (
"diag: invalid dimension M");
1245 octave_idx_type n = args(2).xidx_type_value (
"diag: invalid dimension N");
1247 retval = arg0.
diag (m, n);
1352 int nargin = args.length ();
1354 bool isnative =
false;
1355 bool isdouble =
false;
1357 if (nargin > 1 && args(nargin - 1).is_string ())
1359 std::string str = args(nargin - 1).string_value ();
1361 if (str ==
"native")
1363 else if (str ==
"double")
1366 error (
"prod: unrecognized type argument '%s'", str.c_str ());
1371 if (nargin < 1 || nargin > 2)
1381 dim = args(1).int_value () - 1;
1383 error (
"prod: invalid dimension DIM = %d", dim + 1);
1413#define MAKE_INT_BRANCH(X) \
1416 retval = arg.X ## _array_value ().prod (dim); \
1418 retval = arg.array_value ().prod (dim); \
1430#undef MAKE_INT_BRANCH
1529 int n_args = args.
length ();
1530 for (
int i = 0; i < n_args; i++)
1531 if (args(i).
numel () != 1)
1537template <
typename TYPE,
typename T>
1543 int n_args = args.
length ();
1550 if (dim == -1 || dim == -2)
1558 for (
int j = 0; j < n_args; j++)
1562 result(j) = octave_value_extract<T> (args(j));
1569 for (
int j = 0; j < n_args; j++)
1573 array_list[j] = octave_value_extract<TYPE> (args(j));
1580template <
typename TYPE,
typename T>
1586 int n_args = args.
length ();
1589 for (
int j = 0; j < n_args; j++)
1593 sparse_list[j] = octave_value_extract<TYPE> (args(j));
1600template <
typename TYPE>
1606 single_type_concat<TYPE, typename TYPE::element_type> (result, args, dim);
1611template <
typename MAP>
1617 int n_args = args.
length ();
1620 for (
int j = 0; j < n_args; j++)
1624 map_list[j] = octave_value_extract<MAP> (args(j));
1636 single_type_concat_map<octave_scalar_map> (result, args, dim);
1638 single_type_concat_map<octave_map> (result, args, dim);
1668 error (ee,
"conversion from %s to %s failed", dtype.c_str (),
1672 if (result.
empty ())
1673 error (
"conversion from %s to %s failed", dtype.c_str (),
1686 error (
"no constructor for %s!", dtype.c_str ());
1696 error (ee,
"%s constructor failed for %s argument", dtype.c_str (),
1700 if (result.
empty ())
1701 error (
"%s constructor failed for %s argument", dtype.c_str (),
1712 const std::string& cattype,
int dim)
1736 error (ee,
"%s/%s method failed", dtype.c_str (), cattype.c_str ());
1740 error (
"%s/%s method did not return a value", dtype.c_str (),
1760 if (t1_type == dtype)
1770 std::string cname = tmp(0).class_name ();
1771 std::list<std::string> parents = tmp(0).parent_class_name_list ();
1789 int n_args = args.
length ();
1793 else if (n_args == 1)
1795 else if (n_args > 1)
1797 std::string result_type;
1799 bool all_strings_p =
true;
1800 bool all_sq_strings_p =
true;
1801 bool all_dq_strings_p =
true;
1802 bool all_real_p =
true;
1803 bool all_cmplx_p =
true;
1804 bool any_sparse_p =
false;
1805 bool any_cell_p =
false;
1806 bool any_class_p =
false;
1808 bool first_elem_is_struct =
false;
1810 for (
int i = 0; i < n_args; i++)
1814 result_type = args(i).class_name ();
1816 first_elem_is_struct = args(i).isstruct ();
1821 if (all_strings_p && ! args(i).is_string ())
1822 all_strings_p =
false;
1823 if (all_sq_strings_p && ! args(i).is_sq_string ())
1824 all_sq_strings_p =
false;
1825 if (all_dq_strings_p && ! args(i).is_dq_string ())
1826 all_dq_strings_p =
false;
1827 if (all_real_p && ! args(i).isreal ())
1829 if (all_cmplx_p && ! (args(i).iscomplex ()
1830 || args(i).isreal ()))
1831 all_cmplx_p =
false;
1832 if (! any_sparse_p && args(i).issparse ())
1833 any_sparse_p =
true;
1834 if (! any_cell_p && args(i).iscell ())
1836 if (! any_class_p && args(i).isobject ())
1840 if (any_cell_p && ! any_class_p && ! first_elem_is_struct)
1843 for (
int i = 0; i < n_args; i++)
1845 if (args(i).iscell ())
1846 args(j++) = args(i);
1849 if (args(i).isempty ())
1852 args(j++) =
Cell (args(i));
1863 else if (result_type ==
"double")
1868 retval = do_single_type_concat<SparseMatrix> (args, dim);
1870 retval = do_single_type_concat<SparseComplexMatrix> (args, dim);
1875 retval = do_single_type_concat<NDArray> (args, dim);
1877 retval = do_single_type_concat<ComplexNDArray> (args, dim);
1880 else if (result_type ==
"single")
1883 retval = do_single_type_concat<FloatNDArray> (args, dim);
1885 retval = do_single_type_concat<FloatComplexNDArray> (args, dim);
1887 else if (result_type ==
"char")
1889 char type = (all_dq_strings_p ?
'"' :
'\'');
1891 if (! all_strings_p)
1893 "numeric", result_type);
1897 charNDArray result = do_single_type_concat<charNDArray> (args, dim);
1901 else if (result_type ==
"logical")
1904 retval = do_single_type_concat<SparseBoolMatrix> (args, dim);
1906 retval = do_single_type_concat<boolNDArray> (args, dim);
1908 else if (result_type ==
"int8")
1909 retval = do_single_type_concat<int8NDArray> (args, dim);
1910 else if (result_type ==
"int16")
1911 retval = do_single_type_concat<int16NDArray> (args, dim);
1912 else if (result_type ==
"int32")
1913 retval = do_single_type_concat<int32NDArray> (args, dim);
1914 else if (result_type ==
"int64")
1915 retval = do_single_type_concat<int64NDArray> (args, dim);
1916 else if (result_type ==
"uint8")
1917 retval = do_single_type_concat<uint8NDArray> (args, dim);
1918 else if (result_type ==
"uint16")
1919 retval = do_single_type_concat<uint16NDArray> (args, dim);
1920 else if (result_type ==
"uint32")
1921 retval = do_single_type_concat<uint32NDArray> (args, dim);
1922 else if (result_type ==
"uint64")
1923 retval = do_single_type_concat<uint64NDArray> (args, dim);
1924 else if (result_type ==
"cell")
1925 retval = do_single_type_concat<Cell> (args, dim);
1926 else if (result_type ==
"struct")
1936 if (dim == -1 || dim == -2)
1942 for (
int i = 1; i < args.
length (); i++)
1944 if (! (dv.*concat_rule) (args(i).dims (), dim))
1945 error (
"cat: dimension mismatch");
1966 int dv_len = dv.
ndims ();
1969 for (
int j = 0; j < n_args; j++)
1981 error (
"%s: indexing error", fname.c_str ());
1986 ra_idx(dim) += (dim < dv_tmp.
ndims () ? dv_tmp(dim) : 1);
1997DEFUN (horzcat, args, ,
2012 return do_cat (args, -2,
"horzcat");
2236DEFUN (vertcat, args, ,
2251 return do_cat (args, -1,
"vertcat");
2306 if (args.length () == 0)
2309 int dim = args(0).xint_value (
"cat: DIM must be an integer") - 1;
2312 error (
"cat: DIM must be a valid dimension");
2314 return ovl (
do_cat (args.slice (1, args.length () - 1), dim,
"cat"));
2469 if (args.
length () != 2 || args(1).length () < args(1).ndims ())
2472 Array<int> vec = args(1).int_vector_value ();
2476 int n = vec.
numel ();
2477 for (
int i = 0; i < n; i++)
2483DEFUN (permute, args, ,
2516DEFUN (ipermute, args, ,
2535DEFUN (length, args, ,
2547 if (args.length () != 1)
2550 return ovl (args(0).length ());
2553DEFUN (ndims, args, ,
2571 if (args.length () != 1)
2581 while ((ndims > 2) && (sz(ndims - 1) == 1))
2636 int nargin = args.length ();
2644 retval = args(0).
numel ();
2645 else if (nargin > 1)
2649 retval =
dims_to_numel (args(0).dims (), args.slice (1, nargin-1));
2655DEFUN (size, args, nargout,
2717 int nargin = args.length ();
2727 int ndims = dimensions.
ndims ();
2733 dimensions = dimensions.
redim (nargout);
2734 ndims = dimensions.
ndims ();
2740 m(i) = dimensions(i);
2751 query_dims(i) = args(i+1).idx_type_value (
true);
2754 query_dims = args(1).octave_idx_type_vector_value (
true);
2756 if (nargout > 1 && nargout != query_dims.
numel ())
2757 error (
"size: nargout > 1 but does not match number of requested dimensions");
2768 error (
"size: requested dimension DIM (= %"
2769 OCTAVE_IDX_TYPE_FORMAT
") out of range", nd);
2771 m(i) = nd <= ndims ? dimensions (nd-1) : 1;
2864DEFUN (size_equal, args, ,
2874 int nargin = args.length ();
2880 for (
int i = 1; i < nargin; ++i)
2884 if (a_dims != b_dims)
2899 if (args.length () != 1)
2902 return ovl (args(0).nnz ());
2921DEFUN (nzmax, args, ,
2935 if (args.length () != 1)
2938 return ovl (args(0).nzmax ());
2949 if (args.length () != 1)
2985DEFUN (columns, args, ,
2993 if (args.length () != 1)
3041 int nargin = args.length ();
3043 bool isnative =
false;
3044 bool isdouble =
false;
3045 bool isextra =
false;
3047 if (nargin > 1 && args(nargin - 1).is_string ())
3049 std::string str = args(nargin - 1).string_value ();
3051 if (str ==
"native")
3053 else if (str ==
"double")
3055 else if (str ==
"extra")
3058 error (
"sum: unrecognized type argument '%s'", str.c_str ());
3063 if (nargin < 1 || nargin > 2)
3069 dim = args(1).int_value () - 1;
3071 error (
"sum: invalid dimension DIM = %d", dim + 1);
3083 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3096 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3106 if (isdouble || isextra)
3113 if (isdouble || isextra)
3119#define MAKE_INT_BRANCH(X) \
3122 retval = arg.X ## _array_value ().sum (dim); \
3124 retval = arg.X ## _array_value ().dsum (dim); \
3136#undef MAKE_INT_BRANCH
3232DEFUN (sumsq, args, ,
3272DEFUN (islogical, args, ,
3280 if (args.length () != 1)
3283 return ovl (args(0).islogical ());
3312 if (args.length () != 1)
3360DEFUN (iscomplex, args, ,
3367 if (args.length () != 1)
3370 return ovl (args(0).iscomplex ());
3390DEFUN (isfloat, args, ,
3399 if (args.length () != 1)
3402 return ovl (args(0).isfloat ());
3408DEFUN (complex, args, ,
3432 int nargin = args.length ();
3434 if (nargin < 1 || nargin > 2)
3455 if (arg.
numel () == 1)
3470 if (arg.
numel () == 1)
3495 if (re.
numel () == 1)
3498 if (re_val.
nnz () == 0)
3510 i < im_val.
cidx (j + 1); i++)
3511 result.
data (im_val.
ridx (i) + off)
3517 else if (im.
numel () == 1)
3520 if (im_val.
nnz () == 0)
3533 i < re_val.
cidx (j + 1); i++)
3534 result.
data (re_val.
ridx (i) + off)
3542 if (re_val.
dims () != im_val.
dims ())
3543 error (
"complex: dimension mismatch");
3553 if (re.
numel () == 1)
3557 if (im.
numel () == 1)
3582 if (im.
numel () == 1)
3599 if (re_val.
dims () != im_val.
dims ())
3600 error (
"complex: dimension mismatch");
3614 else if (re.
numel () == 1)
3618 if (im.
numel () == 1)
3641 if (im.
numel () == 1)
3656 if (re_val.
dims () != im_val.
dims ())
3657 error (
"complex: dimension mismatch");
3715DEFUN (isreal, args, ,
3725 if (args.length () != 1)
3728 return ovl (args(0).isreal ());
3731DEFUN (isempty, args, ,
3739 if (args.length () != 1)
3742 return ovl (args(0).isempty ());
3750DEFUN (isnumeric, args, ,
3761 if (args.length () != 1)
3764 return ovl (args(0).isnumeric ());
3783DEFUN (isscalar, args, ,
3793 if (args.length () != 1)
3800 return ovl (sz.
numel () == 2 && sz(0) == 1 && sz(1) == 1);
3833 if (args.length () != 1)
3840 return ovl (sz.
numel () == 2 && (sz(0) == 1 || sz(1) == 1));
3863DEFUN (isrow, args, ,
3873 if (args.length () != 1)
3880 return ovl (sz.
numel () == 2 && sz(0) == 1);
3912DEFUN (iscolumn, args, ,
3922 if (args.length () != 1)
3929 return ovl (sz.
numel () == 2 && sz(1) == 1);
3961DEFUN (ismatrix, args, ,
3972 if (args.length () != 1)
3979 return ovl (sz.
numel () == 2 && sz(0) >= 0 && sz(1) >= 0);
4010DEFUN (issquare, args, ,
4020 if (args.length () != 1)
4027 return ovl (sz.
numel () == 2 && sz(0) == sz(1));
4056 int nargin = args.
length ();
4061 bool issparse =
false;
4062 bool iscomplex =
false;
4064 if (nargin > 0 && args(nargin-1).is_string ())
4066 std::string nm = args(nargin-1).string_value ();
4072 if (nargin > 1 && args(nargin-2).is_string ()
4073 && args(nargin-2).string_value () ==
"like")
4075 std::string nm = args(nargin-1).class_name ();
4076 issparse = args(nargin-1).issparse ();
4077 iscomplex = args(nargin-1).iscomplex ();
4095 for (
int i = 0; i < nargin; i++)
4096 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4113 if (dims.
ndims () > 2)
4114 error (
"%s: sparse ND arrays not supported.", fcn);
4122 retval =
SparseMatrix (dims(0), dims(1),
static_cast<double> (val));
4131 error (
"%s: invalid class name for sparse", fcn);
4191 error (
"%s: invalid class name", fcn);
4204 int nargin = args.
length ();
4209 bool issparse =
false;
4210 bool iscomplex =
false;
4212 if (nargin > 0 && args(nargin-1).is_string ())
4214 std::string nm = args(nargin-1).string_value ();
4220 if (nargin > 1 && args(nargin-2).is_string ()
4221 && args(nargin-2).string_value () ==
"like"
4222 && (std::string(fcn) ==
"Inf"
4223 || std::string(fcn) ==
"NaN" || std::string(fcn) ==
"NA"))
4225 if (! args(nargin-1).isfloat ())
4226 error (
"%s: input followed by 'like' must be floating point", fcn);
4227 std::string nm = args(nargin-1).class_name ();
4228 issparse = args(nargin-1).issparse ();
4229 iscomplex = args(nargin-1).iscomplex ();
4247 for (
int i = 0; i < nargin; i++)
4248 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4262 if (dims.
ndims () > 2)
4263 error (
"%s: sparse ND arrays not supported", fcn);
4268 retval =
SparseMatrix (dims(0), dims(1),
static_cast<double> (val));
4290 error (
"%s: invalid class name", fcn);
4302 int nargin = args.
length ();
4308 if (nargin > 0 && args(nargin-1).is_string ())
4310 std::string nm = args(nargin-1).string_value ();
4329 for (
int i = 0; i < nargin; i++)
4330 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4345 retval =
FloatNDArray (dims,
static_cast<float> (val));
4353 error (
"%s: invalid class name", fcn);
4366 int nargin = args.
length ();
4372 if (nargin > 0 && args(nargin-1).is_string ())
4374 std::string nm = args(nargin-1).string_value ();
4393 for (
int i = 0; i < nargin; i++)
4394 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4418 error (
"%s: invalid class name", fcn);
4430 int nargin = args.
length ();
4437 if (nargin > 0 && args(nargin-1).is_string ())
4439 std::string nm = args(nargin-1).string_value ();
4443 error (
"%s: invalid data type '%s'", fcn, nm.c_str ());
4446 bool issparse =
false;
4448 if (nargin > 1 && args(nargin-2).is_string ()
4449 && args(nargin-2).string_value () ==
"like")
4451 if (! args(nargin-1).islogical ())
4452 error (R
"(%s: input followed by "like" must be logical)", fcn);
4454 issparse = args(nargin-1).issparse ();
4471 for (
int i = 0; i < nargin; i++)
4472 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4486 if (dims.
ndims () > 2)
4487 error (
"%s: sparse ND arrays not supported", fcn);
4585DEFUN (zeros, args, ,
4834 double e_val = exp (1.0);
4840template <
typename T>
4844 T epsval =
x.abs ();
4845 typedef typename T::value_type P;
4848 P val = epsval.xelem (i);
4852 epsval(i) = std::numeric_limits<P>::denorm_min ();
4857 const P digits = std::numeric_limits<P>::digits;
4858 epsval(i) =
std::pow (
static_cast<P
> (2.0),
4859 static_cast<P
> (exponent - digits));
4902 if (args.length () == 1 && ! args(0).is_string ())
4916 error (
"eps: X must be of a floating point type");
4919 retval =
fill_matrix (args, std::numeric_limits<double>::epsilon (),
4920 std::numeric_limits<float>::epsilon (),
"eps");
4990 double pi_val = M_PI;
4992 double pi_val = 4.0 *
atan (1.0);
4998DEFUN (realmax, args, ,
5037DEFUN (realmin, args, ,
5161DEFUN (
false, args, ,
5225template <
typename MT>
5231 typename MT::element_type one (1);
5233 if (nr == 1 && nc == 1)
5239 typename MT::element_type zero (0);
5243 if (nr > 0 && nc > 0)
5247 for (
int i = 0; i < n; i++)
5257#define INSTANTIATE_EYE(T) \
5258 template octave_value identity_matrix<T> (int, int)
5327 error (
"eye: invalid class name");
5334#undef INT_EYE_MATRIX
5386 int nargin = args.length ();
5392 if (nargin > 0 && args(nargin-1).is_string ())
5394 std::string nm = args(nargin-1).string_value ();
5407 else if (nargin == 1)
5442template <
typename MT>
5447 typedef typename MT::column_vector_type CVT;
5448 typedef typename MT::element_type T;
5454 T bs = octave_value_extract<T> (base);
5457 T ls = octave_value_extract<T> (limit);
5462 CVT lv = octave_value_extract<CVT> (limit);
5463 CVT bv (lv.numel (), bs);
5469 CVT bv = octave_value_extract<CVT> (base);
5472 T ls = octave_value_extract<T> (limit);
5473 CVT lv (bv.numel (), ls);
5478 CVT lv = octave_value_extract<CVT> (limit);
5509 int nargin = args.length ();
5511 if (nargin != 2 && nargin != 3)
5524 error (
"linspace: N must be a scalar");
5534 bool isvector1 = sz1.
ndims () == 2 && (sz1(0) == 1 || sz1(1) == 1);
5536 bool isvector2 = sz2.
ndims () == 2 && (sz2(0) == 1 || sz2(1) == 1);
5538 if (! isvector1 || ! isvector2)
5539 error (
"linspace: START, END must be scalars or vectors");
5546 retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
5548 retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
5553 retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
5555 retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
5663DEFUN (resize, args, ,
5710 int nargin = args.length ();
5720 int ndim = vec.
numel ();
5731 for (
int i = 0; i < ndim; i++)
5734 retval = retval.
resize (dv,
true);
5745 retval = retval.
resize (dv,
true);
5753DEFUN (reshape, args, ,
5787 int nargin = args.length ();
5800 if (new_size.
numel () < 2)
5801 error (
"reshape: SIZE must have 2 or more dimensions");
5807 if (new_size(i) < 0)
5808 error (
"reshape: SIZE must be non-negative");
5810 new_dims(i) = new_size(i);
5818 for (
int i = 1; i < nargin; i++)
5820 if (args(i).isempty ())
5823 error (
"reshape: only a single dimension can be unknown");
5830 new_dims(i-1) = args(i).idx_type_value ();
5832 if (new_dims(i-1) < 0)
5833 error (
"reshape: SIZE must be non-negative");
5842 new_dims(empty_dim-1) = 0;
5848 if (a_nel != size_empty_dim * nel)
5849 error (
"reshape: SIZE is not divisible by the product of "
5850 "known dimensions (= %" OCTAVE_IDX_TYPE_FORMAT
")",
5853 new_dims(empty_dim-1) = size_empty_dim;
5858 retval = args(0).
reshape (new_dims);
5902 int nargin = args.length ();
5904 if (nargin < 1 || nargin > 2)
5910 dim = args(1).idx_type_value ();
5913 error (
"vec: DIM must be greater than zero");
5925 for (
int i = 0; i < dim-1; i++)
5928 new_dims(dim-1) = retval.
numel ();
5930 retval = retval.
reshape (new_dims);
5951DEFUN (squeeze, args, ,
5961 if (args.length () != 1)
5964 return ovl (args(0).squeeze ());
5975 if (args.length () != 1)
5978 return ovl (args(0).full_value ());
6044 int nargin = args.length ();
6046 if (nargin < 1 || nargin > 3)
6051 if (x_arg.
ndims () != 2)
6052 error (
"norm: only valid for 2-D objects");
6054 enum {sfmatrix, sfcols, sfrows, sffrob, sfinf, sfneginf} strflag = sfmatrix;
6055 if (nargin > 1 && args(nargin-1).is_string ())
6057 std::string str = args(nargin-1).string_value ();
6058 std::transform (str.begin (), str.end (), str.begin (), tolower);
6059 if (str ==
"cols" || str ==
"columns")
6061 else if (str ==
"rows")
6063 else if (str ==
"fro")
6065 else if (str ==
"inf")
6067 else if (str ==
"-inf")
6070 error (
"norm: unrecognized option: %s", str.c_str ());
6083 std::transform (str.begin (), str.end (), str.begin (), tolower);
6084 if (strflag != sfcols && strflag != sfrows)
6085 error (
"norm: invalid combination of options");
6087 if (str ==
"cols" || str ==
"columns" || str ==
"rows")
6088 error (
"norm: invalid combination of options");
6092 else if (str ==
"inf")
6094 else if (str ==
"-inf")
6097 error (
"norm: unrecognized option: %s", str.c_str ());
6107 retval =
xnorm (x_arg, p_arg);
6245DEFUN (uplus, args, ,
6255DEFUN (uminus, args, ,
6297DEFUN (ctranspose, args, ,
6336 return binary_op (op, args(0), args(1));
6344 int nargin = args.
length ();
6352 retval =
binary_op (op, args(0), args(1));
6355 retval =
binary_op (op, args(0), args(1));
6357 for (
int i = 2; i < nargin; i++)
6358 retval.
assign (aop, args(i));
6395DEFUN (minus, args, ,
6405DEFUN (mtimes, args, ,
6426DEFUN (mrdivide, args, ,
6441DEFUN (mpower, args, ,
6453DEFUN (mldivide, args, ,
6532DEFUN (times, args, ,
6553DEFUN (rdivide, args, ,
6565DEFUN (power, args, ,
6583DEFUN (ldivide, args, ,
6638DEFUN (colon, args, ,
6651 int nargin = args.length ();
6653 if (nargin < 2 || nargin > 3)
6658 :
colon_op (args(0), args(1), args(2)));
6663DEFUN (tic, args, nargout,
6715 if (args.length () != 0)
6716 warning (
"tic: ignoring extra arguments");
6725 double frac = std::modf (tmp, &ip);
6726 uint64_t microsecs =
static_cast<uint64_t
> (CLOCKS_PER_SEC * frac);
6727 microsecs += CLOCKS_PER_SEC *
static_cast<uint64_t
> (ip);
6736DEFUN (toc, args, nargout,
6754 int nargin = args.length ();
6763 octave_uint64 id = args(0).xuint64_scalar_value (
"toc: invalid ID");
6765 uint64_t val =
id.
value ();
6768 = (
static_cast<double> (val / CLOCKS_PER_SEC)
6769 +
static_cast<double> (val % CLOCKS_PER_SEC)
6777 error (
"toc: function called before timer initialization with tic()");
6781 double etime = now.double_value () - start_time;
6787 octave_stdout <<
"Elapsed time is " << etime <<
" seconds.\n";
6799DEFUN (cputime, args, ,
6818 if (args.length () != 0)
6821 sys::cpu_time cpu_tm;
6823 double usr = cpu_tm.user ();
6824 double sys = cpu_tm.system ();
6826 return ovl (usr + sys, usr, sys);
6829DEFUN (sort, args, nargout,
6899 int nargin = args.length ();
6901 if (nargin < 1 || nargin > 3)
6905 bool return_idx = (nargout > 1);
6906 bool have_sortmode = (nargin > 1 && args(1).is_string ());
6914 std::string mode = args(1).string_value ();
6915 if (mode ==
"ascend")
6917 else if (mode ==
"descend")
6920 error (R
"(sort: MODE must be either "ascend" or "descend")");
6923 dim = args(1).nint_value () - 1;
6929 error (
"sort: DIM must be a valid dimension");
6931 std::string mode = args(2).xstring_value (
"sort: MODE must be a string");
6933 if (mode ==
"ascend")
6935 else if (mode ==
"descend")
6938 error (R
"(sort: MODE must be either "ascend" or "descend")");
6942 if (nargin == 1 || have_sortmode)
6949 error (
"sort: DIM must be a valid dimension");
6960 retval(0) = arg.
sort (sidx, dim, smode);
6964 retval =
ovl (arg.
sort (dim, smode));
7151DEFUN (__sort_rows_idx__, args, ,
7157 int nargin = args.length ();
7159 if (nargin < 1 || nargin > 2)
7162 if (nargin == 2 && ! args(1).is_string ())
7163 error (
"__sort_rows_idx__: second argument must be a string");
7168 std::string mode = args(1).string_value ();
7169 if (mode ==
"ascend")
7171 else if (mode ==
"descend")
7174 error (R
"(__sort_rows_idx__: MODE must be either "ascend" or "descend")");
7180 error (
"__sort_rows_idx__: sparse matrices not yet supported");
7182 if (arg.
ndims () != 2)
7183 error (
"__sort_rows_idx__: needs a 2-D object");
7199 std::string mode = arg.
xstring_value (
"issorted: MODE must be a string");
7201 if (mode ==
"ascend")
7203 else if (mode ==
"descend")
7205 else if (mode ==
"either")
7208 error (R
"(issorted: MODE must be "ascend", "descend", or "either")");
7213DEFUN (issorted, args, ,
7231 int nargin = args.length ();
7233 if (nargin < 1 || nargin > 3)
7236 bool by_rows =
false;
7245 std::string tmp = args(1).xstring_value (
"issorted: second argument must be a string");
7261 error (
"issorted: sparse matrices not yet supported");
7263 if (arg.
ndims () != 2)
7264 error (
"issorted: A must be a 2-D object");
7271 error (
"issorted: needs a vector");
7342DEFUN (nth_element, args, ,
7366 int nargin = args.length ();
7368 if (nargin < 2 || nargin > 3)
7374 dim = args(2).int_value (
true) - 1;
7376 error (
"nth_element: DIM must be a valid dimension");
7404#define MAKE_INT_BRANCH(X) \
7406 retval = argx.X ## _array_value ().nth_element (n, dim); \
7419#undef MAKE_INT_BRANCH
7428 catch (
const index_exception& ie)
7430 error (
"nth_element: invalid index %s", ie.what ());
7451template <
typename NDT>
7456 typedef typename NDT::element_type T;
7459 else if (idx.
extent (n) > n)
7460 error (
"accumarray: index out of range");
7464 if (vals.numel () == 1)
7465 retval.idx_add (idx, vals (0));
7466 else if (vals.numel () == idx.
length (n))
7467 retval.idx_add (idx, vals);
7469 error (
"accumarray: dimensions mismatch");
7474DEFUN (__accumarray_sum__, args, ,
7480 int nargin = args.length ();
7482 if (nargin < 2 || nargin > 3)
7485 if (! args(0).isnumeric ())
7486 error (
"__accumarray_sum__: first argument must be numeric");
7495 n = args(2).idx_type_value (
true);
7502 if (r.increment () == 0)
7527 catch (
const index_exception& ie)
7529 error (
"__accumarray_sum__: invalid index %s", ie.what ());
7535template <
typename NDT>
7539 const typename NDT::element_type& zero_val)
7541 typedef typename NDT::element_type T;
7544 else if (idx.
extent (n) > n)
7545 error (
"accumarray: index out of range");
7554 if (vals.numel () == 1)
7555 (retval.*op) (idx, NDT (
dim_vector (l, 1), vals(0)));
7556 else if (vals.numel () == l)
7557 (retval.*op) (idx, vals);
7559 error (
"accumarray: dimensions mismatch");
7568 int nargin = args.
length ();
7570 if (nargin < 3 || nargin > 4)
7573 if (! args(0).isnumeric ())
7574 error (
"accumarray: first argument must be numeric");
7583 n = args(3).idx_type_value (
true);
7612#define MAKE_INT_BRANCH(X) \
7614 retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
7615 n, ismin, zero.X ## _scalar_value ()); \
7627#undef MAKE_INT_BRANCH
7638 catch (
const index_exception& ie)
7640 error (
"do_accumarray_minmax_fun: invalid index %s", ie.what ());
7646DEFUN (__accumarray_min__, args, ,
7655DEFUN (__accumarray_max__, args, ,
7664template <
typename NDT>
7669 typedef typename NDT::element_type T;
7672 else if (idx.
extent (n) > n)
7673 error (
"accumdim: index out of range");
7680 else if (dim >= rdv.
ndims ())
7685 NDT retval (rdv, T ());
7687 if (idx.
length () != vals_dim(dim))
7688 error (
"accumdim: dimension mismatch");
7690 retval.idx_add_nd (idx, vals, dim);
7695DEFUN (__accumdim_sum__, args, ,
7701 int nargin = args.length ();
7703 if (nargin < 2 || nargin > 4)
7706 if (! args(0).isnumeric ())
7707 error (
"__accumdim_sum__: first argument must be numeric");
7716 dim = args(2).int_value () - 1;
7720 n = args(3).idx_type_value (
true);
7745 catch (
const index_exception& ie)
7747 error (
"__accumdim_sum__: invalid index %s", ie.what ());
7753template <
typename NDT>
7756 const NDT& tval,
const NDT& fval)
7758 typedef typename NDT::element_type T;
7762 bool tscl = tval.numel () == 1;
7763 bool fscl = fval.numel () == 1;
7765 if ((! tscl && tval.dims () != dv) || (! fscl && fval.dims () != dv))
7766 error (
"merge: MASK, TVAL, and FVAL dimensions must match");
7768 T *rv = retval.fortran_vec ();
7771 const T *tv = tval.data ();
7772 const T *fv = fval.data ();
7773 const bool *mv = mask.
data ();
7782 rv[i] = (mv[i] ? ts : fs);
7788 rv[i] = (mv[i] ? ts : fv[i]);
7797 rv[i] = (mv[i] ? tv[i] : fs);
7802 rv[i] = (mv[i] ? tv[i] : fv[i]);
7809#define MAKE_INT_BRANCH(INTX) \
7810 else if (tval.is_ ## INTX ## _type () && fval.is_ ## INTX ## _type ()) \
7812 retval = do_merge (mask, \
7813 tval.INTX ## _array_value (), \
7814 fval.INTX ## _array_value ()); \
7817DEFUN (merge, args, ,
7846 if (args.length () != 3)
7849 if (! (args(0).islogical () || args(0).isnumeric ()))
7850 error (
"merge: first argument must be logical or numeric");
7857 retval = (mask_val.
is_true () ? args(1) : args(2));
7893 sq_string ?
'\'' :
'"');
7912 error (
"merge: cannot merge %s with %s with array mask",
7922#undef MAKE_INT_BRANCH
7924template <
typename SparseT>
7929 SparseT retval = array;
7933 while (order > 0 && k > 0)
7935 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7936 retval = SparseT (retval.index (col1, sl1))
7937 - SparseT (retval.index (col2, sl2));
7938 assert (retval.columns () == k-1);
7946 while (order > 0 && k > 0)
7948 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7949 retval = SparseT (retval.index (sl1, col1))
7950 - SparseT (retval.index (sl2, col2));
7951 assert (retval.rows () == k-1);
7972 if (dv(dim) <= order)
7981 if (dim == dv.
ndims ())
7983 retval =
do_diff (array, order, dim - 1);
7986 else if (dv(dim) == 1)
7990 retval =
do_diff (array, dv(dim) - 1, dim);
7991 order -= dv(dim) - 1;
8080 int nargin = args.length ();
8082 if (nargin < 1 || nargin > 3)
8085 if (! (args(0).isnumeric () || args(0).islogical ()))
8086 error (
"diff: X must be numeric or logical");
8092 if (args(1).is_scalar_type ())
8093 order = args(1).idx_type_value (
true,
false);
8094 else if (! args(1).is_zero_by_zero ())
8095 error (
"diff: order K must be a scalar or []");
8097 error (
"diff: order K must be non-negative");
8102 dim = args(2).int_value (
true,
false);
8103 if (dim < 1 || dim > args(0).ndims ())
8104 error (
"diff: DIM must be a valid dimension");
8109 return do_diff (args(0), order, dim);
8125template <
typename T>
8131 assert (rep.
ndims () == 2 && rep.
rows () == 2);
8139 error (
"repelems: second row must contain non-negative numbers");
8144 retval.
clear (1, l);
8150 std::fill_n (dest, k, src.
checkelem (rep(0, i) - 1));
8157DEFUN (repelems, args, ,
8183 if (args.length () != 2)
8188 const Matrix rm = args(1).matrix_value ();
8190 if (rm.
rows () != 2 || rm.
ndims () != 2)
8191 error (
"repelems: R must be a matrix with two rows");
8200 if (
static_cast<double> (rx) != rm(i))
8201 error (
"repelems: R must be a matrix of integers");
8206 switch (
x.builtin_type ())
8208#define BTYP_BRANCH(X, EX) \
8210 retval = do_repelems (x.EX ## _value (), r); \
8250 if (args.length () != 1)
8253 if (! args(0).isnumeric ())
8254 error (
"base64_encode: encoding is supported only for numeric arrays");
8256 if (args(0).iscomplex () || args(0).issparse ())
8257 error (
"base64_encode: encoding complex or sparse data is not supported");
8263#define MAKE_INT_BRANCH(X) \
8264 if (args(0).is_ ## X ## _type ()) \
8266 const X##NDArray in = args(0). X## _array_value (); \
8267 std::size_t inlen = in.numel () * sizeof (X## _t) / sizeof (char); \
8268 const char *inc = reinterpret_cast<const char *> (in.data ()); \
8270 if (base64_encode (inc, inlen, &out)) \
8272 retval(0) = octave_value (out); \
8286#undef MAKE_INT_BRANCH
8291 else if (args(0).is_single_type ())
8295 inlen = in.
numel () *
sizeof (
float) /
sizeof (
char);
8297 inc =
reinterpret_cast<const char *
> (in.
data ());
8309 inlen = in.
numel () *
sizeof (
double) /
sizeof (
char);
8311 inc =
reinterpret_cast<const char *
> (in.
data ());
8358 int nargin = args.length ();
8360 if (nargin < 1 || nargin > 2)
8363 std::string str = args(0).string_value ();
8372 = args(1).octave_idx_type_vector_value ();
8378 retval = retval.
reshape (dims);
8381 return ovl (retval);
8402DEFUN (__base64_decode_bytes__, args, ,
8414 int nargin = args.length ();
8416 if (nargin < 1 || nargin > 2)
8419 std::string str = args(0).string_value ();
8428 = args(1).octave_idx_type_vector_value ();
8434 retval = retval.
reshape (dims);
8437 return ovl (retval);
bool isvector(const dim_vector &dim)
ComplexMatrix linspace(const ComplexColumnVector &x1, const ComplexColumnVector &x2, octave_idx_type n)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
T & xelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_API void clear(void)
octave_idx_type numel(void) const
Number of elements in the array.
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.
octave_idx_type rows(void) const
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns(void) const
const T * data(void) const
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
int ndims(void) const
Size of the specified dimension.
OCTARRAY_API T & checkelem(octave_idx_type n)
Size of the specified dimension.
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().
OCTAVE_API ComplexNDArray prod(int dim=-1) const
OCTAVE_API ComplexNDArray cumsum(int dim=-1) const
OCTAVE_API ComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
OCTAVE_API ComplexNDArray xsum(int dim=-1) const
OCTAVE_API ComplexNDArray sum(int dim=-1) const
OCTAVE_API FloatComplexNDArray sum(int dim=-1) const
OCTAVE_API ComplexNDArray dsum(int dim=-1) const
OCTAVE_API FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
OCTAVE_API FloatComplexNDArray prod(int dim=-1) const
OCTAVE_API FloatComplexNDArray cumsum(int dim=-1) const
OCTAVE_API ComplexNDArray dprod(int dim=-1) const
OCTAVE_API FloatNDArray sum(int dim=-1) const
OCTAVE_API FloatNDArray prod(int dim=-1) const
OCTAVE_API NDArray dprod(int dim=-1) const
OCTAVE_API FloatNDArray cumsum(int dim=-1) const
OCTAVE_API NDArray dsum(int dim=-1) const
OCTAVE_API FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
Template for N-dimensional array classes with like-type math operators.
MArray< T > reshape(const dim_vector &new_dims) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
OCTAVE_API NDArray diff(octave_idx_type order=1, int dim=-1) const
OCTAVE_API NDArray cumsum(int dim=-1) const
OCTAVE_API NDArray prod(int dim=-1) const
OCTAVE_API NDArray xsum(int dim=-1) const
OCTAVE_API NDArray sum(int dim=-1) const
OCTAVE_API SparseBoolMatrix all(int dim=-1) const
OCTAVE_API SparseMatrix sum(int dim=-1) const
OCTAVE_API SparseBoolMatrix any(int dim=-1) const
OCTAVE_API SparseComplexMatrix prod(int dim=-1) const
OCTAVE_API SparseComplexMatrix sum(int dim=-1) const
OCTAVE_API SparseComplexMatrix cumsum(int dim=-1) const
OCTAVE_API SparseMatrix sum(int dim=-1) const
OCTAVE_API SparseMatrix prod(int dim=-1) const
OCTAVE_API SparseMatrix cumsum(int dim=-1) const
octave_idx_type rows(void) const
octave_idx_type nnz(void) const
Actual number of nonzero terms.
dim_vector dims(void) const
octave_idx_type * ridx(void)
octave_idx_type * cidx(void)
octave_idx_type cols(void) const
static OCTAVE_API Sparse< T, Alloc > cat(int dim, octave_idx_type n, const Sparse< T, Alloc > *sparse_list)
OCTAVE_API boolNDArray any(int dim=-1) const
OCTAVE_API boolNDArray all(int dim=-1) const
Vector representing the dimensions (size) of an Array.
OCTAVE_API bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
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)
static dim_vector alloc(int n)
bool isvector(void) const
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)
int first_non_singleton(int def=0) const
octave_idx_type ndims(void) const
Number of dimensions.
OCTAVE_API dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
OCTAVE_API intNDArray diff(octave_idx_type order=1, int dim=-1) const
static data_type string_to_data_type(const std::string &s)
octave_idx_type extent(octave_idx_type n) const
octave_idx_type length(octave_idx_type n=0) const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
octave_idx_type length(void) const
int32NDArray int32_array_value(void) const
bool iscellstr(void) const
boolNDArray bool_array_value(bool warn=false) const
uint16NDArray uint16_array_value(void) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool bool_value(bool warn=false) const
bool issparse(void) const
OCTINTERP_API std::string xstring_value(const char *fmt,...) const
OCTINTERP_API FloatComplexNDArray xfloat_complex_array_value(const char *fmt,...) const
bool is_uint16_type(void) const
builtin_type_t builtin_type(void) const
OCTINTERP_API FloatComplex xfloat_complex_value(const char *fmt,...) const
Complex complex_value(bool frc_str_conv=false) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
bool is_int8_type(void) const
octave_idx_type rows(void) const
bool isnumeric(void) const
octave_idx_type numel(void) const
octave_idx_type idx_type_value(bool req_int=false, bool frc_str_conv=false) const
bool is_scalar_type(void) const
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
bool is_string(void) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
bool is_defined(void) const
charNDArray char_array_value(bool frc_str_conv=false) const
bool isinteger(void) const
bool is_double_type(void) const
Cell cell_value(void) const
FloatComplex float_complex_value(bool frc_str_conv=false) const
std::string class_name(void) const
bool is_uint32_type(void) const
octave_idx_type columns(void) const
int8NDArray int8_array_value(void) const
OCTINTERP_API SparseComplexMatrix xsparse_complex_matrix_value(const char *fmt,...) const
bool is_int64_type(void) const
float float_value(bool frc_str_conv=false) const
int64NDArray int64_array_value(void) const
uint8NDArray uint8_array_value(void) const
octave_value reshape(const dim_vector &dv) const
double scalar_value(bool frc_str_conv=false) const
octave_value abs(void) const
OCTINTERP_API octave_value & assign(assign_op op, const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
std::string string_value(bool force=false) const
Array< std::string > cellstr_value(void) const
bool is_int32_type(void) const
bool is_uint64_type(void) const
bool is_int16_type(void) const
uint64NDArray uint64_array_value(void) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave::range< double > range_value(void) const
bool is_range(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
bool is_single_type(void) const
uint32NDArray uint32_array_value(void) const
sortmode issorted(sortmode mode=UNSORTED) const
bool isobject(void) const
bool is_sq_string(void) const
OCTINTERP_API ComplexNDArray xcomplex_array_value(const char *fmt,...) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
OCTINTERP_API octave_value single_subsref(const std::string &type, const octave_value_list &idx)
OCTINTERP_API Complex xcomplex_value(const char *fmt,...) const
octave_value resize(const dim_vector &dv, bool fill=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_uint8_type(void) const
int16NDArray int16_array_value(void) const
bool iscomplex(void) const
octave_value diag(octave_idx_type k=0) const
double double_value(bool frc_str_conv=false) const
bool islogical(void) const
dim_vector dims(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
octave_value find_method(const std::string &name, const std::string &dispatch_type)
#define INSTANTIATE_EYE(T)
static octave_map do_single_type_concat_map(const octave_value_list &args, int dim)
static octave_value attempt_type_conversion(const octave_value &ov, std::string dtype)
static octave_value binary_op_defun_body(octave_value::binary_op op, const octave_value_list &args)
template octave_value identity_matrix< int8NDArray >(int, int)
octave_value do_class_concat(const octave_value_list &ovl, const std::string &cattype, int dim)
static SparseT do_sparse_diff(const SparseT &array, octave_idx_type order, int dim)
template octave_value identity_matrix< uint64NDArray >(int, int)
template octave_value identity_matrix< int16NDArray >(int, int)
static octave_value do_diff(const octave_value &array, octave_idx_type order, int dim=-1)
static octave_value do_cat(const octave_value_list &xargs, int dim, std::string fname)
static octave_value_list do_accumarray_minmax_fun(const octave_value_list &args, bool ismin)
static octave_value unary_op_defun_body(octave_value::unary_op op, const octave_value_list &args)
#define BTYP_BRANCH(X, EX)
void map_2_xlog2(const Array< T > &x, Array< T > &f, Array< ET > &e)
static octave_value do_linspace(const octave_value &base, const octave_value &limit, octave_idx_type n)
static void single_type_concat_map(octave_map &result, const octave_value_list &args, int dim)
static NDT do_accumdim_sum(const idx_vector &idx, const NDT &vals, int dim=-1, octave_idx_type n=-1)
template octave_value identity_matrix< int64NDArray >(int, int)
template octave_value identity_matrix< int32NDArray >(int, int)
template octave_value identity_matrix< uint8NDArray >(int, int)
static bool all_scalar_1x1(const octave_value_list &args)
octave_value identity_matrix(int nr, int nc)
#define MAKE_INT_BRANCH(X)
static TYPE do_single_type_concat(const octave_value_list &args, int dim)
static octave_value binary_assoc_op_defun_body(octave_value::binary_op op, octave_value::assign_op aop, const octave_value_list &args)
template octave_value identity_matrix< uint16NDArray >(int, int)
#define DATA_REDUCTION(FCN)
static NDT do_accumarray_minmax(const idx_vector &idx, const NDT &vals, octave_idx_type n, bool ismin, const typename NDT::element_type &zero_val)
static NDT do_merge(const Array< bool > &mask, const NDT &tval, const NDT &fval)
static octave_value do_permute(const octave_value_list &args, bool inv)
static void single_type_concat(Array< T > &result, const octave_value_list &args, int dim)
static double tic_toc_timestamp
static octave_value fill_matrix(const octave_value_list &args, int val, const char *fcn)
static octave_value do_hypot(const octave_value &x, const octave_value &y)
static Array< T > do_repelems(const Array< T > &src, const Array< octave_idx_type > &rep)
template octave_value identity_matrix< boolNDArray >(int, int)
static sortmode get_sort_mode_option(const octave_value &arg)
template octave_value identity_matrix< uint32NDArray >(int, int)
static NDT do_accumarray_sum(const idx_vector &idx, const NDT &vals, octave_idx_type n=-1)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
void warning(const char *fmt,...)
void error(const char *fmt,...)
#define panic_impossible()
void err_wrong_type_arg(const char *name, const char *s)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
std::string get_dispatch_type(const octave_value_list &args, builtin_type_t &builtin_type)
double norm(const ColumnVector &v)
ColumnVector transform(const Matrix &m, double x, double y, double z)
octave::idx_vector idx_vector
intNDArray< octave_int16 > int16NDArray
intNDArray< octave_int32 > int32NDArray
intNDArray< octave_int64 > int64NDArray
intNDArray< octave_int8 > int8NDArray
double lo_ieee_inf_value(void)
double lo_ieee_na_value(void)
float lo_ieee_float_inf_value(void)
double lo_ieee_nan_value(void)
float lo_ieee_float_na_value(void)
float lo_ieee_float_nan_value(void)
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
class OCTAVE_API FloatDiagMatrix
class OCTAVE_API boolNDArray
class OCTAVE_API DiagMatrix
class OCTAVE_API SparseMatrix
class OCTAVE_API ComplexNDArray
class OCTAVE_API SparseComplexMatrix
class OCTAVE_API FloatComplexNDArray
class OCTAVE_API SparseBoolMatrix
class OCTAVE_API FloatNDArray
Complex atan(const Complex &x)
double frexp(double x, int *expptr)
Complex log2(const Complex &x)
std::string get_concat_class(const std::string &c1, const std::string &c2)
Array< double > base64_decode(const std::string &str)
bool base64_encode(const char *inc, const std::size_t inlen, char **out)
double xfrobnorm(const Matrix &x)
ColumnVector xrownorms(const Matrix &m, double p)
RowVector xcolnorms(const Matrix &m, double p)
intNDArray< octave_uint8 > base64_decode_bytes(const std::string &str)
double xnorm(const ColumnVector &x, double p)
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
symbol_table & __get_symbol_table__(const std::string &who)
std::complex< double > Complex
std::complex< float > FloatComplex
octave_int< uint64_t > octave_uint64
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
octave_int< T > rem(const octave_int< T > &x, const octave_int< T > &y)
octave_int< T > mod(const octave_int< T > &x, const octave_int< T > &y)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
T::size_type numel(const T &str)
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
OCTINTERP_API octave_value cat_op(type_info &ti, const octave_value &a, const octave_value &b, const Array< octave_idx_type > &ra_idx)
OCTINTERP_API octave_value colon_op(const octave_value &base, const octave_value &increment, const octave_value &limit, bool is_for_cmd_expr=false)
OCTAVE_NAMESPACE_BEGIN OCTINTERP_API octave_value unary_op(type_info &ti, octave_value::unary_op op, const octave_value &a)
OCTINTERP_API octave_value binary_op(type_info &ti, octave_value::binary_op op, const octave_value &a, const octave_value &b)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
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)
intNDArray< octave_uint16 > uint16NDArray
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint64 > uint64NDArray
intNDArray< octave_uint8 > uint8NDArray
static void check_dimensions(octave_idx_type &nr, octave_idx_type &nc, const char *warnfor)
octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx_arg)
void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)