26 #if defined (HAVE_CONFIG_H)
51 const T *avec = a.
data ();
60 T *rvec =
r.fortran_vec ();
64 rvec = std::copy (avec + ii, avec + nr, rvec);
73 T *rvec =
r.fortran_vec ();
77 std::fill (rvec, rvec + ii, T ());
78 std::copy (avec + ii, avec + nr, rvec + ii);
93 const T *avec = a.
data ();
101 = ((j2 - j1) * ((j1+1-k) + (j2-k))) / 2 + (nc - j2) * nr;
103 T *rvec =
r.fortran_vec ();
107 rvec = std::copy (avec, avec + ii, rvec);
116 T *rvec =
r.fortran_vec ();
120 std::copy (avec, avec + ii, rvec);
121 std::fill (rvec + ii, rvec + nr, T ());
133 template <
typename T>
138 error (R
"(tril: "pack" not implemented for sparse matrices)");
145 if (
m.ridx (i) < j-k)
148 m.maybe_compress (
true);
153 template <
typename T>
158 error (R
"(triu: "pack" not implemented for sparse matrices)");
165 if (
m.ridx (i) > j-k)
168 m.maybe_compress (
true);
173 template <
typename T>
180 template <
typename T>
191 bool lower = (name ==
"tril");
193 int nargin = args.
length ();
196 if (nargin >= 2 && args(nargin-1).is_string ())
198 pack = (args(nargin-1).string_value () ==
"pack");
202 if (nargin < 1 || nargin > 2)
207 k = args(1).idx_type_value (
true);
212 if (dims.
ndims () != 2)
213 error (
"%s: need a 2-D matrix", name.c_str ());
214 else if (k < -dims(0))
216 else if (k > dims(1))
246 #define ARRAYCASE(TYP) \
248 retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
270 error (R
"(%s: "pack" not implemented for class %s)",
289 std::list<octave_value_list> idx_tmp;
290 ov_idx(1) =
static_cast<double> (nc+1);
291 ov_idx(0) = range<double> (1, nr);
292 idx_tmp.push_back (ov_idx);
293 ov_idx(1) =
static_cast<double> (nc);
307 ov_idx(1) =
static_cast<double> (j);
308 ov_idx(0) = range<double> (nr_limit, nr);
309 std::list<octave_value_list> idx;
310 idx.push_back (ov_idx);
322 ov_idx(1) =
static_cast<double> (j);
323 ov_idx(0) = range<double> (1, nr_limit);
324 std::list<octave_value_list> idx;
325 idx.push_back (ov_idx);
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
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
octave_value index_op(const octave_value_list &idx, bool resize_ok=false)
builtin_type_t builtin_type(void) const
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
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
dim_vector dims(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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,...)
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)