26#if defined (HAVE_CONFIG_H)
51 const T *avec = a.
data ();
58 octave_idx_type n = j1 * nr + ((j2 - j1) * (nr-(j1-k) + nr-(j2-1-k))) / 2;
60 T *rvec = r.rwdata ();
64 rvec = std::copy (avec + ii, avec + nr, rvec);
73 T *rvec = r.rwdata ();
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.rwdata ();
107 rvec = std::copy (avec, avec + ii, rvec);
116 T *rvec = r.rwdata ();
120 std::copy (avec, avec + ii, rvec);
121 std::fill (rvec + ii, rvec + nr, T ());
138 error (R
"(tril: "pack" not implemented for sparse matrices)");
145 if (m.
ridx (i) < j-k)
158 error (R
"(triu: "pack" not implemented for sparse matrices)");
165 if (m.
ridx (i) > j-k)
177 return lower ? do_tril (a, k, pack) : do_triu (a, k, pack);
184 return lower ? do_tril (a, k, pack) : do_triu (a, k, pack);
188do_trilu (
const std::string& name,
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))
227 retval = do_trilu (arg.
array_value (), k, lower, pack);
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);
292 idx_tmp.push_back (ov_idx);
293 ov_idx(1) =
static_cast<double> (nc);
307 ov_idx(1) =
static_cast<double> (j);
309 std::list<octave_value_list> idx;
310 idx.push_back (ov_idx);
322 ov_idx(1) =
static_cast<double> (j);
324 std::list<octave_value_list> idx;
325 idx.push_back (ov_idx);
384 return do_trilu (
"tril", args);
433 return do_trilu (
"triu", args);
486OCTAVE_END_NAMESPACE(octave)
N Dimensional Array with copy-on-write semantics.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
octave_idx_type rows() const
octave_idx_type columns() const
const T * data() const
Size of the specified dimension.
octave_idx_type cols() const
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
Vector representing the dimensions (size) of an Array.
octave_idx_type ndims() const
Number of dimensions.
octave_idx_type length() const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
std::string class_name() const
octave_value index_op(const octave_value_list &idx, bool resize_ok=false)
ComplexNDArray complex_array_value(bool frc_str_conv=false) 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
builtin_type_t builtin_type() 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)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)