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>
177 return lower ? do_tril (a, k, pack) : do_triu (a, k, pack);
180 template <
typename T>
184 return lower ? do_tril (a, k, pack) : do_triu (a, k, pack);
188 do_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);
486 OCTAVE_END_NAMESPACE(
octave)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
octave_idx_type rows() const
const T * data() const
Size of the specified dimension.
octave_idx_type columns() const
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
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,...)