26 #if defined (HAVE_CONFIG_H)
93 int nargin = args.length ();
95 if (nargin < 1 || nargin > 2)
98 int dim = (nargin == 1 ? -1
99 : args(1).xint_value (
"all: DIM must be an integer")-1);
102 error (
"all: invalid dimension argument = %d", dim + 1);
104 return ovl (args(0).all (dim));
158 int nargin = args.length ();
160 if (nargin < 1 || nargin > 2)
163 int dim = (nargin == 1 ? -1
164 : args(1).xint_value (
"any: DIM must be an integer")-1);
167 error (
"any: invalid dimension argument = %d", dim + 1);
169 return ovl (args(0).any (dim));
195 DEFUN (atan2, args, ,
209 if (args.length () != 2)
214 if (! args(0).isnumeric ())
217 if (! args(1).isnumeric ())
220 if (args(0).iscomplex () || args(1).iscomplex ())
221 error (
"atan2: not defined for complex numbers");
223 if (args(0).is_single_type () || args(1).is_single_type ())
225 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
226 retval = atan2f (args(0).float_value (), args(1).float_value ());
231 retval = binmap<float> (a0, a1, std::atan2,
"atan2");
236 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
237 retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
238 else if (args(0).issparse ())
242 retval = binmap<double> (m0, m1, std::atan2,
"atan2");
246 NDArray a0 = args(0).array_value ();
247 NDArray a1 = args(1).array_value ();
248 retval = binmap<double> (a0, a1, std::atan2,
"atan2");
341 retval = binmap<float> (a0, a1, std::hypot,
"hypot");
352 retval = binmap<double> (m0, m1, std::hypot,
"hypot");
358 retval = binmap<double> (a0, a1, std::hypot,
"hypot");
365 DEFUN (hypot, args, ,
387 int nargin = args.length ();
395 retval =
do_hypot (args(0), args(1));
400 for (
int i = 1; i < nargin; i++)
401 retval =
do_hypot (retval, args(i));
446 template <
typename T,
typename ET>
499 if (args.length () != 1)
505 retval =
ovl (args(0).
log2 ());
506 else if (args(0).is_single_type ())
508 if (args(0).isreal ())
517 else if (args(0).iscomplex ())
527 else if (args(0).isreal ())
536 else if (args(0).iscomplex ())
609 if (args.length () != 2)
614 if (! args(0).isnumeric ())
617 if (! args(1).isnumeric ())
620 if (args(0).iscomplex () || args(1).iscomplex ())
621 error (
"rem: not defined for complex numbers");
633 error (
"rem: cannot combine %s and %s",
634 args(0).class_name ().c_str (),
635 args(1).class_name ().c_str ());
639 #define MAKE_INT_BRANCH(X) \
642 X##NDArray a0 = args(0).X##_array_value (); \
643 X##NDArray a1 = args(1).X##_array_value (); \
644 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
657 #undef MAKE_INT_BRANCH
663 else if (args(0).is_single_type () || args(1).is_single_type ())
665 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
666 retval =
math::rem (args(0).float_value (), args(1).float_value ());
671 retval = binmap<float> (a0, a1, math::rem<float>,
"rem");
676 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
677 retval =
math::rem (args(0).scalar_value (), args(1).scalar_value ());
678 else if (args(0).issparse () || args(1).issparse ())
682 retval = binmap<double> (m0, m1, math::rem<double>,
"rem");
686 NDArray a0 = args(0).array_value ();
687 NDArray a1 = args(1).array_value ();
688 retval = binmap<double> (a0, a1, math::rem<double>,
"rem");
793 if (args.length () != 2)
798 if (! args(0).isnumeric ())
801 if (! args(1).isnumeric ())
804 if (args(0).iscomplex () || args(1).iscomplex ())
805 error (
"mod: not defined for complex numbers");
817 error (
"mod: cannot combine %s and %s",
818 args(0).class_name ().c_str (),
819 args(1).class_name ().c_str ());
823 #define MAKE_INT_BRANCH(X) \
826 X##NDArray a0 = args(0).X##_array_value (); \
827 X##NDArray a1 = args(1).X##_array_value (); \
828 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
841 #undef MAKE_INT_BRANCH
847 else if (args(0).is_single_type () || args(1).is_single_type ())
849 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
850 retval =
math::mod (args(0).float_value (), args(1).float_value ());
855 retval = binmap<float> (a0, a1, math::mod<float>,
"mod");
860 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
861 retval =
math::mod (args(0).scalar_value (), args(1).scalar_value ());
862 else if (args(0).issparse () || args(1).issparse ())
866 retval = binmap<double> (m0, m1, math::mod<double>,
"mod");
870 NDArray a0 = args(0).array_value ();
871 NDArray a1 = args(1).array_value ();
872 retval = binmap<double> (a0, a1, math::mod<double>,
"mod");
933 #define DATA_REDUCTION(FCN) \
935 int nargin = args.length (); \
937 if (nargin < 1 || nargin > 2) \
940 octave_value retval; \
942 octave_value arg = args(0); \
944 int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
947 error (#FCN ": invalid dimension argument = %d", dim + 1); \
951 if (arg.issparse ()) \
953 SparseMatrix tmp = arg.sparse_matrix_value (); \
955 retval = tmp.FCN (dim); \
957 else if (arg.is_single_type ()) \
959 FloatNDArray tmp = arg.float_array_value (); \
961 retval = tmp.FCN (dim); \
965 NDArray tmp = arg.array_value (); \
967 retval = tmp.FCN (dim); \
970 else if (arg.iscomplex ()) \
972 if (arg.issparse ()) \
974 SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
976 retval = tmp.FCN (dim); \
978 else if (arg.is_single_type ()) \
980 FloatComplexNDArray tmp \
981 = arg.float_complex_array_value (); \
983 retval = tmp.FCN (dim); \
987 ComplexNDArray tmp = arg.complex_array_value (); \
989 retval = tmp.FCN (dim); \
993 err_wrong_type_arg (#FCN, arg); \
997 DEFUN (cumprod, args, ,
1043 DEFUN (cumsum, args, ,
1068 int nargin = args.length ();
1070 bool isnative =
false;
1071 bool isdouble =
false;
1073 if (nargin > 1 && args(nargin - 1).is_string ())
1075 std::string str = args(nargin - 1).string_value ();
1077 if (str ==
"native")
1079 else if (str ==
"double")
1082 error (
"cumsum: unrecognized string argument");
1087 if (nargin < 1 || nargin > 2)
1093 dim = args(1).int_value () - 1;
1095 error (
"cumsum: invalid dimension argument = %d", dim + 1);
1128 #define MAKE_INT_BRANCH(X) \
1131 retval = arg.X ## _array_value ().cumsum (dim); \
1133 retval = arg.array_value ().cumsum (dim); \
1145 #undef MAKE_INT_BRANCH
1152 retval = (cs != 0.0);
1160 retval = (cs != 0.0);
1196 DEFUN (diag, args, ,
1229 int nargin = args.length ();
1231 if (nargin < 1 || nargin > 3)
1237 retval = args(0).
diag ();
1238 else if (nargin == 2)
1240 octave_idx_type k = args(1).xidx_type_value (
"diag: invalid argument K");
1242 retval = args(0).
diag (k);
1249 error (
"diag: V must be a vector");
1254 retval = arg0.
diag (
m,
n);
1347 DEFUN (prod, args, ,
1378 int nargin = args.length ();
1380 bool isnative =
false;
1381 bool isdouble =
false;
1383 if (nargin > 1 && args(nargin - 1).is_string ())
1385 std::string str = args(nargin - 1).string_value ();
1387 if (str ==
"native")
1389 else if (str ==
"double")
1392 error (
"prod: unrecognized type argument '%s'", str.c_str ());
1397 if (nargin < 1 || nargin > 2)
1407 dim = args(1).int_value () - 1;
1409 error (
"prod: invalid dimension DIM = %d", dim + 1);
1439 #define MAKE_INT_BRANCH(X) \
1442 retval = arg.X ## _array_value ().prod (dim); \
1444 retval = arg.array_value ().prod (dim); \
1456 #undef MAKE_INT_BRANCH
1558 int n_args = args.
length ();
1559 for (
int i = 0; i < n_args; i++)
1560 if (args(i).
numel () != 1)
1566 template <
typename TYPE,
typename T>
1572 int n_args = args.
length ();
1579 if (dim == -1 || dim == -2)
1587 for (
int j = 0; j < n_args; j++)
1591 result(j) = octave_value_extract<T> (args(j));
1598 for (
int j = 0; j < n_args; j++)
1602 array_list[j] = octave_value_extract<TYPE> (args(j));
1609 template <
typename TYPE,
typename T>
1615 int n_args = args.
length ();
1618 for (
int j = 0; j < n_args; j++)
1622 sparse_list[j] = octave_value_extract<TYPE> (args(j));
1629 template <
typename TYPE>
1635 single_type_concat<TYPE, typename TYPE::element_type> (result, args, dim);
1640 template <
typename MAP>
1646 int n_args = args.
length ();
1649 for (
int j = 0; j < n_args; j++)
1653 map_list[j] = octave_value_extract<MAP> (args(j));
1665 single_type_concat_map<octave_scalar_map> (result, args, dim);
1667 single_type_concat_map<octave_map> (result, args, dim);
1697 error (ee,
"conversion from %s to %s failed", dtype.c_str (),
1701 if (result.
empty ())
1702 error (
"conversion from %s to %s failed", dtype.c_str (),
1715 error (
"no constructor for %s!", dtype.c_str ());
1725 error (ee,
"%s constructor failed for %s argument", dtype.c_str (),
1729 if (result.
empty ())
1730 error (
"%s constructor failed for %s argument", dtype.c_str (),
1741 const std::string& cattype,
int dim)
1765 error (ee,
"%s/%s method failed", dtype.c_str (), cattype.c_str ());
1769 error (
"%s/%s method did not return a value", dtype.c_str (),
1789 if (t1_type == dtype)
1799 std::string cname = tmp(0).class_name ();
1800 std::list<std::string> parents = tmp(0).parent_class_name_list ();
1818 int n_args = args.
length ();
1822 else if (n_args == 1)
1824 else if (n_args > 1)
1826 std::string result_type;
1828 bool all_strings_p =
true;
1829 bool all_sq_strings_p =
true;
1830 bool all_dq_strings_p =
true;
1831 bool all_real_p =
true;
1832 bool all_cmplx_p =
true;
1833 bool any_sparse_p =
false;
1834 bool any_cell_p =
false;
1835 bool any_class_p =
false;
1837 bool first_elem_is_struct =
false;
1839 for (
int i = 0; i < n_args; i++)
1843 result_type = args(i).class_name ();
1845 first_elem_is_struct = args(i).isstruct ();
1850 if (all_strings_p && ! args(i).is_string ())
1851 all_strings_p =
false;
1852 if (all_sq_strings_p && ! args(i).is_sq_string ())
1853 all_sq_strings_p =
false;
1854 if (all_dq_strings_p && ! args(i).is_dq_string ())
1855 all_dq_strings_p =
false;
1856 if (all_real_p && ! args(i).isreal ())
1858 if (all_cmplx_p && ! (args(i).iscomplex ()
1859 || args(i).isreal ()))
1860 all_cmplx_p =
false;
1861 if (! any_sparse_p && args(i).issparse ())
1862 any_sparse_p =
true;
1863 if (! any_cell_p && args(i).iscell ())
1865 if (! any_class_p && args(i).isobject ())
1869 if (any_cell_p && ! any_class_p && ! first_elem_is_struct)
1872 for (
int i = 0; i < n_args; i++)
1874 if (args(i).iscell ())
1875 args(j++) = args(i);
1878 if (args(i).isempty ())
1881 args(j++) =
Cell (args(i));
1892 else if (result_type ==
"double")
1897 retval = do_single_type_concat<SparseMatrix> (args, dim);
1899 retval = do_single_type_concat<SparseComplexMatrix> (args, dim);
1904 retval = do_single_type_concat<NDArray> (args, dim);
1906 retval = do_single_type_concat<ComplexNDArray> (args, dim);
1909 else if (result_type ==
"single")
1912 retval = do_single_type_concat<FloatNDArray> (args, dim);
1914 retval = do_single_type_concat<FloatComplexNDArray> (args, dim);
1916 else if (result_type ==
"char")
1918 char type = (all_dq_strings_p ?
'"' :
'\'');
1920 if (! all_strings_p)
1922 "numeric", result_type);
1926 charNDArray result = do_single_type_concat<charNDArray> (args, dim);
1930 else if (result_type ==
"logical")
1933 retval = do_single_type_concat<SparseBoolMatrix> (args, dim);
1935 retval = do_single_type_concat<boolNDArray> (args, dim);
1937 else if (result_type ==
"int8")
1938 retval = do_single_type_concat<int8NDArray> (args, dim);
1939 else if (result_type ==
"int16")
1940 retval = do_single_type_concat<int16NDArray> (args, dim);
1941 else if (result_type ==
"int32")
1942 retval = do_single_type_concat<int32NDArray> (args, dim);
1943 else if (result_type ==
"int64")
1944 retval = do_single_type_concat<int64NDArray> (args, dim);
1945 else if (result_type ==
"uint8")
1946 retval = do_single_type_concat<uint8NDArray> (args, dim);
1947 else if (result_type ==
"uint16")
1948 retval = do_single_type_concat<uint16NDArray> (args, dim);
1949 else if (result_type ==
"uint32")
1950 retval = do_single_type_concat<uint32NDArray> (args, dim);
1951 else if (result_type ==
"uint64")
1952 retval = do_single_type_concat<uint64NDArray> (args, dim);
1953 else if (result_type ==
"cell")
1954 retval = do_single_type_concat<Cell> (args, dim);
1955 else if (result_type ==
"struct")
1965 if (dim == -1 || dim == -2)
1971 for (
int i = 1; i < args.
length (); i++)
1973 if (! (dv.*concat_rule) (args(i).dims (), dim))
1974 error (
"cat: dimension mismatch");
1995 int dv_len = dv.
ndims ();
1998 for (
int j = 0; j < n_args; j++)
2010 error (
"%s: indexing error", fname.c_str ());
2015 ra_idx(dim) += (dim < dv_tmp.
ndims () ? dv_tmp(dim) : 1);
2026 DEFUN (horzcat, args, ,
2044 return do_cat (args, -2,
"horzcat");
2268 DEFUN (vertcat, args, ,
2286 return do_cat (args, -1,
"vertcat");
2341 if (args.length () == 0)
2344 int dim = args(0).xint_value (
"cat: DIM must be an integer") - 1;
2347 error (
"cat: DIM must be a valid dimension");
2349 return ovl (
do_cat (args.slice (1, args.length () - 1), dim,
"cat"));
2516 if (args.
length () != 2 || args(1).length () < args(1).ndims ())
2519 Array<int> vec = args(1).int_vector_value ();
2524 for (
int i = 0; i <
n; i++)
2530 DEFUN (permute, args, ,
2563 DEFUN (ipermute, args, ,
2582 DEFUN (length, args, ,
2594 if (args.length () != 1)
2597 return ovl (args(0).length ());
2600 DEFUN (ndims, args, ,
2618 if (args.length () != 1)
2628 while ((ndims > 2) && (sz(ndims - 1) == 1))
2683 int nargin = args.length ();
2691 retval = args(0).
numel ();
2692 else if (nargin > 1)
2696 retval =
dims_to_numel (args(0).dims (), args.slice (1, nargin-1));
2702 DEFUN (size, args, nargout,
2764 int nargin = args.length ();
2774 int ndims = dimensions.
ndims ();
2780 dimensions = dimensions.
redim (nargout);
2781 ndims = dimensions.
ndims ();
2784 m.resize (1, ndims);
2787 m(i) = dimensions(i);
2798 query_dims(i) = args(i+1).idx_type_value (
true);
2801 query_dims = args(1).octave_idx_type_vector_value (
true);
2803 if (nargout > 1 && nargout != query_dims.
numel ())
2804 error (
"size: nargout > 1 but does not match number of requested dimensions");
2815 error (
"size: requested dimension DIM (= %"
2816 OCTAVE_IDX_TYPE_FORMAT
") out of range", nd);
2818 m(i) = nd <= ndims ? dimensions (nd-1) : 1;
2911 DEFUN (size_equal, args, ,
2922 int nargin = args.length ();
2928 for (
int i = 1; i < nargin; ++i)
2932 if (a_dims != b_dims)
2947 if (args.length () != 1)
2950 return ovl (args(0).nnz ());
2969 DEFUN (nzmax, args, ,
2983 if (args.length () != 1)
2986 return ovl (args(0).nzmax ());
2989 DEFUN (rows, args, ,
2998 if (args.length () != 1)
3034 DEFUN (columns, args, ,
3043 if (args.length () != 1)
3091 int nargin = args.length ();
3093 bool isnative =
false;
3094 bool isdouble =
false;
3095 bool isextra =
false;
3097 if (nargin > 1 && args(nargin - 1).is_string ())
3099 std::string str = args(nargin - 1).string_value ();
3101 if (str ==
"native")
3103 else if (str ==
"double")
3105 else if (str ==
"extra")
3108 error (
"sum: unrecognized type argument '%s'", str.c_str ());
3113 if (nargin < 1 || nargin > 2)
3119 dim = args(1).int_value () - 1;
3121 error (
"sum: invalid dimension DIM = %d", dim + 1);
3133 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3146 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3156 if (isdouble || isextra)
3163 if (isdouble || isextra)
3169 #define MAKE_INT_BRANCH(X) \
3172 retval = arg.X ## _array_value ().sum (dim); \
3174 retval = arg.X ## _array_value ().dsum (dim); \
3186 #undef MAKE_INT_BRANCH
3283 DEFUN (sumsq, args, ,
3323 DEFUN (islogical, args, ,
3331 if (args.length () != 1)
3334 return ovl (args(0).islogical ());
3363 if (args.length () != 1)
3411 DEFUN (iscomplex, args, ,
3418 if (args.length () != 1)
3421 return ovl (args(0).iscomplex ());
3441 DEFUN (isfloat, args, ,
3450 if (args.length () != 1)
3453 return ovl (args(0).isfloat ());
3459 DEFUN (complex, args, ,
3489 int nargin = args.length ();
3491 if (nargin < 1 || nargin > 2)
3512 if (arg.
numel () == 1)
3527 if (arg.
numel () == 1)
3552 if (re.
numel () == 1)
3555 if (re_val.
nnz () == 0)
3567 i < im_val.
cidx (j + 1); i++)
3568 result.
data (im_val.
ridx (i) + off)
3574 else if (im.
numel () == 1)
3577 if (im_val.
nnz () == 0)
3590 i < re_val.
cidx (j + 1); i++)
3591 result.
data (re_val.
ridx (i) + off)
3599 if (re_val.
dims () != im_val.
dims ())
3600 error (
"complex: dimension mismatch");
3610 if (re.
numel () == 1)
3614 if (im.
numel () == 1)
3638 if (im.
numel () == 1)
3654 if (re_val.
dims () != im_val.
dims ())
3655 error (
"complex: dimension mismatch");
3668 else if (re.
numel () == 1)
3672 if (im.
numel () == 1)
3695 if (im.
numel () == 1)
3710 if (re_val.
dims () != im_val.
dims ())
3711 error (
"complex: dimension mismatch");
3770 DEFUN (isreal, args, ,
3780 if (args.length () != 1)
3783 return ovl (args(0).isreal ());
3786 DEFUN (isempty, args, ,
3794 if (args.length () != 1)
3797 return ovl (args(0).isempty ());
3805 DEFUN (isnumeric, args, ,
3816 if (args.length () != 1)
3819 return ovl (args(0).isnumeric ());
3838 DEFUN (isscalar, args, ,
3848 if (args.length () != 1)
3855 return ovl (sz.
numel () == 2 && sz(0) == 1 && sz(1) == 1);
3888 if (args.length () != 1)
3895 return ovl (sz.
numel () == 2 && (sz(0) == 1 || sz(1) == 1));
3918 DEFUN (isrow, args, ,
3928 if (args.length () != 1)
3935 return ovl (sz.
numel () == 2 && sz(0) == 1);
3967 DEFUN (iscolumn, args, ,
3977 if (args.length () != 1)
3984 return ovl (sz.
numel () == 2 && sz(1) == 1);
4016 DEFUN (ismatrix, args, ,
4027 if (args.length () != 1)
4034 return ovl (sz.
numel () == 2 && sz(0) >= 0 && sz(1) >= 0);
4065 DEFUN (issquare, args, ,
4075 if (args.length () != 1)
4082 return ovl (sz.
numel () == 2 && sz(0) == sz(1));
4111 int nargin = args.
length ();
4116 bool issparse =
false;
4117 bool iscomplex =
false;
4119 if (nargin > 0 && args(nargin-1).is_string ())
4121 std::string nm = args(nargin-1).string_value ();
4127 if (nargin > 1 && args(nargin-2).is_string ()
4128 && args(nargin-2).string_value () ==
"like")
4130 std::string nm = args(nargin-1).class_name ();
4131 issparse = args(nargin-1).issparse ();
4132 iscomplex = args(nargin-1).iscomplex ();
4150 for (
int i = 0; i < nargin; i++)
4152 if (args(i).
numel () > 1)
4153 error (
"%s: dimensions must be scalars.", fcn);
4155 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4173 if (dims.
ndims () > 2)
4174 error (
"%s: sparse ND arrays not supported.", fcn);
4182 retval =
SparseMatrix (dims(0), dims(1),
static_cast<double> (val));
4191 error (
"%s: invalid class name for sparse", fcn);
4250 error (
"%s: invalid class name", fcn);
4263 int nargin = args.
length ();
4268 bool issparse =
false;
4269 bool iscomplex =
false;
4271 if (nargin > 0 && args(nargin-1).is_string ())
4273 std::string nm = args(nargin-1).string_value ();
4279 if (nargin > 1 && args(nargin-2).is_string ()
4280 && args(nargin-2).string_value () ==
"like"
4281 && (std::string(fcn) ==
"Inf"
4282 || std::string(fcn) ==
"NaN" || std::string(fcn) ==
"NA"))
4284 if (! args(nargin-1).isfloat ())
4285 error (
"%s: input followed by 'like' must be floating point", fcn);
4286 std::string nm = args(nargin-1).class_name ();
4287 issparse = args(nargin-1).issparse ();
4288 iscomplex = args(nargin-1).iscomplex ();
4306 for (
int i = 0; i < nargin; i++)
4308 if (args(i).
numel () > 1)
4309 error (
"%s: dimensions must be scalars.", fcn);
4311 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4326 if (dims.
ndims () > 2)
4327 error (
"%s: sparse ND arrays not supported", fcn);
4332 retval =
SparseMatrix (dims(0), dims(1),
static_cast<double> (val));
4354 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++)
4395 if (args(i).
numel () > 1)
4396 error (
"%s: dimensions must be scalars.", fcn);
4398 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4414 retval =
FloatNDArray (dims,
static_cast<float> (val));
4422 error (
"%s: invalid class name", fcn);
4435 int nargin = args.
length ();
4441 if (nargin > 0 && args(nargin-1).is_string ())
4443 std::string nm = args(nargin-1).string_value ();
4462 for (
int i = 0; i < nargin; i++)
4464 if (args(i).
numel () > 1)
4465 error (
"%s: dimensions must be scalars.", fcn);
4467 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4492 error (
"%s: invalid class name", fcn);
4504 int nargin = args.
length ();
4511 if (nargin > 0 && args(nargin-1).is_string ())
4513 std::string nm = args(nargin-1).string_value ();
4517 error (
"%s: invalid data type '%s'", fcn, nm.c_str ());
4520 bool issparse =
false;
4522 if (nargin > 1 && args(nargin-2).is_string ()
4523 && args(nargin-2).string_value () ==
"like")
4525 if (! args(nargin-1).islogical ())
4526 error (R
"(%s: input followed by "like" must be logical)", fcn);
4528 issparse = args(nargin-1).issparse ();
4545 for (
int i = 0; i < nargin; i++)
4547 if (args(i).
numel () > 1)
4548 error (
"%s: dimensions must be scalars.", fcn);
4550 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4565 if (dims.
ndims () > 2)
4566 error (
"%s: sparse ND arrays not supported", fcn);
4576 DEFUN (ones, args, ,
4669 DEFUN (zeros, args, ,
4934 double e_val = exp (1.0);
4940 template <
typename T>
4944 T epsval =
x.abs ();
4945 typedef typename T::value_type P;
4948 P val = epsval.xelem (i);
4952 epsval(i) = std::numeric_limits<P>::denorm_min ();
4957 const P digits = std::numeric_limits<P>::digits;
4958 epsval(i) =
std::pow (
static_cast<P
> (2.0),
4959 static_cast<P
> (exponent - digits));
5002 if (args.length () == 1 && ! args(0).is_string ())
5016 error (
"eps: X must be of a floating point type");
5019 retval =
fill_matrix (args, std::numeric_limits<double>::epsilon (),
5020 std::numeric_limits<float>::epsilon (),
"eps");
5092 double pi_val = M_PI;
5094 double pi_val = 4.0 *
atan (1.0);
5100 DEFUN (realmax, args, ,
5139 DEFUN (realmin, args, ,
5263 DEFUN (
false, args, ,
5298 DEFUN (
true, args, ,
5333 template <
typename MT>
5339 typename MT::element_type one (1);
5341 if (nr == 1 && nc == 1)
5347 typename MT::element_type zero (0);
5351 if (nr > 0 && nc > 0)
5355 for (
int i = 0; i <
n; i++)
5365 #define INSTANTIATE_EYE(T) \
5366 template octave_value identity_matrix<T> (int, int)
5435 error (
"eye: invalid class name");
5442 #undef INT_EYE_MATRIX
5494 int nargin = args.length ();
5500 if (nargin > 0 && args(nargin-1).is_string ())
5502 std::string nm = args(nargin-1).string_value ();
5515 else if (nargin == 1)
5550 template <
typename MT>
5555 typedef typename MT::column_vector_type CVT;
5556 typedef typename MT::element_type T;
5562 T bs = octave_value_extract<T> (base);
5565 T ls = octave_value_extract<T> (limit);
5570 CVT lv = octave_value_extract<CVT> (limit);
5571 CVT bv (lv.numel (), bs);
5577 CVT bv = octave_value_extract<CVT> (base);
5580 T ls = octave_value_extract<T> (limit);
5581 CVT lv (bv.numel (), ls);
5586 CVT lv = octave_value_extract<CVT> (limit);
5617 int nargin = args.length ();
5619 if (nargin != 2 && nargin != 3)
5632 error (
"linspace: N must be a scalar");
5642 bool isvector1 = sz1.
ndims () == 2 && (sz1(0) == 1 || sz1(1) == 1);
5644 bool isvector2 = sz2.
ndims () == 2 && (sz2(0) == 1 || sz2(1) == 1);
5646 if (! isvector1 || ! isvector2)
5647 error (
"linspace: START, END must be scalars or vectors");
5654 retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
5656 retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
5661 retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
5663 retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
5771 DEFUN (resize, args, ,
5817 int nargin = args.length ();
5827 int ndim = vec.
numel ();
5838 for (
int i = 0; i < ndim; i++)
5841 retval = retval.
resize (dv,
true);
5852 retval = retval.
resize (dv,
true);
5860 DEFUN (reshape, args, ,
5894 int nargin = args.length ();
5907 if (new_size.
numel () < 2)
5908 error (
"reshape: SIZE must have 2 or more dimensions");
5914 if (new_size(i) < 0)
5915 error (
"reshape: SIZE must be non-negative");
5917 new_dims(i) = new_size(i);
5925 for (
int i = 1; i < nargin; i++)
5927 if (args(i).isempty ())
5930 error (
"reshape: only a single dimension can be unknown");
5937 new_dims(i-1) = args(i).idx_type_value ();
5939 if (new_dims(i-1) < 0)
5940 error (
"reshape: SIZE must be non-negative");
5949 new_dims(empty_dim-1) = 0;
5955 if (a_nel != size_empty_dim * nel)
5956 error (
"reshape: SIZE is not divisible by the product of "
5957 "known dimensions (= %" OCTAVE_IDX_TYPE_FORMAT
")",
5960 new_dims(empty_dim-1) = size_empty_dim;
5965 retval = args(0).
reshape (new_dims);
6009 int nargin = args.length ();
6011 if (nargin < 1 || nargin > 2)
6017 dim = args(1).idx_type_value ();
6020 error (
"vec: DIM must be greater than zero");
6032 for (
int i = 0; i < dim-1; i++)
6035 new_dims(dim-1) = retval.
numel ();
6037 retval = retval.
reshape (new_dims);
6058 DEFUN (squeeze, args, ,
6068 if (args.length () != 1)
6071 return ovl (args(0).squeeze ());
6074 DEFUN (full, args, ,
6082 if (args.length () != 1)
6085 return ovl (args(0).full_value ());
6151 int nargin = args.length ();
6153 if (nargin < 1 || nargin > 3)
6158 if (x_arg.
ndims () != 2)
6159 error (
"norm: only valid for 2-D objects");
6161 enum {sfmatrix, sfcols, sfrows, sffrob, sfinf, sfneginf} strflag = sfmatrix;
6162 if (nargin > 1 && args(nargin-1).is_string ())
6164 std::string str = args(nargin-1).string_value ();
6165 std::transform (str.begin (), str.end (), str.begin (), tolower);
6166 if (str ==
"cols" || str ==
"columns")
6168 else if (str ==
"rows")
6170 else if (str ==
"fro")
6172 else if (str ==
"inf")
6174 else if (str ==
"-inf")
6177 error (
"norm: unrecognized option: %s", str.c_str ());
6190 std::transform (str.begin (), str.end (), str.begin (), tolower);
6191 if (strflag != sfcols && strflag != sfrows)
6192 error (
"norm: invalid combination of options");
6194 if (str ==
"cols" || str ==
"columns" || str ==
"rows")
6195 error (
"norm: invalid combination of options");
6199 else if (str ==
"inf")
6201 else if (str ==
"-inf")
6204 error (
"norm: unrecognized option: %s", str.c_str ());
6214 retval =
xnorm (x_arg, p_arg);
6352 DEFUN (uplus, args, ,
6362 DEFUN (uminus, args, ,
6404 DEFUN (ctranspose, args, ,
6443 return binary_op (op, args(0), args(1));
6451 int nargin = args.
length ();
6459 retval =
binary_op (op, args(0), args(1));
6462 retval =
binary_op (op, args(0), args(1));
6464 for (
int i = 2; i < nargin; i++)
6465 retval.
assign (aop, args(i));
6471 DEFUN (plus, args, ,
6502 DEFUN (minus, args, ,
6512 DEFUN (mtimes, args, ,
6533 DEFUN (mrdivide, args, ,
6548 DEFUN (mpower, args, ,
6560 DEFUN (mldivide, args, ,
6639 DEFUN (times, args, ,
6660 DEFUN (rdivide, args, ,
6672 DEFUN (power, args, ,
6690 DEFUN (ldivide, args, ,
6745 DEFUN (colon, args, ,
6758 int nargin = args.length ();
6760 if (nargin < 2 || nargin > 3)
6765 :
colon_op (args(0), args(1), args(2)));
6770 DEFUN (tic, args, nargout,
6822 if (args.length () != 0)
6823 warning (
"tic: ignoring extra arguments");
6832 double frac = std::modf (tmp, &ip);
6833 uint64_t microsecs =
static_cast<uint64_t
> (CLOCKS_PER_SEC * frac);
6834 microsecs += CLOCKS_PER_SEC *
static_cast<uint64_t
> (ip);
6843 DEFUN (toc, args, nargout,
6861 int nargin = args.length ();
6870 octave_uint64 id = args(0).xuint64_scalar_value (
"toc: invalid ID");
6872 uint64_t val =
id.
value ();
6875 = (
static_cast<double> (val / CLOCKS_PER_SEC)
6876 +
static_cast<double> (val % CLOCKS_PER_SEC)
6884 error (
"toc: function called before timer initialization with tic()");
6888 double etime = now.double_value () - start_time;
6894 octave_stdout <<
"Elapsed time is " << etime <<
" seconds.\n";
6906 DEFUN (cputime, args, ,
6925 if (args.length () != 0)
6928 sys::cpu_time cpu_tm;
6930 double usr = cpu_tm.user ();
6931 double sys = cpu_tm.system ();
6933 return ovl (usr + sys, usr, sys);
6936 DEFUN (sort, args, nargout,
7006 int nargin = args.length ();
7008 if (nargin < 1 || nargin > 3)
7012 bool return_idx = (nargout > 1);
7013 bool have_sortmode = (nargin > 1 && args(1).is_string ());
7021 std::string mode = args(1).string_value ();
7022 if (mode ==
"ascend")
7024 else if (mode ==
"descend")
7027 error (R
"(sort: MODE must be either "ascend" or "descend")");
7030 dim = args(1).nint_value () - 1;
7036 error (
"sort: DIM must be a valid dimension");
7038 std::string mode = args(2).xstring_value (
"sort: MODE must be a string");
7040 if (mode ==
"ascend")
7042 else if (mode ==
"descend")
7045 error (R
"(sort: MODE must be either "ascend" or "descend")");
7049 if (nargin == 1 || have_sortmode)
7056 error (
"sort: DIM must be a valid dimension");
7067 retval(0) = arg.
sort (sidx, dim, smode);
7071 retval =
ovl (arg.
sort (dim, smode));
7305 DEFUN (__sort_rows_idx__, args, ,
7311 int nargin = args.length ();
7313 if (nargin < 1 || nargin > 2)
7316 if (nargin == 2 && ! args(1).is_string ())
7317 error (
"__sort_rows_idx__: second argument must be a string");
7322 std::string mode = args(1).string_value ();
7323 if (mode ==
"ascend")
7325 else if (mode ==
"descend")
7328 error (R
"(__sort_rows_idx__: MODE must be either "ascend" or "descend")");
7334 error (
"__sort_rows_idx__: sparse matrices not yet supported");
7336 if (arg.
ndims () != 2)
7337 error (
"__sort_rows_idx__: needs a 2-D object");
7353 std::string mode = arg.
xstring_value (
"issorted: MODE must be a string");
7355 if (mode ==
"ascend")
7357 else if (mode ==
"descend")
7359 else if (mode ==
"either")
7362 error (R
"(issorted: MODE must be "ascend", "descend", or "either")");
7367 DEFUN (issorted, args, ,
7385 int nargin = args.length ();
7387 if (nargin < 1 || nargin > 3)
7390 bool by_rows =
false;
7399 std::string tmp = args(1).xstring_value (
"issorted: second argument must be a string");
7415 error (
"issorted: sparse matrices not yet supported");
7417 if (arg.
ndims () != 2)
7418 error (
"issorted: A must be a 2-D object");
7425 error (
"issorted: needs a vector");
7496 DEFUN (nth_element, args, ,
7520 int nargin = args.length ();
7522 if (nargin < 2 || nargin > 3)
7528 dim = args(2).int_value (
true) - 1;
7530 error (
"nth_element: DIM must be a valid dimension");
7558 #define MAKE_INT_BRANCH(X) \
7560 retval = argx.X ## _array_value ().nth_element (n, dim); \
7573 #undef MAKE_INT_BRANCH
7584 error (
"nth_element: invalid index %s", ie.what ());
7605 template <
typename NDT>
7610 typedef typename NDT::element_type T;
7614 error (
"accumarray: index out of range");
7618 if (vals.numel () == 1)
7619 retval.idx_add (idx, vals (0));
7620 else if (vals.numel () == idx.
length (
n))
7621 retval.idx_add (idx, vals);
7623 error (
"accumarray: dimensions mismatch");
7628 DEFUN (__accumarray_sum__, args, ,
7634 int nargin = args.length ();
7636 if (nargin < 2 || nargin > 3)
7639 if (! args(0).isnumeric ())
7640 error (
"__accumarray_sum__: first argument must be numeric");
7649 n = args(2).idx_type_value (
true);
7656 if (
r.increment () == 0)
7683 error (
"__accumarray_sum__: invalid index %s", ie.what ());
7689 template <
typename NDT>
7693 const typename NDT::element_type& zero_val)
7695 typedef typename NDT::element_type T;
7699 error (
"accumarray: index out of range");
7708 if (vals.numel () == 1)
7709 (retval.*op) (idx, NDT (
dim_vector (l, 1), vals(0)));
7710 else if (vals.numel () == l)
7711 (retval.*op) (idx, vals);
7713 error (
"accumarray: dimensions mismatch");
7722 int nargin = args.
length ();
7724 if (nargin < 3 || nargin > 4)
7727 if (! args(0).isnumeric ())
7728 error (
"accumarray: first argument must be numeric");
7737 n = args(3).idx_type_value (
true);
7766 #define MAKE_INT_BRANCH(X) \
7768 retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
7769 n, ismin, zero.X ## _scalar_value ()); \
7781 #undef MAKE_INT_BRANCH
7794 error (
"do_accumarray_minmax_fcn: invalid index %s", ie.what ());
7800 DEFUN (__accumarray_min__, args, ,
7809 DEFUN (__accumarray_max__, args, ,
7818 template <
typename NDT>
7823 typedef typename NDT::element_type T;
7827 error (
"accumdim: index out of range");
7834 else if (dim >= rdv.
ndims ())
7839 NDT retval (rdv, T ());
7841 if (idx.
length () != vals_dim(dim))
7842 error (
"accumdim: dimension mismatch");
7844 retval.idx_add_nd (idx, vals, dim);
7849 DEFUN (__accumdim_sum__, args, ,
7855 int nargin = args.length ();
7857 if (nargin < 2 || nargin > 4)
7860 if (! args(0).isnumeric ())
7861 error (
"__accumdim_sum__: first argument must be numeric");
7870 dim = args(2).int_value () - 1;
7874 n = args(3).idx_type_value (
true);
7901 error (
"__accumdim_sum__: invalid index %s", ie.what ());
7907 template <
typename NDT>
7910 const NDT& tval,
const NDT& fval)
7912 typedef typename NDT::element_type T;
7916 bool tscl = tval.numel () == 1;
7917 bool fscl = fval.numel () == 1;
7919 if ((! tscl && tval.dims () != dv) || (! fscl && fval.dims () != dv))
7920 error (
"merge: MASK, TVAL, and FVAL dimensions must match");
7922 T *rv = retval.fortran_vec ();
7925 const T *tv = tval.data ();
7926 const T *fv = fval.data ();
7927 const bool *mv = mask.
data ();
7936 rv[i] = (mv[i] ? ts : fs);
7942 rv[i] = (mv[i] ? ts : fv[i]);
7951 rv[i] = (mv[i] ? tv[i] : fs);
7956 rv[i] = (mv[i] ? tv[i] : fv[i]);
7963 #define MAKE_INT_BRANCH(INTX) \
7964 else if (tval.is_ ## INTX ## _type () && fval.is_ ## INTX ## _type ()) \
7966 retval = do_merge (mask, \
7967 tval.INTX ## _array_value (), \
7968 fval.INTX ## _array_value ()); \
7971 DEFUN (merge, args, ,
8000 if (args.length () != 3)
8003 if (! (args(0).islogical () || args(0).isnumeric ()))
8004 error (
"merge: first argument must be logical or numeric");
8011 retval = (mask_val.
is_true () ? args(1) : args(2));
8047 sq_string ?
'\'' :
'"');
8066 error (
"merge: cannot merge %s with %s with array mask",
8076 #undef MAKE_INT_BRANCH
8078 template <
typename SparseT>
8083 SparseT retval = array;
8087 while (order > 0 && k > 0)
8089 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
8090 retval = SparseT (retval.index (col1, sl1))
8091 - SparseT (retval.index (col2, sl2));
8100 while (order > 0 && k > 0)
8102 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
8103 retval = SparseT (retval.index (sl1, col1))
8104 - SparseT (retval.index (sl2, col2));
8126 if (dv(dim) <= order)
8135 if (dim == dv.
ndims ())
8137 retval =
do_diff (array, order, dim - 1);
8140 else if (dv(dim) == 1)
8144 retval =
do_diff (array, dv(dim) - 1, dim);
8145 order -= dv(dim) - 1;
8202 DEFUN (diff, args, ,
8234 int nargin = args.length ();
8236 if (nargin < 1 || nargin > 3)
8239 if (! (args(0).isnumeric () || args(0).islogical ()))
8240 error (
"diff: X must be numeric or logical");
8246 if (args(1).is_scalar_type ())
8247 order = args(1).idx_type_value (
true,
false);
8248 else if (! args(1).is_zero_by_zero ())
8249 error (
"diff: order K must be a scalar or []");
8251 error (
"diff: order K must be non-negative");
8256 dim = args(2).int_value (
true,
false);
8257 if (dim < 1 || dim > args(0).ndims ())
8258 error (
"diff: DIM must be a valid dimension");
8263 return do_diff (args(0), order, dim);
8279 template <
typename T>
8285 if (rep.
ndims () != 2 || rep.
rows () != 2)
8286 error (
"repelems: R must be a 2-row, N-column matrix of integers");
8294 error (
"repelems: second row must contain non-negative numbers");
8299 retval.
clear (1, l);
8305 std::fill_n (dest, k, src.
checkelem (rep(0, i) - 1));
8312 DEFUN (repelems, args, ,
8338 if (args.length () != 2)
8343 const Matrix rm = args(1).matrix_value ();
8345 if (rm.
rows () != 2 || rm.
ndims () != 2)
8346 error (
"repelems: R must be a matrix with two rows");
8355 if (
static_cast<double> (rx) != rm(i))
8356 error (
"repelems: R must be a matrix of integers");
8361 switch (
x.builtin_type ())
8363 #define BTYP_BRANCH(X, EX) \
8365 retval = do_repelems (x.EX ## _value (), r); \
8405 if (args.length () != 1)
8408 if (! args(0).isnumeric ())
8409 error (
"base64_encode: encoding is supported only for numeric arrays");
8411 if (args(0).iscomplex () || args(0).issparse ())
8412 error (
"base64_encode: encoding complex or sparse data is not supported");
8418 #define MAKE_INT_BRANCH(X) \
8419 if (args(0).is_ ## X ## _type ()) \
8421 const X##NDArray in = args(0). X## _array_value (); \
8422 std::size_t inlen = in.numel () * sizeof (X## _t) / sizeof (char); \
8423 const char *inc = reinterpret_cast<const char *> (in.data ()); \
8425 if (base64_encode (inc, inlen, &out)) \
8427 retval(0) = octave_value (out); \
8441 #undef MAKE_INT_BRANCH
8446 else if (args(0).is_single_type ())
8450 inlen = in.
numel () *
sizeof (float) /
sizeof (
char);
8452 inc =
reinterpret_cast<const char *
> (in.
data ());
8464 inlen = in.
numel () *
sizeof (double) /
sizeof (
char);
8466 inc =
reinterpret_cast<const char *
> (in.
data ());
8513 int nargin = args.length ();
8515 if (nargin < 1 || nargin > 2)
8518 std::string str = args(0).string_value ();
8527 = args(1).octave_idx_type_vector_value ();
8533 retval = retval.
reshape (dims);
8536 return ovl (retval);
8557 DEFUN (__base64_decode_bytes__, args, ,
8569 int nargin = args.length ();
8571 if (nargin < 1 || nargin > 2)
8574 std::string str = args(0).string_value ();
8583 = args(1).octave_idx_type_vector_value ();
8589 retval = retval.
reshape (dims);
8592 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)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_API void clear(void)
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
OCTARRAY_API Array< T, Alloc > nth_element(const octave::idx_vector &n, int dim=0) const
Returns the n-th element in increasing order, using the same ordering as used for sort.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_OVERRIDABLE_FUNC_API Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_API T & checkelem(octave_idx_type n)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API int ndims(void) const
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().
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
Size of the specified dimension.
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
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 * cidx(void)
octave_idx_type * ridx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
dim_vector dims(void) const
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_idx_type length(octave_idx_type n=0) const
octave_idx_type extent(octave_idx_type n) const
OCTAVE_API intNDArray diff(octave_idx_type order=1, int dim=-1) const
static data_type string_to_data_type(const std::string &s)
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
octave::range< double > range_value(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
OCTINTERP_API octave_value & assign(assign_op op, const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
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
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
std::string string_value(bool force=false) 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
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
Array< std::string > cellstr_value(void) 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
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
octave_value find_method(const std::string &name, const std::string &dispatch_type)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#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_list do_accumarray_minmax_fcn(const octave_value_list &args, bool ismin)
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 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)
static Array< T > do_repelems(const Array< T > &src, const Array< octave_idx_type > &rep)
#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)
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 error_unless(bool cond)
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
symbol_table & __get_symbol_table__(void)
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)
Complex log2(const Complex &x)
double frexp(double x, int *expptr)
Complex atan(const Complex &x)
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
Array< double > base64_decode(const std::string &str)
bool base64_encode(const char *inc, const std::size_t inlen, char **out)
intNDArray< octave_uint8 > base64_decode_bytes(const std::string &str)
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)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
double xfrobnorm(const Matrix &x)
double xnorm(const ColumnVector &x, double p)
RowVector xcolnorms(const Matrix &m, double p)
ColumnVector xrownorms(const Matrix &m, double p)
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 unary_op(type_info &ti, octave_value::unary_op op, const octave_value &a)
OCTINTERP_API octave_value colon_op(const octave_value &base, const octave_value &increment, const octave_value &limit, bool is_for_cmd_expr=false)
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.
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
std::string get_concat_class(const std::string &c1, const std::string &c2)
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)