26 #if defined (HAVE_CONFIG_H)
30 #include <sys/types.h>
67 #if ! defined (HAVE_HYPOTF) && defined (HAVE__HYPOTF)
68 # define hypotf _hypotf
69 # define HAVE_HYPOTF 1
75 error (fmt, idx.c_str (), msg.c_str ());
103 if (nargin < 1 || nargin > 2)
106 int dim = (nargin == 1 ? -1
107 :
args(1).int_value (
"all: DIM must be an integer")-1);
110 error (
"all: invalid dimension argument = %d", dim + 1);
112 return ovl (
args(0).all (dim));
168 if (nargin < 1 || nargin > 2)
171 int dim = (nargin == 1 ? -1
172 :
args(1).int_value (
"any: DIM must be an integer")-1);
175 error (
"any: invalid dimension argument = %d", dim + 1);
217 if (
args.length () != 2)
222 if (!
args(0).is_numeric_type ())
225 if (!
args(1).is_numeric_type ())
228 if (
args(0).is_complex_type () ||
args(1).is_complex_type ())
229 error (
"atan2: not defined for complex numbers");
231 if (
args(0).is_single_type () ||
args(1).is_single_type ())
233 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
234 retval = atan2f (
args(0).float_value (),
args(1).float_value ());
239 retval = binmap<float> (a0, a1, ::atan2f,
"atan2");
244 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
245 retval =
atan2 (
args(0).scalar_value (),
args(1).scalar_value ());
246 else if (
args(0).is_sparse_type ())
250 retval = binmap<double> (m0, m1,
::atan2,
"atan2");
256 retval = binmap<double> (a0, a1,
::atan2,
"atan2");
349 retval = binmap<float> (a0, a1, ::hypotf,
"hypot");
360 retval = binmap<double> (m0, m1, ::hypot,
"hypot");
366 retval = binmap<double> (a0, a1, ::hypot,
"hypot");
403 retval = do_hypot (
args(0),
args(1));
409 retval = do_hypot (retval,
args(
i));
454 template <
typename T,
typename ET>
492 if (
args.length () != 1)
499 else if (
args(0).is_single_type ())
501 if (
args(0).is_real_type ())
507 map_2_xlog2 (x, f, e);
510 else if (
args(0).is_complex_type ())
516 map_2_xlog2 (x, f, e);
520 else if (
args(0).is_real_type ())
526 map_2_xlog2 (x, f, e);
529 else if (
args(0).is_complex_type ())
535 map_2_xlog2 (x, f, e);
599 if (
args.length () != 2)
604 if (!
args(0).is_numeric_type ())
607 if (!
args(1).is_numeric_type ())
610 if (
args(0).is_complex_type () ||
args(1).is_complex_type ())
611 error (
"rem: not defined for complex numbers");
613 if (
args(0).is_integer_type () ||
args(1).is_integer_type ())
623 error (
"rem: cannot combine %s and %d",
624 args(0).class_name ().c_str (),
625 args(1).class_name ().c_str ());
629 #define MAKE_INT_BRANCH(X) \
632 X##NDArray a0 = args(0).X##_array_value (); \
633 X##NDArray a1 = args(1).X##_array_value (); \
634 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
647 #undef MAKE_INT_BRANCH
653 else if (
args(0).is_single_type () ||
args(1).is_single_type ())
655 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
661 retval = binmap<float> (a0, a1, octave::math::rem<float>,
"rem");
666 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
668 else if (
args(0).is_sparse_type () ||
args(1).is_sparse_type ())
672 retval = binmap<double> (m0, m1, octave::math::rem<double>,
"rem");
678 retval = binmap<double> (a0, a1, octave::math::rem<double>,
"rem");
778 if (
args.length () != 2)
783 if (!
args(0).is_numeric_type ())
786 if (!
args(1).is_numeric_type ())
789 if (
args(0).is_complex_type () ||
args(1).is_complex_type ())
790 error (
"mod: not defined for complex numbers");
792 if (
args(0).is_integer_type () ||
args(1).is_integer_type ())
802 error (
"mod: cannot combine %s and %d",
803 args(0).class_name ().c_str (),
804 args(1).class_name ().c_str ());
808 #define MAKE_INT_BRANCH(X) \
811 X##NDArray a0 = args(0).X##_array_value (); \
812 X##NDArray a1 = args(1).X##_array_value (); \
813 retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
826 #undef MAKE_INT_BRANCH
832 else if (
args(0).is_single_type () ||
args(1).is_single_type ())
834 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
840 retval = binmap<float> (a0, a1, octave::math::mod<float>,
"mod");
845 if (
args(0).is_scalar_type () &&
args(1).is_scalar_type ())
847 else if (
args(0).is_sparse_type () ||
args(1).is_sparse_type ())
851 retval = binmap<double> (m0, m1, octave::math::mod<double>,
"mod");
857 retval = binmap<double> (a0, a1, octave::math::mod<double>,
"mod");
916 #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \
917 (arg.is_ ## TYPE ## _type ()) \
919 TYPE ## NDArray tmp = arg. TYPE ##_array_value (); \
921 retval = tmp.FCN (DIM); \
924 #define NATIVE_REDUCTION(FCN, BOOL_FCN) \
926 int nargin = args.length (); \
928 bool isnative = false; \
929 bool isdouble = false; \
931 if (nargin > 1 && args(nargin - 1).is_string ()) \
933 std::string str = args(nargin - 1).string_value (); \
935 if (str == "native") \
937 else if (str == "double") \
940 error ("sum: unrecognized string argument"); \
945 if (nargin < 1 || nargin > 2) \
948 octave_value retval; \
950 octave_value arg = args(0); \
952 int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
955 error (#FCN ": invalid dimension argument = %d", dim + 1); \
957 if (arg.is_sparse_type ()) \
959 if (arg.is_real_type ()) \
961 SparseMatrix tmp = arg.sparse_matrix_value (); \
963 retval = tmp.FCN (dim); \
967 SparseComplexMatrix tmp \
968 = arg.sparse_complex_matrix_value (); \
970 retval = tmp.FCN (dim); \
977 if NATIVE_REDUCTION_1 (FCN, uint8, dim) \
978 else if NATIVE_REDUCTION_1 (FCN, uint16, dim) \
979 else if NATIVE_REDUCTION_1 (FCN, uint32, dim) \
980 else if NATIVE_REDUCTION_1 (FCN, uint64, dim) \
981 else if NATIVE_REDUCTION_1 (FCN, int8, dim) \
982 else if NATIVE_REDUCTION_1 (FCN, int16, dim) \
983 else if NATIVE_REDUCTION_1 (FCN, int32, dim) \
984 else if NATIVE_REDUCTION_1 (FCN, int64, dim) \
985 else if (arg.is_bool_type ()) \
987 boolNDArray tmp = arg.bool_array_value (); \
989 retval = boolNDArray (tmp.BOOL_FCN (dim)); \
991 else if (arg.is_char_matrix ()) \
993 error (#FCN, ": invalid char type"); \
995 else if (! isdouble && arg.is_single_type ()) \
997 if (arg.is_complex_type ()) \
999 FloatComplexNDArray tmp = \
1000 arg.float_complex_array_value (); \
1002 retval = tmp.FCN (dim); \
1004 else if (arg.is_real_type ()) \
1006 FloatNDArray tmp = arg.float_array_value (); \
1008 retval = tmp.FCN (dim); \
1011 else if (arg.is_complex_type ()) \
1013 ComplexNDArray tmp = arg.complex_array_value (); \
1015 retval = tmp.FCN (dim); \
1017 else if (arg.is_real_type ()) \
1019 NDArray tmp = arg.array_value (); \
1021 retval = tmp.FCN (dim); \
1024 err_wrong_type_arg (#FCN, arg); \
1026 else if (arg.is_bool_type ()) \
1028 boolNDArray tmp = arg.bool_array_value (); \
1030 retval = tmp.FCN (dim); \
1032 else if (! isdouble && arg.is_single_type ()) \
1034 if (arg.is_real_type ()) \
1036 FloatNDArray tmp = arg.float_array_value (); \
1038 retval = tmp.FCN (dim); \
1040 else if (arg.is_complex_type ()) \
1042 FloatComplexNDArray tmp = \
1043 arg.float_complex_array_value (); \
1045 retval = tmp.FCN (dim); \
1048 else if (arg.is_real_type ()) \
1050 NDArray tmp = arg.array_value (); \
1052 retval = tmp.FCN (dim); \
1054 else if (arg.is_complex_type ()) \
1056 ComplexNDArray tmp = arg.complex_array_value (); \
1058 retval = tmp.FCN (dim); \
1061 err_wrong_type_arg (#FCN, arg); \
1066 #define DATA_REDUCTION(FCN) \
1068 int nargin = args.length (); \
1070 if (nargin < 1 || nargin > 2) \
1073 octave_value retval; \
1075 octave_value arg = args(0); \
1077 int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
1080 error (#FCN ": invalid dimension argument = %d", dim + 1); \
1082 if (arg.is_real_type ()) \
1084 if (arg.is_sparse_type ()) \
1086 SparseMatrix tmp = arg.sparse_matrix_value (); \
1088 retval = tmp.FCN (dim); \
1090 else if (arg.is_single_type ()) \
1092 FloatNDArray tmp = arg.float_array_value (); \
1094 retval = tmp.FCN (dim); \
1098 NDArray tmp = arg.array_value (); \
1100 retval = tmp.FCN (dim); \
1103 else if (arg.is_complex_type ()) \
1105 if (arg.is_sparse_type ()) \
1107 SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
1109 retval = tmp.FCN (dim); \
1111 else if (arg.is_single_type ()) \
1113 FloatComplexNDArray tmp \
1114 = arg.float_complex_array_value (); \
1116 retval = tmp.FCN (dim); \
1120 ComplexNDArray tmp = arg.complex_array_value (); \
1122 retval = tmp.FCN (dim); \
1126 err_wrong_type_arg (#FCN, arg); \
1201 bool isnative =
false;
1202 bool isdouble =
false;
1204 if (nargin > 1 &&
args(nargin - 1).is_string ())
1208 if (str ==
"native")
1210 else if (str ==
"double")
1213 error (
"cumsum: unrecognized string argument");
1218 if (nargin < 1 || nargin > 2)
1224 dim =
args(1).int_value () - 1;
1226 error (
"cumsum: invalid dimension argument = %d", dim + 1);
1259 #define MAKE_INT_BRANCH(X) \
1262 retval = arg.X ## _array_value ().cumsum (dim); \
1264 retval = arg.array_value ().cumsum (dim); \
1276 #undef MAKE_INT_BRANCH
1357 int nargin =
args.length ();
1359 if (nargin < 1 || nargin > 3)
1365 retval =
args(0).diag ();
1366 else if (nargin == 2)
1370 retval =
args(0).diag (k);
1377 error (
"diag: V must be a vector");
1382 retval = arg0.
diag (m, n);
1484 int nargin =
args.length ();
1486 bool isnative =
false;
1487 bool isdouble =
false;
1489 if (nargin > 1 &&
args(nargin - 1).is_string ())
1493 if (str ==
"native")
1495 else if (str ==
"double")
1498 error (
"prod: unrecognized type argument '%s'", str.c_str ());
1503 if (nargin < 1 || nargin > 2)
1513 dim =
args(1).int_value () - 1;
1515 error (
"prod: invalid dimension DIM = %d", dim + 1);
1545 #define MAKE_INT_BRANCH(X) \
1548 retval = arg.X ## _array_value ().prod (dim); \
1550 retval = arg.array_value ().prod (dim); \
1562 #undef MAKE_INT_BRANCH
1661 int n_args = args.
length ();
1662 for (
int i = 0;
i < n_args;
i++)
1669 template <
typename TYPE,
typename T>
1675 int n_args = args.
length ();
1678 && all_scalar_1x1 (args))
1682 if (dim == -1 || dim == -2)
1690 for (
int j = 0; j < n_args; j++)
1694 result(j) = octave_value_extract<T> (
args(j));
1701 for (
int j = 0; j < n_args; j++)
1705 array_list[j] = octave_value_extract<TYPE> (
args(j));
1712 template <
typename TYPE,
typename T>
1718 int n_args = args.
length ();
1721 for (
int j = 0; j < n_args; j++)
1725 sparse_list[j] = octave_value_extract<TYPE> (
args(j));
1732 template <
typename TYPE>
1738 single_type_concat<TYPE, typename TYPE::element_type> (
result,
args, dim);
1743 template <
typename MAP>
1749 int n_args = args.
length ();
1752 for (
int j = 0; j < n_args; j++)
1756 map_list[j] = octave_value_extract<MAP> (
args(j));
1767 if (all_scalar_1x1 (args))
1768 single_type_concat_map<octave_scalar_map> (
result,
args, dim);
1770 single_type_concat_map<octave_map> (
result,
args, dim);
1796 catch (octave::execution_exception& e)
1798 error (e,
"conversion from %s to %s failed", dtype.c_str (),
1802 if (result.
empty ())
1803 error (
"conversion from %s to %s failed", dtype.c_str (),
1816 error (
"no constructor for %s!", dtype.c_str ());
1824 catch (octave::execution_exception& e)
1826 error (e,
"%s constructor failed for %s argument", dtype.c_str (),
1830 if (result.
empty ())
1831 error (
"%s constructor failed for %s argument", dtype.c_str (),
1861 catch (octave::execution_exception& e)
1863 error (e,
"%s/%s method failed", dtype.c_str (), cattype.c_str ());
1867 error (
"%s/%s method did not return a value", dtype.c_str (),
1887 if (t1_type == dtype)
1890 tmp(j++) = attempt_type_conversion (elt, dtype);
1898 std::list<std::string> parents =
tmp(0).parent_class_name_list ();
1916 int n_args = args.
length ();
1920 else if (n_args == 1)
1922 else if (n_args > 1)
1926 bool all_strings_p =
true;
1927 bool all_sq_strings_p =
true;
1928 bool all_dq_strings_p =
true;
1929 bool all_real_p =
true;
1930 bool all_cmplx_p =
true;
1931 bool any_sparse_p =
false;
1932 bool any_cell_p =
false;
1933 bool any_class_p =
false;
1935 bool first_elem_is_struct =
false;
1937 for (
int i = 0;
i < n_args;
i++)
1941 result_type =
args(
i).class_name ();
1943 first_elem_is_struct =
args(
i).is_map ();
1948 if (all_strings_p && !
args(
i).is_string ())
1949 all_strings_p =
false;
1950 if (all_sq_strings_p && !
args(
i).is_sq_string ())
1951 all_sq_strings_p =
false;
1952 if (all_dq_strings_p && !
args(
i).is_dq_string ())
1953 all_dq_strings_p =
false;
1954 if (all_real_p && !
args(
i).is_real_type ())
1956 if (all_cmplx_p && ! (
args(
i).is_complex_type ()
1957 ||
args(
i).is_real_type ()))
1958 all_cmplx_p =
false;
1959 if (! any_sparse_p &&
args(
i).is_sparse_type ())
1960 any_sparse_p =
true;
1961 if (! any_cell_p &&
args(
i).is_cell ())
1963 if (! any_class_p &&
args(
i).is_object ())
1967 if (any_cell_p && ! any_class_p && ! first_elem_is_struct)
1969 for (
int i = 0;
i < n_args;
i++)
1971 if (!
args(
i).is_cell ())
1980 else if (result_type ==
"double")
1985 retval = do_single_type_concat<SparseMatrix> (
args, dim);
1987 retval = do_single_type_concat<SparseComplexMatrix> (
args, dim);
1992 retval = do_single_type_concat<NDArray> (
args, dim);
1994 retval = do_single_type_concat<ComplexNDArray> (
args, dim);
1997 else if (result_type ==
"single")
2000 retval = do_single_type_concat<FloatNDArray> (
args, dim);
2002 retval = do_single_type_concat<FloatComplexNDArray> (
args, dim);
2004 else if (result_type ==
"char")
2006 char type = all_dq_strings_p ?
'"' :
'\'';
2008 if (! all_strings_p)
2010 "numeric", result_type);
2018 else if (result_type ==
"logical")
2021 retval = do_single_type_concat<SparseBoolMatrix> (
args, dim);
2023 retval = do_single_type_concat<boolNDArray> (
args, dim);
2025 else if (result_type ==
"int8")
2026 retval = do_single_type_concat<int8NDArray> (
args, dim);
2027 else if (result_type ==
"int16")
2028 retval = do_single_type_concat<int16NDArray> (
args, dim);
2029 else if (result_type ==
"int32")
2030 retval = do_single_type_concat<int32NDArray> (
args, dim);
2031 else if (result_type ==
"int64")
2032 retval = do_single_type_concat<int64NDArray> (
args, dim);
2033 else if (result_type ==
"uint8")
2034 retval = do_single_type_concat<uint8NDArray> (
args, dim);
2035 else if (result_type ==
"uint16")
2036 retval = do_single_type_concat<uint16NDArray> (
args, dim);
2037 else if (result_type ==
"uint32")
2038 retval = do_single_type_concat<uint32NDArray> (
args, dim);
2039 else if (result_type ==
"uint64")
2040 retval = do_single_type_concat<uint64NDArray> (
args, dim);
2041 else if (result_type ==
"cell")
2042 retval = do_single_type_concat<Cell> (
args, dim);
2043 else if (result_type ==
"struct")
2044 retval = do_single_type_concat_map (args, dim);
2053 if (dim == -1 || dim == -2)
2059 for (
int i = 1;
i < args.length ();
i++)
2061 if (! (dv.*concat_rule) (
args(
i).dims (), dim))
2062 error (
"cat: dimension mismatch");
2082 int dv_len = dv.
ndims ();
2085 for (
int j = 0; j < n_args; j++)
2097 error (
"%s: indexing error", fname.c_str ());
2102 ra_idx(dim) += (dim < dv_tmp.
ndims () ? dv_tmp(dim) : 1);
2113 DEFUN (horzcat, args, ,
2128 return do_cat (args, -2,
"horzcat");
2349 DEFUN (vertcat, args, ,
2364 return do_cat (args, -1,
"vertcat");
2419 if (args.length () == 0)
2422 int dim =
args(0).xint_value (
"cat: DIM must be an integer") - 1;
2425 error (
"cat: DIM must be a valid dimension");
2427 return ovl (do_cat (args.slice (1, args.length () - 1), dim,
"cat"));
2583 int n = vec.
numel ();
2584 for (
int i = 0;
i < n;
i++)
2590 DEFUN (permute, args, ,
2620 return do_permute (args,
false);
2623 DEFUN (ipermute, args, ,
2639 return do_permute (args,
true);
2660 DEFUN (ndims, args, ,
2680 return ovl (
args(0).ndims ());
2726 int nargin = args.
length ();
2734 retval =
args(0).numel ();
2735 else if (nargin > 1)
2807 int nargin = args.
length ();
2822 int ndims = dimensions.
ndims ();
2826 for (
int i = 0;
i < ndims;
i++)
2827 m(
i) = dimensions(
i);
2832 else if (nargin == 2 && nargout < 2)
2834 if (!
args(1).is_real_scalar ())
2835 error (
"size: DIM must be a positive integer");
2842 error (
"size: requested dimension DIM (= %d) out of range", nd);
2844 if (nd <= dv.
ndims ())
2855 DEFUN (size_equal, args, ,
2865 int nargin = args.
length ();
2875 if (a_dims != b_dims)
2896 DEFUN (nzmax, args, ,
2910 return ovl (
args(0).nzmax ());
2913 DEFUN (rows, args, ,
2953 DEFUN (columns, args, ,
2963 return ovl (
args(0).columns ());
3003 int nargin = args.
length ();
3005 bool isnative =
false;
3006 bool isdouble =
false;
3007 bool isextra =
false;
3009 if (nargin > 1 &&
args(nargin - 1).is_string ())
3013 if (str ==
"native")
3015 else if (str ==
"double")
3017 else if (str ==
"extra")
3020 error (
"sum: unrecognized type argument '%s'", str.c_str ());
3025 if (nargin < 1 || nargin > 2)
3031 dim =
args(1).int_value () - 1;
3033 error (
"sum: invalid dimension DIM = %d", dim + 1);
3045 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3058 warning (
"sum: 'extra' not yet implemented for sparse matrices");
3068 if (isdouble || isextra)
3075 if (isdouble || isextra)
3081 #define MAKE_INT_BRANCH(X) \
3084 retval = arg.X ## _array_value ().sum (dim); \
3086 retval = arg.X ## _array_value ().dsum (dim); \
3098 #undef MAKE_INT_BRANCH
3194 DEFUN (sumsq, args, ,
3245 return ovl (
args(0).is_bool_type ());
3277 return ovl (
args(0).is_integer_type ());
3322 DEFUN (iscomplex, args, ,
3332 return ovl (
args(0).is_complex_type ());
3347 return ovl (
args(0).is_float_type ());
3353 DEFUN (complex, args, ,
3377 int nargin = args.
length ();
3379 if (nargin < 1 || nargin > 2)
3400 if (arg.
numel () == 1)
3415 if (arg.
numel () == 1)
3440 if (re.
numel () == 1)
3443 if (re_val.
nnz () == 0)
3455 i < im_val.
cidx (j + 1);
i++)
3462 else if (im.
numel () == 1)
3465 if (im_val.
nnz () == 0)
3478 i < re_val.
cidx (j + 1);
i++)
3487 if (re_val.
dims () != im_val.
dims ())
3488 error (
"complex: dimension mismatch");
3498 if (re.
numel () == 1)
3502 if (im.
numel () == 1)
3527 if (im.
numel () == 1)
3544 if (re_val.
dims () != im_val.
dims ())
3545 error (
"complex: dimension mismatch");
3559 else if (re.
numel () == 1)
3563 if (im.
numel () == 1)
3586 if (im.
numel () == 1)
3601 if (re_val.
dims () != im_val.
dims ())
3602 error (
"complex: dimension mismatch");
3617 DEFUN (isreal, args, ,
3630 return ovl (
args(0).is_real_type ());
3633 DEFUN (isempty, args, ,
3644 return ovl (
args(0).is_empty ());
3665 return ovl (
args(0).is_numeric_type ());
3684 DEFUN (isscalar, args, ,
3731 return ovl (sz.
ndims () == 2 && (
sz(0) == 1 ||
sz(1) == 1));
3754 DEFUN (isrow, args, ,
3798 DEFUN (iscolumn, args, ,
3842 DEFUN (ismatrix, args, ,
3854 return ovl (sz.
ndims () == 2 &&
sz(0) >= 0 &&
sz(1) >= 0);
3885 DEFUN (issquare, args, ,
3926 int nargin = args.
length ();
3932 if (nargin > 0 &&
args(nargin-1).is_string ())
3951 dims.resize (nargin);
3955 ? 0 :
args(
i).xidx_type_value (
"%s: dimension arguments must be scalar integers", fcn));
3960 dims.chop_trailing_singletons ();
4011 if (val == 1 &&
dims.ndims () == 2 &&
dims(0) == 1)
4023 error (
"%s: invalid class name", fcn);
4036 int nargin = args.
length ();
4042 if (nargin > 0 &&
args(nargin-1).is_string ())
4061 dims.resize (nargin);
4065 ? 0 :
args(
i).xidx_type_value (
"%s: dimension arguments must be scalar integers", fcn));
4070 dims.chop_trailing_singletons ();
4088 error (
"%s: invalid class name", fcn);
4100 int nargin = args.
length ();
4106 if (nargin > 0 &&
args(nargin-1).is_string ())
4125 dims.resize (nargin);
4129 ? 0 :
args(
i).xidx_type_value (
"%s: dimension arguments must be scalar integers", fcn));
4134 dims.chop_trailing_singletons ();
4152 error (
"%s: invalid class name", fcn);
4165 int nargin = args.
length ();
4171 if (nargin > 0 &&
args(nargin-1).is_string ())
4190 dims.resize (nargin);
4194 ? 0 :
args(
i).xidx_type_value (
"%s: dimension arguments must be scalar integers", fcn));
4199 dims.chop_trailing_singletons ();
4210 static_cast<FloatComplex> (val));
4218 error (
"%s: invalid class name", fcn);
4230 int nargin = args.
length ();
4245 dims.resize (nargin);
4249 ? 0 :
args(
i).xidx_type_value (
"%s: dimension arguments must be scalar integers", fcn));
4254 dims.chop_trailing_singletons ();
4266 DEFUN (ones, args, ,
4297 return fill_matrix (args, 1,
"ones");
4358 return fill_matrix (args, 0,
"zeros");
4539 double e_val = exp (1.0);
4542 return fill_matrix (args, e_val,
"e");
4582 if (args.
length () == 1 && !
args(0).is_string ())
4584 if (
args(0).is_single_type ())
4592 float val = ::fabsf (
x(
i));
4596 epsval(
i) =
powf (2.0, -149e0);
4602 static_cast<float> (expon - 24));
4616 double val = ::fabs (
x(
i));
4620 epsval(
i) =
pow (2.0, -1074e0);
4626 static_cast<double> (expon - 53));
4634 retval = fill_matrix (args, std::numeric_limits<double>::epsilon (),
4635 std::numeric_limits<float>::epsilon (),
"eps");
4705 double pi_val = M_PI;
4707 double pi_val = 4.0 *
atan (1.0);
4710 return fill_matrix (args, pi_val,
"pi");
4713 DEFUN (realmax, args, ,
4752 DEFUN (realmin, args, ,
4829 return fill_matrix (args,
Complex (0.0, 1.0),
"I");
4872 DEFUN (
false, args, ,
4887 return fill_matrix (args,
false,
"false");
4890 DEFUN (
true, args, ,
4905 return fill_matrix (args,
true,
"true");
4908 template <
typename MT>
4914 typename MT::element_type one (1);
4916 if (nr == 1 && nc == 1)
4922 typename MT::element_type
zero (0);
4926 if (nr > 0 && nc > 0)
4930 for (
int i = 0;
i < n;
i++)
4940 #define INSTANTIATE_EYE(T) \
4941 template octave_value identity_matrix<T> (int, int)
4967 retval = identity_matrix<int8NDArray> (nr, nc);
5011 error (
"eye: invalid class name");
5018 #undef INT_EYE_MATRIX
5070 int nargin = args.
length ();
5076 if (nargin > 0 &&
args(nargin-1).is_string ())
5091 else if (nargin == 1)
5122 template <
typename MT>
5127 typedef typename MT::column_vector_type CVT;
5128 typedef typename MT::element_type T;
5134 T bs = octave_value_extract<T> (base);
5137 T
ls = octave_value_extract<T> (limit);
5142 CVT lv = octave_value_extract<CVT> (limit);
5143 CVT bv (lv.numel (), bs);
5149 CVT bv = octave_value_extract<CVT> (base);
5152 T
ls = octave_value_extract<T> (limit);
5153 CVT lv (bv.numel (),
ls);
5158 CVT lv = octave_value_extract<CVT> (limit);
5189 int nargin = args.
length ();
5191 if (nargin != 2 && nargin != 3)
5204 error (
"linspace: N must be a scalar");
5214 bool isvector1 = sz1.
ndims () == 2 && (sz1(0) == 1 || sz1(1) == 1);
5216 bool isvector2 = sz2.
ndims () == 2 && (sz2(0) == 1 || sz2(1) == 1);
5218 if (! isvector1 || ! isvector2)
5219 error (
"linspace: A, B must be scalars or vectors");
5226 retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
5228 retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
5233 retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
5235 retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
5297 DEFUN (resize, args, ,
5344 int nargin = args.
length ();
5354 int ndim = vec.
numel ();
5365 for (
int i = 0;
i < ndim;
i++)
5368 retval = retval.
resize (dv,
true);
5379 retval = retval.
resize (dv,
true);
5387 DEFUN (reshape, args, ,
5421 int nargin = args.
length ();
5434 if (new_size.
numel () < 2)
5435 error (
"reshape: SIZE must have 2 or more dimensions");
5441 if (new_size(
i) < 0)
5442 error (
"reshape: SIZE must be non-negative");
5444 new_dims(
i) = new_size(
i);
5454 if (
args(
i).is_empty ())
5457 error (
"reshape: only a single dimension can be unknown");
5464 new_dims(
i-1) =
args(
i).idx_type_value ();
5466 if (new_dims(
i-1) < 0)
5467 error (
"reshape: SIZE must be non-negative");
5476 new_dims(empty_dim-1) = 0;
5482 if (a_nel != size_empty_dim * nel)
5483 error (
"reshape: SIZE is not divisible by the product of known dimensions (= %d)",
5486 new_dims(empty_dim-1) = size_empty_dim;
5491 retval =
args(0).reshape (new_dims);
5535 int nargin = args.
length ();
5537 if (nargin < 1 || nargin > 2)
5543 dim =
args(1).idx_type_value ();
5546 error (
"vec: DIM must be greater than zero");
5558 for (
int i = 0;
i < dim-1;
i++)
5561 new_dims(dim-1) = retval.
numel ();
5563 retval = retval.
reshape (new_dims);
5584 DEFUN (squeeze, args, ,
5597 return ovl (
args(0).squeeze ());
5600 DEFUN (full, args, ,
5611 return ovl (
args(0).full_value ());
5676 int nargin = args.
length ();
5678 if (nargin < 1 || nargin > 3)
5683 if (x_arg.
ndims () != 2)
5684 error (
"norm: only valid for 2-D objects");
5686 enum { sfmatrix, sfcols, sfrows, sffrob, sfinf } strflag = sfmatrix;
5687 if (nargin > 1 &&
args(nargin-1).is_string ())
5690 if (str ==
"cols" || str ==
"columns")
5692 else if (str ==
"rows")
5694 else if (str ==
"fro")
5696 else if (str ==
"inf")
5699 error (
"norm: unrecognized option: %s", str.c_str ());
5712 if (strflag != sfcols && strflag != sfrows)
5713 error (
"norm: invalid combination of options");
5715 if (str ==
"cols" || str ==
"columns" || str ==
"rows")
5716 error (
"norm: invalid combination of options");
5720 else if (str ==
"inf")
5723 error (
"norm: unrecognized option: %s", str.c_str ());
5733 retval =
xnorm (x_arg, p_arg);
5857 DEFUN (uplus, args, ,
5867 DEFUN (uminus, args, ,
5909 DEFUN (ctranspose, args, ,
5956 int nargin = args.
length ();
5965 else if (nargin == 2)
5978 DEFUN (plus, args, ,
5999 DEFUN (minus, args, ,
6009 DEFUN (mtimes, args, ,
6031 DEFUN (mrdivide, args, ,
6043 DEFUN (mpower, args, ,
6055 DEFUN (mldivide, args, ,
6153 DEFUN (rdivide, args, ,
6165 DEFUN (power, args, ,
6183 DEFUN (ldivide, args, ,
6239 DEFUN (colon, args, ,
6250 int nargin = args.
length ();
6252 if (nargin < 2 || nargin > 3)
6261 DEFUN (tic, args, nargout,
6308 warning (
"tic: ignoring extra arguments");
6317 double frac = modf (tmp, &ip);
6318 uint64_t microsecs =
static_cast<uint64_t
> (CLOCKS_PER_SEC * frac);
6319 microsecs += CLOCKS_PER_SEC *
static_cast<uint64_t
> (ip);
6323 tic_toc_timestamp =
tmp;
6328 DEFUN (toc, args, nargout,
6336 int nargin = args.
length ();
6347 uint64_t val =
id.value ();
6350 = (
static_cast<double> (val / CLOCKS_PER_SEC)
6351 + static_cast<double> (val % CLOCKS_PER_SEC)
6359 error (
"toc called before timer set");
6369 octave_stdout <<
"Elapsed time is " << etime <<
" seconds.\n";
6381 DEFUN (cputime, args, ,
6405 double usr = cpu_tm.
user ();
6406 double sys = cpu_tm.
system ();
6408 return ovl (usr + sys, usr, sys);
6411 DEFUN (sort, args, nargout,
6481 int nargin = args.
length ();
6483 if (nargin < 1 || nargin > 3)
6487 bool return_idx = (nargout > 1);
6488 bool have_sortmode = (nargin > 1 &&
args(1).is_string ());
6497 if (mode ==
"ascend")
6499 else if (mode ==
"descend")
6502 error (
"sort: MODE must be either \"ascend\" or \"descend\"");
6505 dim =
args(1).nint_value () - 1;
6511 error (
"sort: DIM must be a valid dimension");
6513 std::string mode =
args(2).xstring_value (
"sort: MODE must be a string");
6515 if (mode ==
"ascend")
6517 else if (mode ==
"descend")
6520 error (
"sort: MODE must be either \"ascend\" or \"descend\"");
6524 if (nargin == 1 || have_sortmode)
6531 error (
"sort: DIM must be a valid dimension");
6546 retval =
ovl (arg.
sort (dim, smode));
6733 DEFUN (__sort_rows_idx__, args, ,
6739 int nargin = args.
length ();
6741 if (nargin < 1 || nargin > 2)
6744 if (nargin == 2 && !
args(1).is_string ())
6745 error (
"__sort_rows_idx__: second argument must be a string");
6751 if (mode ==
"ascend")
6753 else if (mode ==
"descend")
6756 error (
"__sort_rows_idx__: MODE must be either \"ascend\" or \"descend\"");
6762 error (
"__sort_rows_idx__: sparse matrices not yet supported");
6764 if (arg.
ndims () != 2)
6765 error (
"__sort_rows_idx__: needs a 2-D object");
6783 if (mode ==
"ascending")
6785 else if (mode ==
"descending")
6787 else if (mode ==
"either")
6790 error (
"issorted: MODE must be \"ascending\", \"descending\", or \"either\"");
6795 DEFUN (issorted, args, ,
6815 int nargin = args.
length ();
6817 if (nargin < 1 || nargin > 3)
6820 bool by_rows =
false;
6827 smode = get_sort_mode_option (
args(2));
6829 std::string tmp =
args(1).xstring_value (
"issorted: second argument must be a string");
6833 smode = get_sort_mode_option (
args(1));
6843 error (
"issorted: sparse matrices not yet supported");
6845 if (arg.
ndims () != 2)
6846 error (
"issorted: A must be a 2-D object");
6853 error (
"issorted: needs a vector");
6907 DEFUN (nth_element, args, ,
6931 int nargin = args.
length ();
6933 if (nargin < 2 || nargin > 3)
6939 dim =
args(2).int_value (
true) - 1;
6941 error (
"nth_element: DIM must be a valid dimension");
6969 #define MAKE_INT_BRANCH(X) \
6971 retval = argx.X ## _array_value ().nth_element (n, dim); \
6984 #undef MAKE_INT_BRANCH
6995 index_error (
"nth_element: invalid N value %s. %s",
7002 template <
typename NDT>
7004 do_accumarray_sum (
const idx_vector& idx,
const NDT& vals,
7007 typedef typename NDT::element_type T;
7010 else if (idx.
extent (n) > n)
7011 error (
"accumarray: index out of range");
7015 if (vals.numel () == 1)
7016 retval.idx_add (idx, vals (0));
7017 else if (vals.numel () == idx.
length (n))
7018 retval.idx_add (idx, vals);
7020 error (
"accumarray: dimensions mismatch");
7025 DEFUN (__accumarray_sum__, args, ,
7031 int nargin = args.
length ();
7033 if (nargin < 2 || nargin > 3)
7036 if (!
args(0).is_numeric_type ())
7037 error (
"__accumarray_sum__: first argument must be numeric");
7046 n =
args(2).idx_type_value (
true);
7060 retval = do_accumarray_sum (idx,
7069 retval = do_accumarray_sum (idx,
7073 retval = do_accumarray_sum (idx, vals.
array_value (), n);
7080 index_error (
"__accumarray_sum__: invalid IDX %s. %s",
7087 template <
typename NDT>
7089 do_accumarray_minmax (
const idx_vector& idx,
const NDT& vals,
7091 const typename NDT::element_type& zero_val)
7093 typedef typename NDT::element_type T;
7096 else if (idx.
extent (n) > n)
7097 error (
"accumarray: index out of range");
7106 if (vals.numel () == 1)
7107 (retval.*op) (idx, NDT (
dim_vector (l, 1), vals(0)));
7108 else if (vals.numel () == l)
7109 (retval.*op) (idx, vals);
7111 error (
"accumarray: dimensions mismatch");
7120 int nargin = args.
length ();
7122 if (nargin < 3 || nargin > 4)
7125 if (!
args(0).is_numeric_type ())
7126 error (
"accumarray: first argument must be numeric");
7135 n =
args(3).idx_type_value (
true);
7143 retval = do_accumarray_minmax (idx, vals.
array_value (), n, ismin,
7158 retval = do_accumarray_minmax (idx,
7164 #define MAKE_INT_BRANCH(X) \
7166 retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
7167 n, ismin, zero.X ## _scalar_value ()); \
7179 #undef MAKE_INT_BRANCH
7182 retval = do_accumarray_minmax (idx, vals.
array_value (), n, ismin,
7192 index_error (
"do_accumarray_minmax_fun: invalid index %s. %s",
7199 DEFUN (__accumarray_min__, args, ,
7205 return do_accumarray_minmax_fun (args,
true);
7208 DEFUN (__accumarray_max__, args, ,
7214 return do_accumarray_minmax_fun (args,
false);
7217 template <
typename NDT>
7219 do_accumdim_sum (
const idx_vector& idx,
const NDT& vals,
7222 typedef typename NDT::element_type T;
7225 else if (idx.
extent (n) > n)
7226 error (
"accumdim: index out of range");
7232 dim = vals.dims ().first_non_singleton ();
7233 else if (dim >= rdv.
ndims ())
7240 if (idx.
length () != vals_dim(dim))
7241 error (
"accumdim: dimension mismatch");
7243 retval.idx_add_nd (idx, vals, dim);
7248 DEFUN (__accumdim_sum__, args, ,
7254 int nargin = args.
length ();
7256 if (nargin < 2 || nargin > 4)
7259 if (!
args(0).is_numeric_type ())
7260 error (
"__accumdim_sum__: first argument must be numeric");
7269 dim =
args(2).int_value () - 1;
7273 n =
args(3).idx_type_value (
true);
7280 retval = do_accumdim_sum (idx,
7293 retval = do_accumdim_sum (idx, vals.
array_value (), dim, n);
7300 index_error (
"__accumdim_sum__: invalid IDX %s. %s",
7307 template <
typename NDT>
7310 const NDT& tval,
const NDT& fval)
7312 typedef typename NDT::element_type T;
7316 bool tscl = tval.numel () == 1;
7317 bool fscl = fval.numel () == 1;
7319 if ((! tscl && tval.dims () !=
dv) || (! fscl && fval.dims () !=
dv))
7320 error (
"merge: MASK, TVAL, and FVAL dimensions must match");
7322 T *rv = retval.fortran_vec ();
7325 const T *tv = tval.data ();
7326 const T *fv = fval.data ();
7327 const bool *mv = mask.
data ();
7336 rv[
i] = mv[
i] ? ts : fs;
7342 rv[
i] = mv[
i] ? ts : fv[
i];
7351 rv[
i] = mv[
i] ? tv[
i] : fs;
7356 rv[
i] = mv[
i] ? tv[
i] : fv[
i];
7363 #define MAKE_INT_BRANCH(INTX) \
7364 else if (tval.is_ ## INTX ## _type () && fval.is_ ## INTX ## _type ()) \
7366 retval = do_merge (mask, \
7367 tval.INTX ## _array_value (), \
7368 fval.INTX ## _array_value ()); \
7371 DEFUN (merge, args, ,
7403 if (! (
args(0).is_bool_type () ||
args(0).is_numeric_type ()))
7404 error (
"merge: first argument must be logical or numeric");
7422 retval = do_merge (mask,
7426 retval = do_merge (mask,
7433 retval = do_merge (mask,
7437 retval = do_merge (mask,
7447 sq_string ?
'\'' :
'"');
7451 retval = do_merge (mask,
7466 error ("merge: cannot merge %
s with %
s with
array mask",
7467 tval.class_name ().c_str (),
7468 fval.class_name ().c_str ());
7476 #undef MAKE_INT_BRANCH
7478 template <
typename SparseT>
7483 SparseT retval =
array;
7487 while (order > 0 && k > 0)
7489 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7490 retval = SparseT (retval.index (col1, sl1))
7491 - SparseT (retval.index (col2, sl2));
7492 assert (retval.columns () == k-1);
7500 while (order > 0 && k > 0)
7502 idx_vector col1 (
':'), col2 (
':'), sl1 (1, k), sl2 (0, k-1);
7503 retval = SparseT (retval.index (sl1, col1))
7504 - SparseT (retval.index (sl2, col2));
7505 assert (retval.rows () == k-1);
7526 if (
dv(dim) <= order)
7535 if (dim == dv.
ndims ())
7537 retval =
do_diff (array, order, dim - 1);
7540 else if (
dv(dim) == 1)
7544 retval =
do_diff (array,
dv(dim) - 1, dim);
7545 order -=
dv(dim) - 1;
7602 DEFUN (diff, args, ,
7634 int nargin = args.
length ();
7636 if (nargin < 1 || nargin > 3)
7639 if (! (
args(0).is_numeric_type () ||
args(0).is_bool_type ()))
7640 error (
"diff: X must be numeric or logical");
7646 if (
args(1).is_scalar_type ())
7647 order =
args(1).idx_type_value (
true,
false);
7648 else if (!
args(1).is_zero_by_zero ())
7649 error (
"diff: order K must be a scalar or []");
7651 error (
"diff: order K must be non-negative");
7656 dim =
args(2).int_value (
true,
false);
7657 if (dim < 1 || dim >
args(0).ndims ())
7658 error (
"diff: DIM must be a valid dimension");
7679 template <
typename T>
7685 assert (rep.
ndims () == 2 && rep.
rows () == 2);
7693 error (
"repelems: second row must contain non-negative numbers");
7698 retval.
clear (1, l);
7704 std::fill_n (dest, k, src.
checkelem (rep(0,
i) - 1));
7711 DEFUN (repelems, args, ,
7744 if (rm.
rows () != 2 || rm.
ndims () != 2)
7745 error (
"repelems: R must be a matrix with two rows");
7754 if (static_cast<double> (rx) != rm(
i))
7755 error (
"repelems: R must be a matrix of integers");
7762 #define BTYP_BRANCH(X, EX) \
7764 retval = do_repelems (x.EX ## _value (), r); \
7795 DEFUN (base64_encode, args, ,
7807 if (!
args(0).is_numeric_type ())
7808 error (
"base64_encode: encoding is supported only for numeric arrays");
7810 if (
args(0).is_complex_type () ||
args(0).is_sparse_type ())
7811 error (
"base64_encode: encoding complex or sparse data is not supported");
7815 if (
args(0).is_integer_type ())
7817 #define MAKE_INT_BRANCH(X) \
7818 if (args(0).is_ ## X ## _type ()) \
7820 const X##NDArray in = args(0). X## _array_value (); \
7821 size_t inlen = in.numel () * sizeof (X## _t) / sizeof (char); \
7822 const char* inc = reinterpret_cast<const char*> (in.data ()); \
7824 if (octave_base64_encode (inc, inlen, &out)) \
7826 retval(0) = octave_value (out); \
7840 #undef MAKE_INT_BRANCH
7845 else if (
args(0).is_single_type ())
7849 inlen = in.
numel () *
sizeof (float) /
sizeof (
char);
7851 inc =
reinterpret_cast<const char*
> (in.
data ());
7863 inlen = in.
numel () *
sizeof (
double) /
sizeof (
char);
7865 inc =
reinterpret_cast<const char*
> (in.
data ());
7900 DEFUN (base64_decode, args, ,
7912 int nargin = args.
length ();
7914 if (nargin < 1 || nargin > 2)
7926 args(1).octave_idx_type_vector_value ();
7932 retval = retval.
reshape (dims);
7935 return ovl (retval);
float lo_ieee_float_na_value(void)
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
uint8NDArray uint8_array_value(void) const
SparseComplexMatrix cumsum(int dim=-1) const
OCTAVE_API ColumnVector xrownorms(const Matrix &m, double p)
boolNDArray all(int dim=-1) const
bool is_object(void) const
NDArray cumsum(int dim=-1) const
NDArray dsum(int dim=-1) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
octave_int< uint64_t > octave_uint64
bool is_range(void) const
octave_idx_type cols(void) const
NDArray cumsum(int dim=-1) const
octave_idx_type length(octave_idx_type n=0) const
charNDArray char_array_value(bool frc_str_conv=false) const
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
intNDArray< octave_int64 > int64NDArray
octave_idx_type rows(void) const
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value reshape(const dim_vector &dv) const
octave_idx_type rows(void) const
template octave_value identity_matrix< uint64NDArray >(int, int)
octave_value do_cat_op(const octave_value &v1, const octave_value &v2, const Array< octave_idx_type > &ra_idx)
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
template octave_value identity_matrix< uint16NDArray >(int, int)
FloatNDArray diff(octave_idx_type order=1, int dim=-1) const
double system(void) const
dim_vector dims(void) const
int8NDArray int8_array_value(void) const
OCTAVE_EXPORT octave_value_list or class The return code an ordinary file in Octave s or(after appending @samp{.m}) a function file in Octave's ode
bool is_vector(void) const
std::string get_concat_class(const std::string &c1, const std::string &c2)
static octave_value find_method(const std::string &name, const std::string &dispatch_type)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
bool is_uint16_type(void) const
OCTINTERP_API void print_usage(void)
SparseMatrix sum(int dim=-1) const
octave_idx_type numel(void) const
Number of elements in the array.
OCTAVE_EXPORT octave_value_list uint16
template octave_value identity_matrix< boolNDArray >(int, int)
identity matrix If supplied two scalar respectively For allows like xample val
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
int16NDArray int16_array_value(void) const
FloatNDArray cumsum(int dim=-1) const
octave_idx_type length(void) const
intNDArray< octave_uint32 > uint32NDArray
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
octave_value do_unary_op(octave_value::unary_op op, const octave_value &v)
static octave_value do_single_type_concat(const dim_vector &dv, tm_const &tmp)
bool is_scalar_type(void) const
octave_value diag(octave_idx_type k=0) const
intNDArray< octave_uint8 > uint8NDArray
bool is_numeric_type(void) const
bool is_defined(void) const
intNDArray< octave_uint16 > uint16NDArray
octave_int< T > mod(const octave_int< T > &x, const octave_int< T > &y)
NDArray prod(int dim=-1) const
void resize(int n, int fill_value=0)
uint64NDArray uint64_array_value(void) const
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)
SparseComplexMatrix prod(int dim=-1) const
#define DEFUN(name, args_name, nargout_name, doc)
OCTINTERP_API octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx)
void error(const char *fmt,...)
float float_value(bool frc_str_conv=false) const
#define MAKE_INT_BRANCH(X)
int32NDArray int32_array_value(void) const
double lo_ieee_inf_value(void)
bool is_int8_type(void) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
static octave_value identity_matrix(int nr, int nc, oct_data_conv::data_type dt)
std::string idx(void) const
ComplexNDArray xcomplex_array_value(const char *fmt,...) const
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by zero($0/0 $)
static Sparse< T > cat(int dim, octave_idx_type n, const Sparse< T > *sparse_list)
boolNDArray any(int dim=-1) const
octave_value resize(const dim_vector &dv, bool fill=false) const
Complex xcomplex_value(const char *fmt,...) const
octave_idx_type * cidx(void)
double lo_ieee_nan_value(void)
Template for N-dimensional array classes with like-type math operators.
bool is_int32_type(void) const
ComplexNDArray dsum(int dim=-1) const
intNDArray< octave_int16 > int16NDArray
double scalar_value(bool frc_str_conv=false) const
std::string xstring_value(const char *fmt,...) const
Array< double > octave_base64_decode(const std::string &str)
double frexp(double x, int *expptr)
octave_idx_type idx_type_value(bool req_int=false, bool frc_str_conv=false) const
boolNDArray bool_array_value(bool warn=false) const
OCTAVE_EXPORT octave_value_list isnumeric
int first_non_singleton(int def=0) const
octave_idx_type rows(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
FloatNDArray sum(int dim=-1) const
double lo_ieee_na_value(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
template octave_value identity_matrix< uint32NDArray >(int, int)
SparseMatrix sum(int dim=-1) const
FloatComplexNDArray cumsum(int dim=-1) const
bool concat(const dim_vector &dvb, int dim)
This corresponds to cat().
int64NDArray int64_array_value(void) const
Cell cell_value(void) const
ComplexNDArray dprod(int dim=-1) const
Array< std::string > cellstr_value(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
octave_value single_subsref(const std::string &type, const octave_value_list &idx)
bool isvector(const T &array)
#define DEFALIAS(alias, name)
octave_value_list do_multi_index_op(int nargout, const octave_value_list &idx)
double double_value(void) const
template octave_value identity_matrix< int16NDArray >(int, int)
intNDArray diff(octave_idx_type order=1, int dim=-1) const
octave_idx_type columns(void) const
OCTAVE_EXPORT octave_value_list islogical
FloatComplexNDArray xfloat_complex_array_value(const char *fmt,...) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
ComplexNDArray prod(int dim=-1) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Complex atan(const Complex &x)
ComplexNDArray sum(int dim=-1) const
SparseBoolMatrix all(int dim=-1) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
intNDArray< octave_int8 > int8NDArray
bool is_sparse_type(void) const
OCTINTERP_API octave_value do_class_concat(const octave_value_list &ovl, std::string cattype, int dim)
octave_idx_type numel(const octave_value_list &idx)
bool is_bool_type(void) const
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the special constant used to designate missing values Note that NA always compares not equal to NA(NA!=NA).To find NA values
octave_int< T > powf(const float &a, const octave_int< T > &b)
OCTAVE_EXPORT octave_value_list isfloat
std::string string_value(bool force=false) const
OCTAVE_EXPORT octave_value_list uint32
nd deftypefn *octave_map m
then the function must return scalars which will be concatenated into the return array(s).If code
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().
FloatComplex float_complex_value(bool frc_str_conv=false) const
Range range_value(void) const
float lo_ieee_float_inf_value(void)
OCTAVE_API RowVector xcolnorms(const Matrix &m, double p)
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
bool is_string(void) const
OCTAVE_EXPORT octave_value_list int16
bool is_double_type(void) const
const T * data(void) const
double norm(const ColumnVector &v)
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
bool is_complex_type(void) const
octave_value & assign(assign_op op, const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
bool is_int64_type(void) const
bool is_cellstr(void) const
#define panic_impossible()
OCTAVE_EXPORT octave_value_list int32
octave_value abs(void) const
OCTAVE_API double xnorm(const ColumnVector &x, double p)
dim_vector redim(int n) const
ComplexNDArray xsum(int dim=-1) const
FloatNDArray prod(int dim=-1) const
SparseMatrix cumsum(int dim=-1) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
static dim_vector alloc(int n)
dim_vector dims(void) const
SparseBoolMatrix any(int dim=-1) const
float lo_ieee_float_nan_value(void)
void err_wrong_type_arg(const char *name, const char *s)
With real return the complex result
Restrict the maximum order of the solution method This option must be between and
T & xelem(octave_idx_type n)
bool is_int16_type(void) const
OCTAVE_EXPORT octave_value_list int64
OCTINTERP_API void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
ComplexMatrix linspace(const ComplexColumnVector &x1, const ComplexColumnVector &x2, octave_idx_type n)
ComplexNDArray cumsum(int dim=-1) const
void warning(const char *fmt,...)
N Dimensional Array with copy-on-write semantics.
OCTAVE_API double xfrobnorm(const Matrix &x)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
charNDArray max(char d, const charNDArray &m)
bool octave_base64_encode(const char *inc, const size_t inlen, char **out)
bool is_empty(void) const
octave_idx_type extent(octave_idx_type n) const
intNDArray< octave_int32 > int32NDArray
SparseMatrix atan2(const double &x, const SparseMatrix &y)
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
bool is_sq_string(void) const
NDArray array_value(bool frc_str_conv=false) const
octave_idx_type * ridx(void)
OCTAVE_EXPORT octave_value_list ls
numel(ar{a}, ar{b}) nd group nd example oindent will return 6
NDArray sum(int dim=-1) const
For the expression xample zeros(3, 0) nd example oindent will print xample ans
template octave_value identity_matrix< int32NDArray >(int, int)
T & checkelem(octave_idx_type n)
bool bool_value(bool warn=false) const
=val(i)}if ode{val(i)}occurs in table i
bool is_uint8_type(void) const
SparseComplexMatrix sum(int dim=-1) const
FloatComplex xfloat_complex_value(const char *fmt,...) const
template octave_value identity_matrix< uint8NDArray >(int, int)
Complex complex_value(bool frc_str_conv=false) const
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)
issues an error eealso double
octave_int< T > rem(const octave_int< T > &x, const octave_int< T > &y)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several times
octave_idx_type ndims(void) const
Number of dimensions.
std::string class_name(void) const
the element is set to zero In other the statement xample y
SparseMatrix prod(int dim=-1) const
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
FloatComplexNDArray sum(int dim=-1) const
bool is_uint64_type(void) const
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
octave::sys::file_stat fs(filename)
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
ComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
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...
std::complex< float > FloatComplex
template octave_value identity_matrix< int64NDArray >(int, int)
static data_type string_to_data_type(const std::string &s)
static octave_value do_diff(const octave_value &array, octave_idx_type order, int dim=-1)
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
FloatComplexNDArray prod(int dim=-1) const
static SparseT do_sparse_diff(const SparseT &array, octave_idx_type order, int dim)
std::complex< double > Complex
SparseComplexMatrix xsparse_complex_matrix_value(const char *fmt,...) const
const T * fortran_vec(void) const
virtual std::string details(void) const =0
bool is_single_type(void) const
static void single_type_concat(Array< T > &result, tm_const &tmp)
#define BTYP_BRANCH(X, EX)
static void index_error(const char *fmt, const std::string &idx, const std::string &msg)
double double_value(bool frc_str_conv=false) const
bool is_uint32_type(void) const
Vector representing the dimensions (size) of an Array.
the second is matched to the second specifier and placed in the second column and so forth If there are more words than specifiers then the process is repeated until all words have been processed or the limit imposed by any(non-whitespace) text in the format that is not one of these specifiers is considered a literal.If there is a literal between two format specifiers then that same literal must appear in the input stream between the matching words.The following specifiers are valid
octave_value & xelem(octave_idx_type i)
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
OCTINTERP_API void check_dimensions(dim_vector &dim, const char *warnfor)
octave_value do_colon_op(const octave_value &base, const octave_value &increment, const octave_value &limit, bool is_for_cmd_expr)
uint32NDArray uint32_array_value(void) const
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
builtin_type_t builtin_type(void) const
#define INSTANTIATE_EYE(T)
uint16NDArray uint16_array_value(void) const
octave_idx_type columns(void) const
NDArray sum(int dim=-1) const
NDArray dprod(int dim=-1) const
NDArray diff(octave_idx_type order=1, int dim=-1) const
#define DATA_REDUCTION(FCN)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
NDArray xsum(int dim=-1) const
charNDArray min(char d, const charNDArray &m)
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
octave_value do_binary_op(octave_value::binary_op op, const octave_value &v1, const octave_value &v2)
intNDArray< octave_uint64 > uint64NDArray
bool is_integer_type(void) const