Defines | Functions

tril.cc File Reference

#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"
Include dependency graph for tril.cc:

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 Documentation

#define ARRAYCASE (   TYP  ) 
Value:
case btyp_ ## TYP: \
              retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
              break

Referenced by do_trilu().


Function Documentation

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().

template<class T >
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().

template<class T >
static Sparse<T> do_tril ( const Sparse< T > &  a,
octave_idx_type  k,
bool  pack 
) [static]
template<class T >
static Sparse<T> do_trilu ( const Sparse< T > &  a,
octave_idx_type  k,
bool  lower,
bool  pack 
) [static]

Definition at line 180 of file tril.cc.

References do_tril(), and do_triu().

template<class T >
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]
template<class T >
static Sparse<T> do_triu ( const Sparse< T > &  a,
octave_idx_type  k,
bool  pack 
) [static]
template<class T >
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().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines