26 #if defined (HAVE_CONFIG_H)
58 T *rvec =
r.fortran_vec ();
62 rvec = std::copy (avec + ii, avec + nr, rvec);
71 T *rvec =
r.fortran_vec ();
75 std::fill (rvec, rvec + ii, T ());
76 std::copy (avec + ii, avec + nr, rvec + ii);
99 = ((j2 - j1) * ((j1+1-k) + (j2-k))) / 2 + (nc - j2) * nr;
101 T *rvec =
r.fortran_vec ();
105 rvec = std::copy (avec, avec + ii, rvec);
114 T *rvec =
r.fortran_vec ();
118 std::copy (avec, avec + ii, rvec);
119 std::fill (rvec + ii, rvec + nr, T ());
131 template <
typename T>
136 error (R
"(tril: "pack" not implemented for sparse matrices)");
143 if (
m.ridx (i) < j-k)
146 m.maybe_compress (
true);
151 template <
typename T>
156 error (R
"(triu: "pack" not implemented for sparse matrices)");
163 if (
m.ridx (i) > j-k)
166 m.maybe_compress (
true);
171 template <
typename T>
178 template <
typename T>
189 bool lower = (
name ==
"tril");
191 int nargin = args.
length ();
194 if (nargin >= 2 && args(nargin-1).is_string ())
196 pack = (args(nargin-1).string_value () ==
"pack");
200 if (nargin < 1 || nargin > 2)
205 k = args(1).idx_type_value (
true);
210 if (dims.
ndims () != 2)
211 error (
"%s: need a 2-D matrix",
name.c_str ());
212 else if (k < -dims(0) || k > dims(1))
213 error (
"%s: requested diagonal out of range",
name.c_str ());
242 #define ARRAYCASE(TYP) \
244 retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
266 error (R
"(%s: "pack" not implemented for class %s)",
285 std::list<octave_value_list> idx_tmp;
286 ov_idx(1) =
static_cast<double> (nc+1);
287 ov_idx(0) =
Range (1, nr);
288 idx_tmp.push_back (ov_idx);
289 ov_idx(1) =
static_cast<double> (nc);
301 ov_idx(1) =
static_cast<double> (j);
302 ov_idx(0) =
Range (nr_limit, nr);
303 std::list<octave_value_list> idx;
304 idx.push_back (ov_idx);
316 ov_idx(1) =
static_cast<double> (j);
317 ov_idx(0) =
Range (1, nr_limit);
318 std::list<octave_value_list> idx;
319 idx.push_back (ov_idx);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
N Dimensional Array with copy-on-write semantics.
octave_idx_type columns(void) const
octave_idx_type rows(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
const T * fortran_vec(void) const
Size of the specified dimension.
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims(void) const
Number of dimensions.
octave_idx_type length(void) const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
bool issparse(void) const
builtin_type_t builtin_type(void) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
std::string class_name(void) const
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
NDArray array_value(bool frc_str_conv=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
dim_vector dims(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
octave_value::octave_value(const Array< char > &chm, char type) return retval
static Array< T > do_triu(const Array< T > &a, octave_idx_type k, bool pack)
static Array< T > do_trilu(const Array< T > &a, octave_idx_type k, bool lower, bool pack)
static Array< T > do_tril(const Array< T > &a, octave_idx_type k, bool pack)