24 #if defined (HAVE_CONFIG_H)
56 T *rvec = r.fortran_vec ();
60 rvec = std::copy (avec + ii, avec + nr, rvec);
73 std::fill (rvec, rvec + ii, T ());
74 std::copy (avec + ii, avec + nr, rvec + ii);
97 = ((j2 - j1) * ((j1+1-k) + (j2-
k))) / 2 + (nc - j2) * nr;
103 rvec = std::copy (avec, avec + ii, rvec);
112 T *rvec = r.fortran_vec ();
116 std::copy (avec, avec + ii, rvec);
117 std::fill (rvec + ii, rvec + nr, T ());
129 template <
typename T>
134 error (
"tril: \"pack\" not implemented for sparse matrices");
149 template <
typename T>
154 error (
"triu: \"pack\" not implemented for sparse matrices");
169 template <
typename T>
176 template <
typename T>
187 bool lower = (name ==
"tril");
192 if (nargin >= 2 &&
args(nargin-1).is_string ())
194 pack = (
args(nargin-1).string_value () ==
"pack");
198 if (nargin < 1 || nargin > 2)
203 k =
args(1).idx_type_value (
true);
208 if (dims.
ndims () != 2)
209 error (
"%s: need a 2-D matrix", name.c_str ());
210 else if (k < -
dims(0) || k >
dims(1))
211 error (
"%s: requested diagonal out of range", name.c_str ());
240 #define ARRAYCASE(TYP) \
242 retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
264 error (
"%s: \"pack\" not implemented for class %s",
283 std::list<octave_value_list> idx_tmp;
284 ov_idx(1) =
static_cast<double> (nc+1);
285 ov_idx(0) =
Range (1, nr);
286 idx_tmp.push_back (ov_idx);
287 ov_idx(1) =
static_cast<double> (nc);
289 tmp = tmp.subsasgn (
"(",idx_tmp, arg.
do_index_op (ov_idx));
290 tmp = tmp.resize (dims);
299 ov_idx(1) =
static_cast<double> (j);
300 ov_idx(0) =
Range (nr_limit, nr);
301 std::list<octave_value_list> idx;
302 idx.push_back (ov_idx);
304 tmp = tmp.subsasgn (
"(", idx, arg.
do_index_op (ov_idx));
314 ov_idx(1) =
static_cast<double> (j);
315 ov_idx(0) =
Range (1, nr_limit);
316 std::list<octave_value_list> idx;
317 idx.push_back (ov_idx);
319 tmp = tmp.subsasgn (
"(", idx, arg.
do_index_op (ov_idx));
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
octave_idx_type cols(void) const
OCTINTERP_API void print_usage(void)
OCTAVE_EXPORT octave_value_list uint16
octave_idx_type length(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
octave_idx_type * cidx(void)
static Array< T > do_tril(const Array< T > &a, octave_idx_type k, bool pack)
boolNDArray bool_array_value(bool warn=false) const
octave_idx_type rows(void) const
static Array< T > do_triu(const Array< T > &a, octave_idx_type k, bool pack)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
bool is_sparse_type(void) const
OCTAVE_EXPORT octave_value_list uint32
nd deftypefn *octave_map m
Sparse< T > maybe_compress(bool remove_zeros=false)
OCTAVE_EXPORT octave_value_list int16
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
OCTAVE_EXPORT octave_value_list int32
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
dim_vector dims(void) const
OCTAVE_EXPORT octave_value_list int64
N Dimensional Array with copy-on-write semantics.
charNDArray max(char d, const charNDArray &m)
bool is_empty(void) const
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
NDArray array_value(bool frc_str_conv=false) const
octave_idx_type * ridx(void)
=val(i)}if ode{val(i)}occurs in table i
octave_idx_type ndims(void) const
Number of dimensions.
std::string class_name(void) const
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
const T * fortran_vec(void) const
Vector representing the dimensions (size) of an Array.
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
octave_idx_type columns(void) const
static Array< T > do_trilu(const Array< T > &a, octave_idx_type k, bool lower, bool pack)
charNDArray min(char d, const charNDArray &m)
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)