Navigation

Operators and Keywords

Function List:

C++ API

find.cc File Reference

#include "quit.h"
#include "defun-dld.h"
#include "error.h"
#include "gripes.h"
#include "oct-obj.h"

Include dependency graph for find.cc:


Defines

#define INSTANTIATE_FIND_ARRAY(T)
#define DO_INT_BRANCH(INTT)

Functions

template<typename T >
octave_value_list find_nonzero_elem_idx (const Array< T > &nda, int nargout, octave_idx_type n_to_find, int direction)
 INSTANTIATE_FIND_ARRAY (double)
 INSTANTIATE_FIND_ARRAY (float)
 INSTANTIATE_FIND_ARRAY (Complex)
 INSTANTIATE_FIND_ARRAY (FloatComplex)
 INSTANTIATE_FIND_ARRAY (bool)
 INSTANTIATE_FIND_ARRAY (octave_int8)
template<typename T >
octave_value_list find_nonzero_elem_idx (const Sparse< T > &v, int nargout, octave_idx_type n_to_find, int direction)
template octave_value_list find_nonzero_elem_idx (const Sparse< double > &, int, octave_idx_type, int)
template octave_value_list find_nonzero_elem_idx (const Sparse< Complex > &, int, octave_idx_type, int)
template octave_value_list find_nonzero_elem_idx (const Sparse< bool > &, int, octave_idx_type, int)
octave_value_list find_nonzero_elem_idx (const PermMatrix &v, int nargout, octave_idx_type n_to_find, int direction)
 DEFUN_DLD (find, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} find (@var{x})\n\ @deftypefnx {Loadable Function} {} find (@var{x}, @var{n})\n\ @deftypefnx {Loadable Function} {} find (@var{x}, @var{n}, @var{direction})\n\ Return a vector of indices of nonzero elements of a matrix, as a row if\n\ @var{x} is a row or as a column otherwise. To obtain a single index for\n\ each matrix element, Octave pretends that the columns of a matrix form one\n\ long vector (like Fortran arrays are stored). For example,\n\ \n\ @example\n\ @group\n\ find (eye (2))\n\ @result{} [ 1; 4 ]\n\ @end group\n\ @end example\n\ \n\ If two outputs are requested, @code{find} returns the row and column\n\ indices of nonzero elements of a matrix. For example,\n\ \n\ @example\n\ @group\n\ [i, j] = find (2 * eye (2))\n\ @result{} i = [ 1; 2 ]\n\ @result{} j = [ 1; 2 ]\n\ @end group\n\ @end example\n\ \n\ If three outputs are requested, @code{find} also returns a vector\n\ containing the nonzero values. For example,\n\ \n\ @example\n\ @group\n\ [i, j, v] = find (3 * eye (2))\n\ @result{} i = [ 1; 2 ]\n\ @result{} j = [ 1; 2 ]\n\ @result{} v = [ 3; 3 ]\n\ @end group\n\ @end example\n\ \n\ If two inputs are given, @var{n} indicates the maximum number of\n\ elements to find from the beginning of the matrix or vector.\n\ \n\ If three inputs are given, @var{direction} should be one of \"first\" or\n\ \"last\", requesting only the first or last @var{n} indices, respectively.\n\ However, the indices are always returned in ascending order.\n\ \n\ Note that this function is particularly useful for sparse matrices, as\n\ it extracts the non-zero elements as vectors, which can then be used to\n\ create the original matrix. For example,\n\ \n\ @example\n\ @group\n\ sz = size(a);\n\ [i, j, v] = find (a);\n\ b = sparse(i, j, v, sz(1), sz(2));\n\ @end group\n\ @end example\n\ @seealso{sparse}\n\ @end deftypefn")

Define Documentation

#define DO_INT_BRANCH ( INTT   ) 

Value:

else if (arg.is_ ## INTT ## _type ()) \
        { \
          INTT ## NDArray v = arg.INTT ## _array_value (); \
          \
          if (! error_state) \
            retval = find_nonzero_elem_idx (v, nargout, \
                                            n_to_find, direction);\
        }

#define INSTANTIATE_FIND_ARRAY ( T   ) 

Value:


Function Documentation

DEFUN_DLD ( find  ,
args  ,
nargout   
)

octave_value_list find_nonzero_elem_idx ( const PermMatrix v,
int  nargout,
octave_idx_type  n_to_find,
int  direction 
)

template octave_value_list find_nonzero_elem_idx ( const Sparse< bool > &  ,
int  ,
octave_idx_type  ,
int   
)

template octave_value_list find_nonzero_elem_idx ( const Sparse< Complex > &  ,
int  ,
octave_idx_type  ,
int   
)

template octave_value_list find_nonzero_elem_idx ( const Sparse< double > &  ,
int  ,
octave_idx_type  ,
int   
)

template<typename T >
octave_value_list find_nonzero_elem_idx ( const Sparse< T > &  v,
int  nargout,
octave_idx_type  n_to_find,
int  direction 
) [inline]

template<typename T >
octave_value_list find_nonzero_elem_idx ( const Array< T > &  nda,
int  nargout,
octave_idx_type  n_to_find,
int  direction 
) [inline]

INSTANTIATE_FIND_ARRAY ( octave_int8   ) 

INSTANTIATE_FIND_ARRAY ( bool   ) 

INSTANTIATE_FIND_ARRAY ( FloatComplex   ) 

INSTANTIATE_FIND_ARRAY ( Complex   ) 

INSTANTIATE_FIND_ARRAY ( float   ) 

INSTANTIATE_FIND_ARRAY ( double   )