#include <algorithm>
#include "Array.h"
#include "Sparse.h"
#include "mx-base.h"
#include "ov.h"
#include "Cell.h"
#include "defun-dld.h"
#include "error.h"
#include "oct-obj.h"
Go to the source code of this file.
Defines | |
#define | ARRAYCASE(TYP) |
Functions | |
DEFUN_DLD (tril, args,,"-*- texinfo -*-\n\ @deftypefn {Function File} {} tril (@var{A})\n\ @deftypefnx {Function File} {} tril (@var{A}, @var{k})\n\ @deftypefnx {Function File} {} tril (@var{A}, @var{k}, @var{pack})\n\ @deftypefnx {Function File} {} triu (@var{A})\n\ @deftypefnx {Function File} {} triu (@var{A}, @var{k})\n\ @deftypefnx {Function File} {} triu (@var{A}, @var{k}, @var{pack})\n\ Return a new matrix formed by extracting the lower (@code{tril})\n\ or upper (@code{triu}) triangular part of the matrix @var{A}, and\n\ setting all other elements to zero. The second argument is optional,\n\ and specifies how many diagonals above or below the main diagonal should\n\ also be set to zero.\n\ \n\ The default value of @var{k} is zero, so that @code{triu} and\n\ @code{tril} normally include the main diagonal as part of the result.\n\ \n\ If the value of @var{k} is nonzero integer, the selection of elements\ starts at an offset of @var{k} diagonals above or below the main\ diagonal; above for positive @var{k} and below for negative @var{k}.\ \n\ The absolute value of @var{k} must not be greater than the number of\n\ sub-diagonals or super-diagonals.\n\ \n\ For example:\n\ \n\ @example\n\ @group\n\ tril (ones (3), -1)\n\ @result{} 0 0 0\n\ 1 0 0\n\ 1 1 0\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ and\n\ \n\ @example\n\ @group\n\ tril (ones (3), 1)\n\ @result{} 1 1 0\n\ 1 1 1\n\ 1 1 1\n\ @end group\n\ @end example\n\ \n\ If the option \"pack\" is given as third argument, the extracted elements\n\ are not inserted into a matrix, but rather stacked column-wise one above\n\ other.\n\ @seealso{diag}\n\ @end deftypefn") | |
DEFUN_DLD (triu, args,,"-*- texinfo -*-\n\ @deftypefn {Function File} {} triu (@var{A})\n\ @deftypefnx {Function File} {} triu (@var{A}, @var{k})\n\ @deftypefnx {Function File} {} triu (@var{A}, @var{k}, @var{pack})\n\ See the documentation for the @code{tril} function (@pxref{tril}).\n\ @end deftypefn") | |
template<class T > | |
static Array< T > | do_tril (const Array< T > &a, octave_idx_type k, bool pack) |
template<class T > | |
static Sparse< T > | do_tril (const Sparse< T > &a, octave_idx_type k, bool pack) |
template<class T > | |
static Sparse< T > | do_trilu (const Sparse< T > &a, octave_idx_type k, bool lower, bool pack) |
template<class T > | |
static Array< T > | do_trilu (const Array< T > &a, octave_idx_type k, bool lower, bool pack) |
static octave_value | do_trilu (const std::string &name, const octave_value_list &args) |
template<class T > | |
static Sparse< T > | do_triu (const Sparse< T > &a, octave_idx_type k, bool pack) |
template<class T > | |
static Array< T > | do_triu (const Array< T > &a, octave_idx_type k, bool pack) |
#define ARRAYCASE | ( | TYP | ) |
Referenced by do_trilu().
DEFUN_DLD | ( | tril | , | |
args | ||||
) |
Definition at line 342 of file tril.cc.
References do_trilu().
DEFUN_DLD | ( | triu | , | |
args | ||||
) |
Definition at line 398 of file tril.cc.
References do_trilu().
static Array<T> do_tril | ( | const Array< T > & | a, | |
octave_idx_type | k, | |||
bool | pack | |||
) | [static] |
Definition at line 43 of file tril.cc.
References Array< T >::columns(), Array< T >::dims(), Array< T >::fortran_vec(), max(), min(), and Array< T >::rows().
Referenced by do_trilu().
static Sparse<T> do_tril | ( | const Sparse< T > & | a, | |
octave_idx_type | k, | |||
bool | pack | |||
) | [static] |
Definition at line 128 of file tril.cc.
References Sparse< T >::cidx(), Sparse< T >::cols(), Sparse< T >::data(), error(), Sparse< T >::maybe_compress(), and Sparse< T >::ridx().
static Sparse<T> do_trilu | ( | const Sparse< T > & | a, | |
octave_idx_type | k, | |||
bool | lower, | |||
bool | pack | |||
) | [static] |
static Array<T> do_trilu | ( | const Array< T > & | a, | |
octave_idx_type | k, | |||
bool | lower, | |||
bool | pack | |||
) | [static] |
Definition at line 173 of file tril.cc.
References do_tril(), and do_triu().
Referenced by DEFUN_DLD(), and do_trilu().
static octave_value do_trilu | ( | const std::string & | name, | |
const octave_value_list & | args | |||
) | [static] |
Definition at line 186 of file tril.cc.
References arg(), octave_value::array_value(), ARRAYCASE, octave_value::bool_array_value(), btyp_bool, btyp_complex, btyp_double, octave_value::builtin_type(), octave_value::class_name(), octave_value::complex_array_value(), octave_value::dims(), octave_value::do_index_op(), do_trilu(), error(), error_state, float_complex, octave_value::is_sparse_type(), dim_vector::length(), octave_value_list::length(), octave_value::numel(), octave_value(), print_usage(), octave_value::resize(), octave_value::sparse_bool_matrix_value(), octave_value::sparse_complex_matrix_value(), octave_value::sparse_matrix_value(), and octave_value::subsasgn().
static Sparse<T> do_triu | ( | const Sparse< T > & | a, | |
octave_idx_type | k, | |||
bool | pack | |||
) | [static] |
Definition at line 150 of file tril.cc.
References Sparse< T >::cidx(), Sparse< T >::cols(), Sparse< T >::data(), error(), Sparse< T >::maybe_compress(), and Sparse< T >::ridx().
static Array<T> do_triu | ( | const Array< T > & | a, | |
octave_idx_type | k, | |||
bool | pack | |||
) | [static] |
Definition at line 84 of file tril.cc.
References Array< T >::columns(), Array< T >::dims(), Array< T >::fortran_vec(), max(), min(), and Array< T >::rows().
Referenced by do_trilu().