26 #if defined (HAVE_CONFIG_H)
92 int nargin = args.length ();
94 if (nargin < 1 || nargin > 2)
97 int dim = (nargin == 1 ? -1
98 : args(1).xint_value (
"all: DIM must be an integer")-1);
101 error (
"all: invalid dimension argument = %d", dim + 1);
103 return ovl (args(0).all (dim));
157 int nargin = args.length ();
159 if (nargin < 1 || nargin > 2)
162 int dim = (nargin == 1 ? -1
163 : args(1).xint_value (
"any: DIM must be an integer")-1);
166 error (
"any: invalid dimension argument = %d", dim + 1);
168 return ovl (args(0).any (dim));
194 DEFUN (atan2, args, ,
208 if (args.length () != 2)
213 if (! args(0).isnumeric ())
216 if (! args(1).isnumeric ())
219 if (args(0).iscomplex () || args(1).iscomplex ())
220 error (
"atan2: not defined for complex numbers");
222 if (args(0).is_single_type () || args(1).is_single_type ())
224 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
225 retval = atan2f (args(0).float_value (), args(1).float_value ());
230 retval = binmap<float> (a0, a1, std::atan2,
"atan2");
235 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
236 retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
237 else if (args(0).issparse ())
241 retval = binmap<double> (m0, m1, std::atan2,
"atan2");
245 NDArray a0 = args(0).array_value ();
246 NDArray a1 = args(1).array_value ();
247 retval = binmap<double> (a0, a1, std::atan2,
"atan2");
340 retval = binmap<float> (a0, a1, std::hypot,
"hypot");
351 retval = binmap<double> (m0, m1, std::hypot,
"hypot");
357 retval = binmap<double> (a0, a1, std::hypot,
"hypot");
364 DEFUN (hypot, args, ,
386 int nargin = args.length ();
399 for (
int i = 1; i < nargin; i++)
445 template <
typename T,
typename ET>
483 if (args.length () != 1)
490 else if (args(0).is_single_type ())
492 if (args(0).isreal ())
501 else if (args(0).iscomplex ())
511 else if (args(0).isreal ())
520 else if (args(0).iscomplex ())
593 if (args.length () != 2)
598 if (! args(0).isnumeric ())
601 if (! args(1).isnumeric ())
604 if (args(0).iscomplex () || args(1).iscomplex ())
605 error (
"rem: not defined for complex numbers");
617 error (
"rem: cannot combine %s and %s",
618 args(0).class_name ().c_str (),
619 args(1).class_name ().c_str ());
623 #define MAKE_INT_BRANCH(X) \
626 X##NDArray a0 = args(0).X##_array_value (); \
627 X##NDArray a1 = args(1).X##_array_value (); \
628 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
641 #undef MAKE_INT_BRANCH
647 else if (args(0).is_single_type () || args(1).is_single_type ())
649 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
655 retval = binmap<float> (a0, a1, octave::math::rem<float>,
"rem");
660 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
662 else if (args(0).issparse () || args(1).issparse ())
666 retval = binmap<double> (m0, m1, octave::math::rem<double>,
"rem");
670 NDArray a0 = args(0).array_value ();
671 NDArray a1 = args(1).array_value ();
672 retval = binmap<double> (a0, a1, octave::math::rem<double>,
"rem");
775 if (args.length () != 2)
780 if (! args(0).isnumeric ())
783 if (! args(1).isnumeric ())
786 if (args(0).iscomplex () || args(1).iscomplex ())
787 error (
"mod: not defined for complex numbers");
799 error (
"mod: cannot combine %s and %s",
800 args(0).class_name ().c_str (),
801 args(1).class_name ().c_str ());
805 #define MAKE_INT_BRANCH(X) \
808 X##NDArray a0 = args(0).X##_array_value (); \
809 X##NDArray a1 = args(1).X##_array_value (); \
810 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
823 #undef MAKE_INT_BRANCH
829 else if (args(0).is_single_type () || args(1).is_single_type ())
831 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
837 retval = binmap<float> (a0, a1, octave::math::mod<float>,
"mod");
842 if (args(0).is_scalar_type () && args(1).is_scalar_type ())
844 else if (args(0).issparse () || args(1).issparse ())
848 retval = binmap<double> (m0, m1, octave::math::mod<double>,
"mod");
852 NDArray a0 = args(0).array_value ();
853 NDArray a1 = args(1).array_value ();
854 retval = binmap<double> (a0, a1, octave::math::mod<double>,
"mod");
916 #define DATA_REDUCTION(FCN) \
918 int nargin = args.length (); \
920 if (nargin < 1 || nargin > 2) \
923 octave_value retval; \
925 octave_value arg = args(0); \
927 int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
930 error (#FCN ": invalid dimension argument = %d", dim + 1); \
934 if (arg.issparse ()) \
936 SparseMatrix tmp = arg.sparse_matrix_value (); \
938 retval = tmp.FCN (dim); \
940 else if (arg.is_single_type ()) \
942 FloatNDArray tmp = arg.float_array_value (); \
944 retval = tmp.FCN (dim); \
948 NDArray tmp = arg.array_value (); \
950 retval = tmp.FCN (dim); \
953 else if (arg.iscomplex ()) \
955 if (arg.issparse ()) \
957 SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
959 retval = tmp.FCN (dim); \
961 else if (arg.is_single_type ()) \
963 FloatComplexNDArray tmp \
964 = arg.float_complex_array_value (); \
966 retval = tmp.FCN (dim); \
970 ComplexNDArray tmp = arg.complex_array_value (); \
972 retval = tmp.FCN (dim); \
976 err_wrong_type_arg (#FCN, arg); \
980 DEFUN (cumprod, args, ,
1023 DEFUN (cumsum, args, ,
1048 int nargin = args.length ();
1050 bool isnative =
false;
1051 bool isdouble =
false;
1053 if (nargin > 1 && args(nargin - 1).is_string ())
1055 std::string str = args(nargin - 1).string_value ();
1057 if (str ==
"native")
1059 else if (str ==
"double")
1062 error (
"cumsum: unrecognized string argument");
1067 if (nargin < 1 || nargin > 2)
1073 dim = args(1).int_value () - 1;
1075 error (
"cumsum: invalid dimension argument = %d", dim + 1);
1108 #define MAKE_INT_BRANCH(X) \
1111 retval = arg.X ## _array_value ().cumsum (dim); \
1113 retval = arg.array_value ().cumsum (dim); \
1125 #undef MAKE_INT_BRANCH
1173 DEFUN (diag, args, ,
1206 int nargin = args.length ();
1208 if (nargin < 1 || nargin > 3)
1215 else if (nargin == 2)
1217 octave_idx_type k = args(1).xidx_type_value (
"diag: invalid argument K");
1226 error (
"diag: V must be a vector");
1305 DEFUN (prod, args, ,
1336 int nargin = args.length ();
1338 bool isnative =
false;
1339 bool isdouble =
false;
1341 if (nargin > 1 && args(nargin - 1).is_string ())
1343 std::string str = args(nargin - 1).string_value ();
1345 if (str ==
"native")
1347 else if (str ==
"double")
1350 error (
"prod: unrecognized type argument '%s'", str.c_str ());
1355 if (nargin < 1 || nargin > 2)
1365 dim = args(1).int_value () - 1;
1367 error (
"prod: invalid dimension DIM = %d", dim + 1);
1397 #define MAKE_INT_BRANCH(X) \
1400 retval = arg.X ## _array_value ().prod (dim); \
1402 retval = arg.array_value ().prod (dim); \
1414 #undef MAKE_INT_BRANCH
1513 int n_args = args.
length ();
1514 for (
int i = 0; i < n_args; i++)
1515 if (args(i).
numel () != 1)
1521 template <
typename TYPE,
typename T>
1527 int n_args = args.
length ();
1534 if (dim == -1 || dim == -2)
1542 for (
int j = 0; j < n_args; j++)
1546 result(j) = octave_value_extract<T> (args(j));
1553 for (
int j = 0; j < n_args; j++)
1557 array_list[j] = octave_value_extract<TYPE> (args(j));
1564 template <
typename TYPE,
typename T>
1570 int n_args = args.
length ();
1573 for (
int j = 0; j < n_args; j++)
1577 sparse_list[j] = octave_value_extract<TYPE> (args(j));
1584 template <
typename TYPE>
1590 single_type_concat<TYPE, typename TYPE::element_type> (result, args, dim);
1595 template <
typename MAP>
1601 int n_args = args.
length ();
1604 for (
int j = 0; j < n_args; j++)
1608 map_list[j] = octave_value_extract<MAP> (args(j));
1620 single_type_concat_map<octave_scalar_map> (result, args, dim);
1622 single_type_concat_map<octave_map> (result, args, dim);
1651 catch (octave::execution_exception& e)
1653 error (e,
"conversion from %s to %s failed", dtype.c_str (),
1657 if (result.
empty ())
1658 error (
"conversion from %s to %s failed", dtype.c_str (),
1671 error (
"no constructor for %s!", dtype.c_str ());
1679 catch (octave::execution_exception& e)
1681 error (e,
"%s constructor failed for %s argument", dtype.c_str (),
1685 if (result.
empty ())
1686 error (
"%s constructor failed for %s argument", dtype.c_str (),
1718 catch (octave::execution_exception& e)
1720 error (e,
"%s/%s method failed", dtype.c_str (), cattype.c_str ());
1724 error (
"%s/%s method did not return a value", dtype.c_str (),
1744 if (t1_type == dtype)
1754 std::string cname = tmp(0).class_name ();
1755 std::list<std::string> parents = tmp(0).parent_class_name_list ();
1773 int n_args = args.
length ();
1777 else if (n_args == 1)
1779 else if (n_args > 1)
1781 std::string result_type;
1783 bool all_strings_p =
true;
1784 bool all_sq_strings_p =
true;
1785 bool all_dq_strings_p =
true;
1786 bool all_real_p =
true;
1787 bool all_cmplx_p =
true;
1788 bool any_sparse_p =
false;
1789 bool any_cell_p =
false;
1790 bool any_class_p =
false;
1792 bool first_elem_is_struct =
false;
1794 for (
int i = 0; i < n_args; i++)
1798 result_type = args(i).class_name ();
1800 first_elem_is_struct = args(i).isstruct ();
1805 if (all_strings_p && ! args(i).is_string ())
1806 all_strings_p =
false;
1807 if (all_sq_strings_p && ! args(i).is_sq_string ())
1808 all_sq_strings_p =
false;
1809 if (all_dq_strings_p && ! args(i).is_dq_string ())
1810 all_dq_strings_p =
false;
1811 if (all_real_p && ! args(i).isreal ())
1813 if (all_cmplx_p && ! (args(i).iscomplex ()
1814 || args(i).isreal ()))
1815 all_cmplx_p =
false;
1816 if (! any_sparse_p && args(i).issparse ())
1817 any_sparse_p =
true;
1818 if (! any_cell_p && args(i).iscell ())
1820 if (! any_class_p && args(i).isobject ())
1824 if (any_cell_p && ! any_class_p && ! first_elem_is_struct)
1827 for (
int i = 0; i < n_args; i++)
1829 if (args(i).iscell ())
1830 args(j++) = args(i);
1833 if (args(i).isempty ())
1836 args(j++) =
Cell (args(i));
1847 else if (result_type ==
"double")
1852 retval = do_single_type_concat<SparseMatrix> (args, dim);
1854 retval = do_single_type_concat<SparseComplexMatrix> (args, dim);
1859 retval = do_single_type_concat<NDArray> (args, dim);
1861 retval = do_single_type_concat<ComplexNDArray> (args, dim);
1864 else if (result_type ==
"single")
1867 retval = do_single_type_concat<FloatNDArray> (args, dim);
1869 retval = do_single_type_concat<FloatComplexNDArray> (args, dim);
1871 else if (result_type ==
"char")
1873 char type = (all_dq_strings_p ?
'"' :
'\'');
1875 if (! all_strings_p)
1877 "numeric", result_type);
1881 charNDArray result = do_single_type_concat<charNDArray> (args, dim);
1885 else if (result_type ==
"logical")
1888 retval = do_single_type_concat<SparseBoolMatrix> (args, dim);
1890 retval = do_single_type_concat<boolNDArray> (args, dim);
1892 else if (result_type ==
"int8")
1893 retval = do_single_type_concat<int8NDArray> (args, dim);
1894 else if (result_type ==
"int16")
1895 retval = do_single_type_concat<int16NDArray> (args, dim);
1896 else if (result_type ==
"int32")
1897 retval = do_single_type_concat<int32NDArray> (args, dim);
1898 else if (result_type ==
"int64")
1899 retval = do_single_type_concat<int64NDArray> (args, dim);
1900 else if (result_type ==
"uint8")
1901 retval = do_single_type_concat<uint8NDArray> (args, dim);
1902 else if (result_type ==
"uint16")
1903 retval = do_single_type_concat<uint16NDArray> (args, dim);
1904 else if (result_type ==
"uint32")
1905 retval = do_single_type_concat<uint32NDArray> (args, dim);
1906 else if (result_type ==
"uint64")
1907 retval = do_single_type_concat<uint64NDArray> (args, dim);
1908 else if (result_type ==
"cell")
1909 retval = do_single_type_concat<Cell> (args, dim);
1910 else if (result_type ==
"struct")
1920 if (dim == -1 || dim == -2)
1926 for (
int i = 1; i < args.
length (); i++)
1928 if (! (dv.*concat_rule) (args(i).dims (), dim))
1929 error (
"cat: dimension mismatch");
1950 int dv_len = dv.
ndims ();
1953 for (
int j = 0; j < n_args; j++)
1965 error (
"%s: indexing error", fname.c_str ());
1970 ra_idx(dim) += (dim < dv_tmp.
ndims () ? dv_tmp(dim) : 1);
1981 DEFUN (horzcat, args, ,
1996 return do_cat (args, -2,
"horzcat");
2220 DEFUN (vertcat, args, ,
2235 return do_cat (args, -1,
"vertcat");
2290 if (args.length () == 0)
2293 int dim = args(0).xint_value (
"cat: DIM must be an integer") - 1;
2296 error (
"cat: DIM must be a valid dimension");
2298 return ovl (
do_cat (args.slice (1, args.length () - 1), dim,
"cat"));
2453 if (args.
length () != 2 || args(1).
length () < args(1).ndims ())
2456 Array<int> vec = args(1).int_vector_value ();
2461 for (
int i = 0; i <
n; i++)
2467 DEFUN (permute, args, ,
2500 DEFUN (ipermute, args, ,
2531 if (args.length () != 1)
2537 DEFUN (ndims, args, ,
2555 if (args.length () != 1)
2565 while ((ndims > 2) && (sz(ndims - 1) == 1))
2620 int nargin = args.length ();
2629 else if (nargin > 1)
2634 args.slice (1, nargin-1));
2640 DEFUN (size, args, nargout,
2702 int nargin = args.length ();
2706 const dim_vector dimensions = args(0).dims ();
2712 for (
int i = 0; i < nargout; i++)
2717 int ndims = dimensions.
ndims ();
2721 for (
int i = 0; i < ndims; i++)
2722 m.xelem (i) = dimensions(i);
2727 else if (nargin == 2 && nargout < 2)
2729 if (! args(1).is_real_scalar ())
2730 error (
"size: DIM must be a positive integer");
2737 error (
"size: requested dimension DIM (= %" OCTAVE_IDX_TYPE_FORMAT
") "
2738 "out of range", nd);
2740 if (nd <= dv.
ndims ())
2751 DEFUN (size_equal, args, ,
2761 int nargin = args.length ();
2767 for (
int i = 1; i < nargin; ++i)
2771 if (a_dims != b_dims)
2786 if (args.length () != 1)
2789 return ovl (args(0).nnz ());
2808 DEFUN (nzmax, args, ,
2822 if (args.length () != 1)
2825 return ovl (args(0).nzmax ());
2828 DEFUN (rows, args, ,
2836 if (args.length () != 1)
2872 DEFUN (columns, args, ,
2880 if (args.length () != 1)
2928 int nargin = args.length ();
2930 bool isnative =
false;
2931 bool isdouble =
false;
2932 bool isextra =
false;
2934 if (nargin > 1 && args(nargin - 1).is_string ())
2936 std::string str = args(nargin - 1).string_value ();
2938 if (str ==
"native")
2940 else if (str ==
"double")
2942 else if (str ==
"extra")
2945 error (
"sum: unrecognized type argument '%s'", str.c_str ());
2950 if (nargin < 1 || nargin > 2)
2956 dim = args(1).int_value () - 1;
2958 error (
"sum: invalid dimension DIM = %d", dim + 1);
2970 warning (
"sum: 'extra' not yet implemented for sparse matrices");
2983 warning (
"sum: 'extra' not yet implemented for sparse matrices");
2993 if (isdouble || isextra)
3000 if (isdouble || isextra)
3006 #define MAKE_INT_BRANCH(X) \
3009 retval = arg.X ## _array_value ().sum (dim); \
3011 retval = arg.X ## _array_value ().dsum (dim); \
3023 #undef MAKE_INT_BRANCH
3119 DEFUN (sumsq, args, ,
3159 DEFUN (islogical, args, ,
3167 if (args.length () != 1)
3170 return ovl (args(0).islogical ());
3199 if (args.length () != 1)
3247 DEFUN (iscomplex, args, ,
3254 if (args.length () != 1)
3257 return ovl (args(0).iscomplex ());
3277 DEFUN (isfloat, args, ,
3286 if (args.length () != 1)
3289 return ovl (args(0).isfloat ());
3295 DEFUN (complex, args, ,
3319 int nargin = args.length ();
3321 if (nargin < 1 || nargin > 2)
3342 if (arg.
numel () == 1)
3357 if (arg.
numel () == 1)
3382 if (re.
numel () == 1)
3385 if (re_val.
nnz () == 0)
3397 i < im_val.
cidx (j + 1); i++)
3398 result.
data (im_val.
ridx (i) + off)
3404 else if (im.
numel () == 1)
3407 if (im_val.
nnz () == 0)
3420 i < re_val.
cidx (j + 1); i++)
3421 result.
data (re_val.
ridx (i) + off)
3429 if (re_val.
dims () != im_val.
dims ())
3430 error (
"complex: dimension mismatch");
3440 if (re.
numel () == 1)
3444 if (im.
numel () == 1)
3469 if (im.
numel () == 1)
3486 if (re_val.
dims () != im_val.
dims ())
3487 error (
"complex: dimension mismatch");
3501 else if (re.
numel () == 1)
3505 if (im.
numel () == 1)
3528 if (im.
numel () == 1)
3543 if (re_val.
dims () != im_val.
dims ())
3544 error (
"complex: dimension mismatch");
3602 DEFUN (isreal, args, ,
3612 if (args.length () != 1)
3615 return ovl (args(0).isreal ());
3618 DEFUN (isempty, args, ,
3626 if (args.length () != 1)
3629 return ovl (args(0).isempty ());
3637 DEFUN (isnumeric, args, ,
3647 if (args.length () != 1)
3650 return ovl (args(0).isnumeric ());
3669 DEFUN (isscalar, args, ,
3679 if (args.length () != 1)
3686 return ovl (sz.
numel () == 2 && sz(0) == 1 && sz(1) == 1);
3719 if (args.length () != 1)
3726 return ovl (sz.
numel () == 2 && (sz(0) == 1 || sz(1) == 1));
3749 DEFUN (isrow, args, ,
3759 if (args.length () != 1)
3766 return ovl (sz.
numel () == 2 && sz(0) == 1);
3798 DEFUN (iscolumn, args, ,
3808 if (args.length () != 1)
3815 return ovl (sz.
numel () == 2 && sz(1) == 1);
3847 DEFUN (ismatrix, args, ,
3858 if (args.length () != 1)
3865 return ovl (sz.
numel () == 2 && sz(0) >= 0 && sz(1) >= 0);
3896 DEFUN (issquare, args, ,
3906 if (args.length () != 1)
3913 return ovl (sz.
numel () == 2 && sz(0) == sz(1));
3942 int nargin = args.
length ();
3948 if (nargin > 0 && args(nargin-1).is_string ())
3950 std::string nm = args(nargin-1).string_value ();
3969 for (
int i = 0; i < nargin; i++)
3970 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4025 if (dims.
ndims () == 2 && dims(0) == 1)
4026 retval =
Range (
static_cast<double> (val), 0.0, dims(1));
4037 error (
"%s: invalid class name", fcn);
4050 int nargin = args.
length ();
4056 if (nargin > 0 && args(nargin-1).is_string ())
4058 std::string nm = args(nargin-1).string_value ();
4077 for (
int i = 0; i < nargin; i++)
4078 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4104 error (
"%s: invalid class name", fcn);
4116 int nargin = args.
length ();
4122 if (nargin > 0 && args(nargin-1).is_string ())
4124 std::string nm = args(nargin-1).string_value ();
4143 for (
int i = 0; i < nargin; i++)
4144 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4170 error (
"%s: invalid class name", fcn);
4183 int nargin = args.
length ();
4189 if (nargin > 0 && args(nargin-1).is_string ())
4191 std::string nm = args(nargin-1).string_value ();
4210 for (
int i = 0; i < nargin; i++)
4211 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4235 error (
"%s: invalid class name", fcn);
4247 int nargin = args.
length ();
4264 for (
int i = 0; i < nargin; i++)
4265 dims(i) = (args(i).isempty () ? 0 : args(i).idx_type_value (
true));
4282 DEFUN (ones, args, ,
4357 DEFUN (zeros, args, ,
4570 double e_val = exp (1.0);
4576 template <
typename T>
4580 T epsval =
x.abs ();
4581 typedef typename T::value_type P;
4584 P val = epsval.xelem (i);
4588 epsval(i) = std::numeric_limits<P>::denorm_min ();
4593 const P digits = std::numeric_limits<P>::digits;
4594 epsval(i) =
std::pow (
static_cast<P
> (2.0),
4595 static_cast<P
> (exponent - digits));
4638 if (args.length () == 1 && ! args(0).is_string ())
4652 error (
"eps: X must be of a floating point type");
4656 std::numeric_limits<float>::epsilon (),
"eps");
4726 double pi_val = M_PI;
4728 double pi_val = 4.0 *
atan (1.0);
4734 DEFUN (realmax, args, ,
4773 DEFUN (realmin, args, ,
4893 DEFUN (
false, args, ,
4911 DEFUN (
true, args, ,
4929 template <
typename MT>
4935 typename MT::element_type one (1);
4937 if (nr == 1 && nc == 1)
4943 typename MT::element_type zero (0);
4947 if (nr > 0 && nc > 0)
4951 for (
int i = 0; i <
n; i++)
4961 #define INSTANTIATE_EYE(T) \
4962 template octave_value identity_matrix<T> (int, int)
5031 error (
"eye: invalid class name");
5038 #undef INT_EYE_MATRIX
5090 int nargin = args.length ();
5096 if (nargin > 0 && args(nargin-1).is_string ())
5098 std::string nm = args(nargin-1).string_value ();
5111 else if (nargin == 1)
5146 template <
typename MT>
5151 typedef typename MT::column_vector_type CVT;
5152 typedef typename MT::element_type T;
5158 T bs = octave_value_extract<T> (base);
5161 T ls = octave_value_extract<T> (limit);
5166 CVT lv = octave_value_extract<CVT> (limit);
5167 CVT bv (lv.numel (), bs);
5173 CVT bv = octave_value_extract<CVT> (base);
5176 T ls = octave_value_extract<T> (limit);
5177 CVT lv (bv.numel (), ls);
5182 CVT lv = octave_value_extract<CVT> (limit);
5213 int nargin = args.length ();
5215 if (nargin != 2 && nargin != 3)
5228 error (
"linspace: N must be a scalar");
5238 bool isvector1 = sz1.
ndims () == 2 && (sz1(0) == 1 || sz1(1) == 1);
5240 bool isvector2 = sz2.
ndims () == 2 && (sz2(0) == 1 || sz2(1) == 1);
5242 if (! isvector1 || ! isvector2)
5243 error (
"linspace: START, END must be scalars or vectors");
5250 retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
5252 retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
5257 retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
5259 retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
5367 DEFUN (resize, args, ,
5414 int nargin = args.length ();
5424 int ndim = vec.
numel ();
5435 for (
int i = 0; i < ndim; i++)
5457 DEFUN (reshape, args, ,
5491 int nargin = args.length ();
5504 if (new_size.
numel () < 2)
5505 error (
"reshape: SIZE must have 2 or more dimensions");
5511 if (new_size(i) < 0)
5512 error (
"reshape: SIZE must be non-negative");
5514 new_dims(i) = new_size(i);
5522 for (
int i = 1; i < nargin; i++)
5524 if (args(i).isempty ())
5527 error (
"reshape: only a single dimension can be unknown");
5534 new_dims(i-1) = args(i).idx_type_value ();
5536 if (new_dims(i-1) < 0)
5537 error (
"reshape: SIZE must be non-negative");
5546 new_dims(empty_dim-1) = 0;
5552 if (a_nel != size_empty_dim * nel)
5553 error (
"reshape: SIZE is not divisible by the product of "
5554 "known dimensions (= %" OCTAVE_IDX_TYPE_FORMAT
")",
5557 new_dims(empty_dim-1) = size_empty_dim;
5606 int nargin = args.length ();
5608 if (nargin < 1 || nargin > 2)
5614 dim = args(1).idx_type_value ();
5617 error (
"vec: DIM must be greater than zero");
5629 for (
int i = 0; i < dim-1; i++)
5655 DEFUN (squeeze, args, ,
5665 if (args.length () != 1)
5668 return ovl (args(0).squeeze ());
5671 DEFUN (full, args, ,
5679 if (args.length () != 1)
5682 return ovl (args(0).full_value ());
5748 int nargin = args.length ();
5750 if (nargin < 1 || nargin > 3)
5755 if (x_arg.
ndims () != 2)
5756 error (
"norm: only valid for 2-D objects");
5758 enum {sfmatrix, sfcols, sfrows, sffrob, sfinf, sfneginf} strflag = sfmatrix;
5759 if (nargin > 1 && args(nargin-1).is_string ())
5761 std::string str = args(nargin-1).string_value ();
5762 std::transform (str.begin (), str.end (), str.begin (), tolower);
5763 if (str ==
"cols" || str ==
"columns")
5765 else if (str ==
"rows")
5767 else if (str ==
"fro")
5769 else if (str ==
"inf")
5771 else if (str ==
"-inf")
5774 error (
"norm: unrecognized option: %s", str.c_str ());
5787 std::transform (str.begin (), str.end (), str.begin (), tolower);
5788 if (strflag != sfcols && strflag != sfrows)
5789 error (
"norm: invalid combination of options");
5791 if (str ==
"cols" || str ==
"columns" || str ==
"rows")
5792 error (
"norm: invalid combination of options");
5796 else if (str ==
"inf")
5798 else if (str ==
"-inf")
5801 error (
"norm: unrecognized option: %s", str.c_str ());
5949 DEFUN (uplus, args, ,
5959 DEFUN (uminus, args, ,
6001 DEFUN (ctranspose, args, ,
6048 int nargin = args.
length ();
6061 for (
int i = 2; i < nargin; i++)
6068 DEFUN (plus, args, ,
6099 DEFUN (minus, args, ,
6109 DEFUN (mtimes, args, ,
6130 DEFUN (mrdivide, args, ,
6142 DEFUN (mpower, args, ,
6154 DEFUN (mldivide, args, ,
6230 DEFUN (times, args, ,
6251 DEFUN (rdivide, args, ,
6263 DEFUN (power, args, ,
6281 DEFUN (ldivide, args, ,
6336 DEFUN (colon, args, ,
6349 int nargin = args.length ();
6351 if (nargin < 2 || nargin > 3)
6354 return (nargin == 2 ?
do_colon_op (args(0), args(1))
6360 DEFUN (tic, args, nargout,
6412 if (args.length () != 0)
6413 warning (
"tic: ignoring extra arguments");
6422 double frac = std::modf (tmp, &ip);
6423 uint64_t microsecs =
static_cast<uint64_t
> (CLOCKS_PER_SEC * frac);
6424 microsecs += CLOCKS_PER_SEC *
static_cast<uint64_t
> (ip);
6433 DEFUN (toc, args, nargout,
6451 int nargin = args.length ();
6460 octave_uint64 id = args(0).xuint64_scalar_value (
"toc: invalid ID");
6462 uint64_t val =
id.
value ();
6465 = (
static_cast<double> (val / CLOCKS_PER_SEC)
6466 +
static_cast<double> (val % CLOCKS_PER_SEC)
6474 error (
"toc called before timer set");
6484 octave_stdout <<
"Elapsed time is " << etime <<
" seconds.\n";
6496 DEFUN (cputime, args, ,
6515 if (args.length () != 0)
6520 double usr = cpu_tm.
user ();
6521 double sys = cpu_tm.
system ();
6523 return ovl (usr + sys, usr, sys);
6526 DEFUN (sort, args, nargout,
6596 int nargin = args.length ();
6598 if (nargin < 1 || nargin > 3)
6602 bool return_idx = (nargout > 1);
6603 bool have_sortmode = (nargin > 1 && args(1).is_string ());
6611 std::string mode = args(1).string_value ();
6612 if (mode ==
"ascend")
6614 else if (mode ==
"descend")
6617 error (R
"(sort: MODE must be either "ascend" or "descend")");
6620 dim = args(1).nint_value () - 1;
6626 error (
"sort: DIM must be a valid dimension");
6628 std::string mode = args(2).xstring_value (
"sort: MODE must be a string");
6630 if (mode ==
"ascend")
6632 else if (mode ==
"descend")
6635 error (R
"(sort: MODE must be either "ascend" or "descend")");
6639 if (nargin == 1 || have_sortmode)
6646 error (
"sort: DIM must be a valid dimension");
6848 DEFUN (__sort_rows_idx__, args, ,
6854 int nargin = args.length ();
6856 if (nargin < 1 || nargin > 2)
6859 if (nargin == 2 && ! args(1).is_string ())
6860 error (
"__sort_rows_idx__: second argument must be a string");
6865 std::string mode = args(1).string_value ();
6866 if (mode ==
"ascend")
6868 else if (mode ==
"descend")
6871 error (R
"(__sort_rows_idx__: MODE must be either "ascend" or "descend")");
6877 error (
"__sort_rows_idx__: sparse matrices not yet supported");
6879 if (arg.
ndims () != 2)
6880 error (
"__sort_rows_idx__: needs a 2-D object");
6896 std::string mode = arg.
xstring_value (
"issorted: MODE must be a string");
6898 if (mode ==
"ascend")
6900 else if (mode ==
"descend")
6902 else if (mode ==
"either")
6905 error (R
"(issorted: MODE must be "ascend", "descend", or "either")");
6910 DEFUN (issorted, args, ,
6928 int nargin = args.length ();
6930 if (nargin < 1 || nargin > 3)
6933 bool by_rows =
false;
6942 std::string tmp = args(1).xstring_value (
"issorted: second argument must be a string");
6958 error (
"issorted: sparse matrices not yet supported");
6960 if (arg.
ndims () != 2)
6961 error (
"issorted: A must be a 2-D object");
6968 error (
"issorted: needs a vector");
7039 DEFUN (nth_element, args, ,
7063 int nargin = args.length ();
7065 if (nargin < 2 || nargin > 3)
7071 dim = args(2).int_value (
true) - 1;
7073 error (
"nth_element: DIM must be a valid dimension");
7101 #define MAKE_INT_BRANCH(X) \
7103 retval = argx.X ## _array_value ().nth_element (n, dim); \
7116 #undef MAKE_INT_BRANCH
7127 error (
"nth_element: invalid index %s", e.what ());
7148 template <
typename NDT>
7153 typedef typename NDT::element_type T;
7157 error (
"accumarray: index out of range");
7161 if (vals.numel () == 1)
7162 retval.idx_add (idx, vals (0));
7163 else if (vals.numel () == idx.
length (
n))
7164 retval.idx_add (idx, vals);
7166 error (
"accumarray: dimensions mismatch");
7171 DEFUN (__accumarray_sum__, args, ,
7177 int nargin = args.length ();
7179 if (nargin < 2 || nargin > 3)
7182 if (! args(0).isnumeric ())
7183 error (
"__accumarray_sum__: first argument must be numeric");
7192 n = args(2).idx_type_value (
true);
7226 error (
"__accumarray_sum__: invalid index %s", e.what ());
7232 template <
typename NDT>
7236 const typename NDT::element_type& zero_val)
7238 typedef typename NDT::element_type T;
7242 error (
"accumarray: index out of range");
7251 if (vals.numel () == 1)
7253 else if (vals.numel () == l)
7254 (
retval.*op) (idx, vals);
7256 error (
"accumarray: dimensions mismatch");
7265 int nargin = args.
length ();
7267 if (nargin < 3 || nargin > 4)
7270 if (! args(0).isnumeric ())
7271 error (
"accumarray: first argument must be numeric");
7280 n = args(3).idx_type_value (
true);
7309 #define MAKE_INT_BRANCH(X) \
7311 retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
7312 n, ismin, zero.X ## _scalar_value ()); \
7324 #undef MAKE_INT_BRANCH
7337 error (
"do_accumarray_minmax_fun: invalid index %s", e.what ());
7343 DEFUN (__accumarray_min__, args, ,
7352 DEFUN (__accumarray_max__, args, ,
7361 template <
typename NDT>
7366 typedef typename NDT::element_type T;
7370 error (
"accumdim: index out of range");
7377 else if (dim >= rdv.
ndims ())
7384 if (idx.
length () != vals_dim(dim))
7385 error (
"accumdim: dimension mismatch");
7387 retval.idx_add_nd (idx, vals, dim);
7392 DEFUN (__accumdim_sum__, args, ,
7398 int nargin = args.length ();
7400 if (nargin < 2 || nargin > 4)
7403 if (! args(0).isnumeric ())
7404 error (
"__accumdim_sum__: first argument must be numeric");
7413 dim = args(2).int_value () - 1;
7417 n = args(3).idx_type_value (
true);
7444 error (
"__accumdim_sum__: invalid index %s", e.what ());
7450 template <
typename NDT>
7453 const NDT& tval,
const NDT& fval)
7455 typedef typename NDT::element_type T;
7459 bool tscl = tval.numel () == 1;
7460 bool fscl = fval.numel () == 1;
7462 if ((! tscl && tval.dims () != dv) || (! fscl && fval.dims () != dv))
7463 error (
"merge: MASK, TVAL, and FVAL dimensions must match");
7468 const T *tv = tval.data ();
7469 const T *fv = fval.data ();
7470 const bool *mv = mask.
data ();
7479 rv[i] = (mv[i] ? ts : fs);
7485 rv[i] = (mv[i] ? ts : fv[i]);
7494 rv[i] = (mv[i] ? tv[i] : fs);
7499 rv[i] = (mv[i] ? tv[i] : fv[i]);
7506 #define MAKE_INT_BRANCH(INTX) \
7507 else if (tval.is_ ## INTX ## _type () && fval.is_ ## INTX ## _type ()) \
7509 retval = do_merge (mask, \
7510 tval.INTX ## _array_value (), \
7511 fval.INTX ## _array_value ()); \
7514 DEFUN (merge, args, ,
7543 if (args.length () != 3)
7546 if (! (args(0).islogical () || args(0).isnumeric ()))
7547 error (
"merge: first argument must be logical or numeric");
7590 sq_string ?
'\'' :
'"');
7609 error (
"merge: cannot merge %s with %s with array mask",
7619 #undef MAKE_INT_BRANCH
7621 template <
typename SparseT>
7630 while (order > 0 && k > 0)
7632 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7643 while (order > 0 && k > 0)
7645 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7669 if (dv(dim) <= order)
7678 if (dim == dv.
ndims ())
7683 else if (dv(dim) == 1)
7688 order -= dv(dim) - 1;
7745 DEFUN (diff, args, ,
7777 int nargin = args.length ();
7779 if (nargin < 1 || nargin > 3)
7782 if (! (args(0).isnumeric () || args(0).islogical ()))
7783 error (
"diff: X must be numeric or logical");
7789 if (args(1).is_scalar_type ())
7790 order = args(1).idx_type_value (
true,
false);
7791 else if (! args(1).is_zero_by_zero ())
7792 error (
"diff: order K must be a scalar or []");
7794 error (
"diff: order K must be non-negative");
7799 dim = args(2).int_value (
true,
false);
7800 if (dim < 1 || dim > args(0).ndims ())
7801 error (
"diff: DIM must be a valid dimension");
7806 return do_diff (args(0), order, dim);
7822 template <
typename T>
7828 assert (rep.
ndims () == 2 && rep.
rows () == 2);
7836 error (
"repelems: second row must contain non-negative numbers");
7847 std::fill_n (dest, k, src.
checkelem (rep(0, i) - 1));
7854 DEFUN (repelems, args, ,
7880 if (args.length () != 2)
7885 const Matrix rm = args(1).matrix_value ();
7887 if (rm.
rows () != 2 || rm.
ndims () != 2)
7888 error (
"repelems: R must be a matrix with two rows");
7897 if (
static_cast<double> (rx) != rm(i))
7898 error (
"repelems: R must be a matrix of integers");
7903 switch (
x.builtin_type ())
7905 #define BTYP_BRANCH(X, EX) \
7907 retval = do_repelems (x.EX ## _value (), r); \
7947 if (args.length () != 1)
7950 if (! args(0).isnumeric ())
7951 error (
"base64_encode: encoding is supported only for numeric arrays");
7953 if (args(0).iscomplex () || args(0).issparse ())
7954 error (
"base64_encode: encoding complex or sparse data is not supported");
7960 #define MAKE_INT_BRANCH(X) \
7961 if (args(0).is_ ## X ## _type ()) \
7963 const X##NDArray in = args(0). X## _array_value (); \
7964 size_t inlen = in.numel () * sizeof (X## _t) / sizeof (char); \
7965 const char *inc = reinterpret_cast<const char *> (in.data ()); \
7967 if (octave::base64_encode (inc, inlen, &out)) \
7969 retval(0) = octave_value (out); \
7983 #undef MAKE_INT_BRANCH
7988 else if (args(0).is_single_type ())
7992 inlen = in.
numel () *
sizeof (float) /
sizeof (
char);
7994 inc =
reinterpret_cast<const char *
> (in.
data ());
8006 inlen = in.
numel () *
sizeof (double) /
sizeof (
char);
8008 inc =
reinterpret_cast<const char *
> (in.
data ());
8055 int nargin = args.length ();
8057 if (nargin < 1 || nargin > 2)
8060 std::string str = args(0).string_value ();
8069 = args(1).octave_idx_type_vector_value ();
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)
N Dimensional Array with copy-on-write semantics.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
sortmode issorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
void assign(const idx_vector &i, const Array< T > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
octave_idx_type columns(void) const
T & xelem(octave_idx_type n)
Size of the specified dimension.
Array< T > nth_element(const idx_vector &n, int dim=0) const
Returns the n-th element in increasing order, using the same ordering as used for sort.
octave_idx_type numel(void) const
Number of elements in the array.
const T * data(void) const
Size of the specified dimension.
T & checkelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type rows(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int ndims(void) const
Size of the specified dimension.
const T * fortran_vec(void) const
Size of the specified dimension.
static Array< T > cat(int dim, octave_idx_type n, const Array< T > *array_list)
Concatenation along a specified (0-based) dimension, equivalent to cat().
ComplexNDArray prod(int dim=-1) const
ComplexNDArray cumsum(int dim=-1) const
ComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
ComplexNDArray xsum(int dim=-1) const
ComplexNDArray sum(int dim=-1) const
FloatComplexNDArray sum(int dim=-1) const
ComplexNDArray dsum(int dim=-1) const
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
FloatComplexNDArray prod(int dim=-1) const
FloatComplexNDArray cumsum(int dim=-1) const
ComplexNDArray dprod(int dim=-1) const
FloatNDArray sum(int dim=-1) const
FloatNDArray prod(int dim=-1) const
NDArray dprod(int dim=-1) const
FloatNDArray cumsum(int dim=-1) const
NDArray dsum(int dim=-1) const
FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
Template for N-dimensional array classes with like-type math operators.
NDArray diff(octave_idx_type order=1, int dim=-1) const
NDArray cumsum(int dim=-1) const
NDArray prod(int dim=-1) const
NDArray xsum(int dim=-1) const
NDArray sum(int dim=-1) const
SparseBoolMatrix all(int dim=-1) const
SparseMatrix sum(int dim=-1) const
SparseBoolMatrix any(int dim=-1) const
SparseComplexMatrix prod(int dim=-1) const
SparseComplexMatrix sum(int dim=-1) const
SparseComplexMatrix cumsum(int dim=-1) const
SparseMatrix sum(int dim=-1) const
SparseMatrix prod(int dim=-1) const
SparseMatrix cumsum(int dim=-1) const
static Sparse< T > cat(int dim, octave_idx_type n, const Sparse< T > *sparse_list)
octave_idx_type cols(void) const
octave_idx_type * cidx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type rows(void) const
dim_vector dims(void) const
octave_idx_type * ridx(void)
boolNDArray any(int dim=-1) const
boolNDArray all(int dim=-1) const
Vector representing the dimensions (size) of an Array.
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
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.
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
intNDArray diff(octave_idx_type order=1, int dim=-1) const
static data_type string_to_data_type(const std::string &s)
octave_value find_method(const std::string &name, const std::string &dispatch_type)
double system(void) const
double double_value(void) 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
FloatComplexNDArray xfloat_complex_array_value(const char *fmt,...) const
bool is_uint16_type(void) const
builtin_type_t builtin_type(void) 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
Complex xcomplex_value(const char *fmt,...) const
Range range_value(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
bool is_int64_type(void) const
float float_value(bool frc_str_conv=false) const
SparseComplexMatrix xsparse_complex_matrix_value(const char *fmt,...) const
int64NDArray int64_array_value(void) const
uint8NDArray uint8_array_value(void) 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
ComplexNDArray xcomplex_array_value(const char *fmt,...) const
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
octave_value single_subsref(const std::string &type, const octave_value_list &idx)
bool is_range(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
FloatComplex xfloat_complex_value(const char *fmt,...) const
bool is_single_type(void) const
uint32NDArray uint32_array_value(void) const
bool isobject(void) const
std::string xstring_value(const char *fmt,...) const
bool is_sq_string(void) const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) 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
#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)
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 do_class_concat(const octave_value_list &ovl, std::string cattype, int dim)
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 err_wrong_type_arg(const char *name, const char *s)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
double norm(const ColumnVector &v)
ColumnVector transform(const Matrix &m, double x, double y, double z)
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
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)
void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
static void check_dimensions(octave_idx_type &nr, octave_idx_type &nc, const char *warnfor)
std::string get_dispatch_type(const octave_value_list &args, builtin_type_t &builtin_type)
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.
symbol_table & __get_symbol_table__(const std::string &who)
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
bool base64_encode(const char *inc, const size_t inlen, char **out)
octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx_arg)
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_API RowVector xcolnorms(const Matrix &m, double p)
OCTAVE_API double xfrobnorm(const Matrix &x)
OCTAVE_API double xnorm(const ColumnVector &x, double p)
OCTAVE_API ColumnVector xrownorms(const Matrix &m, double p)
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()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value do_unary_op(octave::type_info &ti, octave_value::unary_op op, const octave_value &v)
OCTINTERP_API octave_value do_cat_op(octave::type_info &ti, const octave_value &a, const octave_value &b, const Array< octave_idx_type > &ra_idx)
OCTINTERP_API octave_value do_colon_op(const octave_value &base, const octave_value &limit, bool is_for_cmd_expr=false)
OCTINTERP_API octave_value do_binary_op(octave::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