Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Related Functions | List of all members
vnl_int_matrix Class Reference

Specializes vnl_matrix for integers, adding a vnl_matrix<double> ctor. More...

#include <vnl_int_matrix.h>

Inheritance diagram for vnl_int_matrix:
Inheritance graph
[legend]

Public Types

typedef vnl_c_vector< int >::abs_t abs_t
 Type def for norms. More...
 
typedef int element_type
 
typedef int * iterator
 Iterators. More...
 
typedef int const * const_iterator
 Const iterators. More...
 

Public Member Functions

 vnl_int_matrix ()=default
 
 vnl_int_matrix (char const *filename)
 Load from disk. More...
 
 vnl_int_matrix (unsigned r, unsigned c)
 
 vnl_int_matrix (unsigned r, unsigned c, int fillvalue)
 
 vnl_int_matrix (const vnl_matrix< double > &d)
 Construct from matrix of double. More...
 
 vnl_int_matrix (const vnl_matrix< int > &d)
 
vnl_int_matrixoperator= (const vnl_matrix< int > &d)
 
unsigned int size () const
 Return the total number of elements stored by the matrix. More...
 
unsigned int rows () const
 Return the number of rows. More...
 
unsigned int cols () const
 Return the number of columns. More...
 
unsigned int columns () const
 Return the number of columns. More...
 
void put (unsigned r, unsigned c, int const &)
 set element with boundary checks if error checking is on. More...
 
int get (unsigned r, unsigned c) const
 get element with boundary checks if error checking is on. More...
 
int * operator[] (unsigned r)
 return pointer to given row. More...
 
int const * operator[] (unsigned r) const
 return pointer to given row. More...
 
int & operator() (unsigned r, unsigned c)
 Access an element for reading or writing. More...
 
int const & operator() (unsigned r, unsigned c) const
 Access an element for reading. More...
 
vnl_matrixfill (int const &)
 Sets all elements of matrix to specified value, and returns "*this". More...
 
vnl_matrixfill_diagonal (int const &)
 Sets all diagonal elements of matrix to specified value; returns "*this". More...
 
vnl_matrixset_diagonal (vnl_vector< int > const &)
 Sets the diagonal elements of this matrix to the specified list of values. More...
 
vnl_matrixcopy_in (int const *)
 Fills (laminates) this matrix with the given data, then returns it. More...
 
vnl_matrixset (int const *d)
 Fills (laminates) this matrix with the given data, then returns it. More...
 
void copy_out (int *) const
 Fills the given array with this matrix. More...
 
vnl_matrix< int > & operator+= (int value)
 Add rhs to each element of lhs matrix in situ. More...
 
vnl_matrix< int > & operator+= (vnl_matrix< int > const &)
 Add rhs to lhs matrix in situ. More...
 
vnl_matrix< int > & operator-= (int value)
 Subtract rhs from each element of lhs matrix in situ. More...
 
vnl_matrix< int > & operator-= (vnl_matrix< int > const &)
 Subtract rhs from lhs matrix in situ. More...
 
vnl_matrix< int > & operator *= (int value)
 Scalar multiplication in situ of lhs matrix by rhs. More...
 
vnl_matrix< int > & operator *= (vnl_matrix< int > const &rhs)
 Multiply lhs matrix in situ by rhs. More...
 
vnl_matrix< int > & operator/= (int value)
 Scalar division of lhs matrix in situ by rhs. More...
 
vnl_matrix< int > operator- () const
 Negate all elements of matrix. More...
 
vnl_matrix< int > operator- (int const &v) const
 Subtract rhs from each element of lhs matrix and return result in new matrix. More...
 
vnl_matrix< int > operator- (vnl_matrix< int > const &rhs) const
 Matrix subtract rhs from lhs and return result in new matrix. More...
 
vnl_matrix< int > operator+ (int const &v) const
 Add rhs to each element of lhs matrix and return result in new matrix. More...
 
vnl_matrix< int > operator+ (vnl_matrix< int > const &rhs) const
 Matrix add rhs to lhs matrix and return result in new matrix. More...
 
vnl_matrix< int > operator * (int const &v) const
 Scalar multiplication of lhs matrix by rhs and return result in new matrix. More...
 
vnl_matrix< int > operator * (vnl_matrix< int > const &rhs) const
 Matrix multiply lhs by rhs matrix and return result in new matrix. More...
 
vnl_matrix< int > operator/ (int const &v) const
 Scalar division of lhs matrix by rhs and return result in new matrix. More...
 
vnl_matrix< int > apply (int(*f)(int)) const
 Make a new matrix by applying function to each element. More...
 
vnl_matrix< int > apply (int(*f)(int const &)) const
 Make a new matrix by applying function to each element. More...
 
vnl_vector< int > apply_rowwise (int(*f)(vnl_vector< int > const &)) const
 Make a vector by applying a function across rows. More...
 
vnl_vector< int > apply_columnwise (int(*f)(vnl_vector< int > const &)) const
 Make a vector by applying a function across columns. More...
 
vnl_matrix< int > transpose () const
 Return transpose. More...
 
vnl_matrix< int > conjugate_transpose () const
 Return conjugate transpose. More...
 
vnl_matrix< int > & update (vnl_matrix< int > const &, unsigned top=0, unsigned left=0)
 Set values of this matrix to those of M, starting at [top,left]. More...
 
vnl_matrixset_column (unsigned i, int const *v)
 Set the elements of the i'th column to v[i] (No bounds checking). More...
 
vnl_matrixset_column (unsigned i, int value)
 Set the elements of the i'th column to value, then return *this. More...
 
vnl_matrixset_column (unsigned j, vnl_vector< int > const &v)
 Set j-th column to v, then return *this. More...
 
vnl_matrixset_columns (unsigned starting_column, vnl_matrix< int > const &M)
 Set columns to those in M, starting at starting_column, then return *this. More...
 
vnl_matrixset_row (unsigned i, int const *v)
 Set the elements of the i'th row to v[i] (No bounds checking). More...
 
vnl_matrixset_row (unsigned i, int value)
 Set the elements of the i'th row to value, then return *this. More...
 
vnl_matrixset_row (unsigned i, vnl_vector< int > const &)
 Set the i-th row. More...
 
vnl_matrix< int > extract (unsigned r, unsigned c, unsigned top=0, unsigned left=0) const
 Extract a sub-matrix of size r x c, starting at (top,left). More...
 
void extract (vnl_matrix< int > &sub_matrix, unsigned top=0, unsigned left=0) const
 Extract a sub-matrix starting at (top,left). More...
 
vnl_vector< int > get_row (unsigned r) const
 Get a vector equal to the given row. More...
 
vnl_vector< int > get_column (unsigned c) const
 Get a vector equal to the given column. More...
 
vnl_matrix< int > get_rows (vnl_vector< unsigned int > i) const
 Get a matrix composed of rows from the indices specified in the supplied vector. More...
 
vnl_matrix< int > get_columns (vnl_vector< unsigned int > i) const
 Get a matrix composed of columns from the indices specified in the supplied vector. More...
 
vnl_matrix< int > get_n_rows (unsigned rowstart, unsigned n) const
 Get n rows beginning at rowstart. More...
 
vnl_matrix< int > get_n_columns (unsigned colstart, unsigned n) const
 Get n columns beginning at colstart. More...
 
vnl_vector< int > get_diagonal () const
 Return a vector with the content of the (main) diagonal. More...
 
vnl_vector< int > flatten_row_major () const
 Flatten row-major (C-style). More...
 
vnl_vector< int > flatten_column_major () const
 Flatten column-major (Fortran-style). More...
 
vnl_matrixset_identity ()
 Sets this matrix to an identity matrix, then returns "*this". More...
 
vnl_matrixinplace_transpose ()
 Transposes this matrix efficiently, and returns it. More...
 
vnl_matrixflipud ()
 Reverses the order of rows, and returns "*this". More...
 
vnl_matrixfliplr ()
 Reverses the order of columns, and returns "*this". More...
 
vnl_matrixnormalize_rows ()
 Normalizes each row so it is a unit vector, and returns "*this". More...
 
vnl_matrixnormalize_columns ()
 Normalizes each column so it is a unit vector, and returns "*this". More...
 
vnl_matrixscale_row (unsigned row, int value)
 Scales elements in given row by a factor T, and returns "*this". More...
 
vnl_matrixscale_column (unsigned col, int value)
 Scales elements in given column by a factor T, and returns "*this". More...
 
void swap (vnl_matrix< int > &that)
 Swap this matrix with that matrix. More...
 
abs_t array_one_norm () const
 Return sum of absolute values of elements. More...
 
abs_t array_two_norm () const
 Return square root of sum of squared absolute element values. More...
 
abs_t array_inf_norm () const
 Return largest absolute element value. More...
 
abs_t absolute_value_sum () const
 Return sum of absolute values of elements. More...
 
abs_t absolute_value_max () const
 Return largest absolute value. More...
 
abs_t operator_one_norm () const
 
abs_t operator_inf_norm () const
 
abs_t frobenius_norm () const
 Return Frobenius norm of matrix (sqrt of sum of squares of its elements). More...
 
abs_t fro_norm () const
 Return Frobenius norm of matrix (sqrt of sum of squares of its elements). More...
 
abs_t rms () const
 Return RMS of all elements. More...
 
int min_value () const
 Return minimum value of elements. More...
 
int max_value () const
 Return maximum value of elements. More...
 
unsigned arg_min () const
 Return location of minimum value of elements. More...
 
unsigned arg_max () const
 Return location of maximum value of elements. More...
 
int mean () const
 Return mean of all matrix elements. More...
 
bool empty () const
 Return true iff the size is zero. More...
 
bool is_identity () const
 Return true if all elements equal to identity. More...
 
bool is_identity (double tol) const
 Return true if all elements equal to identity, within given tolerance. More...
 
bool is_zero () const
 Return true if all elements equal to zero. More...
 
bool is_zero (double tol) const
 Return true if all elements equal to zero, within given tolerance. More...
 
bool is_equal (vnl_matrix< int > const &rhs, double tol) const
 Return true if all elements of both matrices are equal, within given tolerance. More...
 
bool is_finite () const
 Return true if finite. More...
 
bool has_nans () const
 Return true if matrix contains NaNs. More...
 
void assert_size (unsigned VXL_USED_IN_DEBUG(r), unsigned VXL_USED_IN_DEBUG(c)) const
 abort if size is not as expected. More...
 
void assert_finite () const
 abort if matrix contains any INFs or NANs. More...
 
bool read_ascii (std::istream &s)
 Read a vnl_matrix from an ascii std::istream. More...
 
int const * data_block () const
 Access the contiguous block storing the elements in the matrix row-wise. O(1). More...
 
int * data_block ()
 Access the contiguous block storing the elements in the matrix row-wise. O(1). More...
 
int const *const * data_array () const
 Access the 2D array, so that elements can be accessed with array[row][col] directly. More...
 
int ** data_array ()
 Access the 2D array, so that elements can be accessed with array[row][col] directly. More...
 
iterator begin ()
 Iterator pointing to start of data. More...
 
const_iterator begin () const
 Iterator pointing to start of data. More...
 
iterator end ()
 Iterator pointing to element beyond end of data. More...
 
const_iterator end () const
 Iterator pointing to element beyond end of data. More...
 
vnl_matrix< int > const & as_ref () const
 Return a reference to this. More...
 
vnl_matrix< int > & as_ref ()
 Return a reference to this. More...
 
bool operator_eq (vnl_matrix< int > const &rhs) const
 Return true if *this == rhs. More...
 
bool operator== (vnl_matrix< int > const &that) const
 Equality operator. More...
 
bool operator!= (vnl_matrix< int > const &that) const
 Inequality operator. More...
 
void print (std::ostream &os) const
 Print matrix to os in some hopefully sensible format. More...
 
void clear ()
 Make the matrix as if it had been default-constructed. More...
 
bool set_size (unsigned r, unsigned c)
 Resize to r rows by c columns. Old data lost. More...
 

Static Public Member Functions

static vnl_matrix< int > read (std::istream &s)
 Read a vnl_matrix from an ascii std::istream, automatically determining file size if the input matrix has zero size. More...
 

Protected Member Functions

void assert_size_internal (unsigned r, unsigned c) const
 Abort unless M has the given size. More...
 
void assert_finite_internal () const
 Abort if any element of M is inf or nan. More...
 
void destroy ()
 Delete data. More...
 

Protected Attributes

unsigned num_rows
 
unsigned num_cols
 
int ** data
 

Private Types

typedef vnl_matrix< int > Base
 

Related Functions

(Note that these are not member functions.)

vnl_matrix< int > operator- (vnl_matrix< int > const &A, vnl_diag_matrix< int > const &D)
 Subtract a vnl_diag_matrix from a vnl_matrix. n adds, mn copies. More...
 
vnl_matrix< int > operator- (vnl_diag_matrix< int > const &D, vnl_matrix< int > const &A)
 Subtract a vnl_matrix from a vnl_diag_matrix. n adds, mn copies. More...
 
vnl_matrix_fixed< int, N, N > operator- (vnl_matrix_fixed< int, N, N > const &A, vnl_diag_matrix_fixed< int, N > const &D)
 Subtract a vnl_diag_matrix_fixed from a vnl_matrix. n adds, mn copies. More...
 
vnl_matrix_fixed< int, N, N > operator- (vnl_diag_matrix_fixed< int, N > const &D, vnl_matrix_fixed< int, N, N > const &A)
 Subtract a vnl_matrix from a vnl_diag_matrix_fixed. n adds, mn copies. More...
 
vnl_matrix< int > operator+ (vnl_matrix< int > const &A, vnl_diag_matrix< int > const &D)
 Add a vnl_diag_matrix to a vnl_matrix. n adds, mn copies. More...
 
vnl_matrix< int > operator+ (vnl_diag_matrix< int > const &D, vnl_matrix< int > const &A)
 Add a vnl_matrix to a vnl_diag_matrix. n adds, mn copies. More...
 
vnl_matrix_fixed< int, N, N > operator+ (vnl_matrix_fixed< int, N, N > const &A, vnl_diag_matrix_fixed< int, N > const &D)
 Add a vnl_diag_matrix_fixed to a vnl_matrix. n adds, mn copies. More...
 
vnl_matrix_fixed< int, N, N > operator+ (vnl_diag_matrix_fixed< int, N > const &D, vnl_matrix_fixed< int, N, N > const &A)
 Add a vnl_matrix to a vnl_diag_matrix_fixed. n adds, mn copies. More...
 
vnl_matrix< int > operator+ (int const &value, vnl_matrix< int > const &m)
 
vnl_matrix< int > operator * (vnl_matrix< int > const &A, vnl_diag_matrix< int > const &D)
 Multiply a vnl_matrix by a vnl_diag_matrix. Just scales the columns - mn flops. More...
 
vnl_matrix< int > operator * (vnl_diag_matrix< int > const &D, vnl_matrix< int > const &A)
 Multiply a vnl_diag_matrix by a vnl_matrix. Just scales the rows - mn flops. More...
 
vnl_matrix_fixed< int, R, C > operator * (vnl_matrix_fixed< int, R, C > const &A, vnl_diag_matrix_fixed< int, C > const &D)
 Multiply a vnl_matrix by a vnl_diag_matrix_fixed. Just scales the columns - mn flops. More...
 
vnl_matrix_fixed< int, R, C > operator * (vnl_diag_matrix_fixed< int, R > const &D, vnl_matrix_fixed< int, R, C > const &A)
 Multiply a vnl_diag_matrix_fixed by a vnl_matrix. Just scales the rows - mn flops. More...
 
vnl_matrix< int > operator * (int const &value, vnl_matrix< int > const &m)
 
vnl_sparse_matrix< int > operator * (int const &value, vnl_sparse_matrix< int > const &m)
 
vnl_vector< int > operator * (vnl_matrix< int > const &m, vnl_vector< int > const &v)
 multiply matrix and (column) vector. O(m*n). More...
 
void swap (vnl_matrix< int > &A, vnl_matrix< int > &B)
 Swap two matrices. More...
 
int vnl_determinant (vnl_matrix< int > const &M, bool balance=false)
 evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices. More...
 
void vnl_matrix_update (vnl_matrix< int > &M, const vnl_vector< int > &a, const vnl_vector< int > &b)
 Perform rank 1 update of M: M+=(a*b'). More...
 
vnl_matrix< int > vnl_orthogonal_complement (vnl_vector< int > const &v)
 Return a matrix whose columns span is the orthogonal complement of v. More...
 
void vsl_b_write (vsl_b_ostream &os, const vnl_matrix< int > &v)
 Binary save vnl_matrix to stream. More...
 
void vsl_b_read (vsl_b_istream &is, vnl_matrix< int > &v)
 Binary load vnl_matrix from stream. More...
 
void vsl_print_summary (std::ostream &os, const vnl_matrix< int > &b)
 Print human readable summary of object to a stream. More...
 
VNL_EXPORT vnl_matrix< std::complex< int > > vnl_complexify (vnl_matrix< int > const &R)
 Return complexified version of real matrix R. More...
 
VNL_EXPORT vnl_matrix< std::complex< int > > vnl_complexify (vnl_matrix< int > const &R, vnl_matrix< int > const &I)
 Return complex matrix R+j*I from two real matrices R and I. More...
 
VNL_EXPORT vnl_matrix< int > vnl_imag (vnl_matrix< std::complex< int > > const &C)
 Matrix of imaginary parts of vnl_matrix<std::complex<T> >. More...
 
vnl_matrix< int > vnl_inverse (vnl_matrix< int > const &m)
 Calculates inverse of a small vnl_matrix_fixed (not using svd). More...
 
vnl_matrix< int > vnl_inverse_transpose (vnl_matrix< int > const &m)
 Calculates transpose of the inverse of a small vnl_matrix_fixed (not using svd). More...
 
VNL_EXPORT std::ostream & vnl_matlab_print (std::ostream &, vnl_matrix< int > const &, char const *variable_name=nullptr, vnl_matlab_print_format=vnl_matlab_print_format_default)
 print a vnl_matrix<T>. More...
 
VNL_EXPORT bool operator< (vnl_matrix< int > const &lhs, vnl_matrix< int > const &rhs)
 Define a complete ordering on vnl_matrix. More...
 
vnl_matrix< int > vnl_power (vnl_matrix< int > const &m, int n)
 Calculates nth power of a square vnl_matrix (not using svd). More...
 
VNL_EXPORT unsigned int vnl_rank (vnl_matrix< int > const &mat, vnl_rank_type=vnl_rank_both)
 Returns the rank of a matrix. More...
 
VNL_EXPORT vnl_matrix< int > vnl_rank_row_reduce (vnl_matrix< int > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
 Row reduce a matrix. More...
 
VNL_EXPORT vnl_matrix< int > vnl_rank_column_reduce (vnl_matrix< int > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
 Column reduce a matrix. More...
 
VNL_EXPORT vnl_matrix< int > vnl_rank_row_column_reduce (vnl_matrix< int > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all)
 Row and column reduce a matrix. More...
 
VNL_EXPORT vnl_matrix< int > vnl_real (vnl_matrix< std::complex< int > > const &C)
 Matrix of real parts of vnl_matrix<std::complex<T> >. More...
 
VNL_EXPORT vnl_matrix< double > vnl_rotation_matrix (vnl_vector< double > const &axis)
 Returns an orthogonal 3x3 matrix which is a rotation about the axis, by an angle equal to ||axis||. More...
 
int vnl_trace (vnl_matrix< int > const &M)
 Calculate trace of a matrix. More...
 
void VNL_EXPORT x_write (std::ostream &os, vnl_matrix< int > const &v, std::string name="vnl_matrix")
 XML save vnl_matrix to stream. More...
 
void VNL_EXPORT x_write_tree (std::ostream &os, vnl_matrix< int > const &v, std::string name="vnl_matrix")
 XML save vnl_matrix as a 3-level tree to stream. More...
 

Detailed Description

Specializes vnl_matrix for integers, adding a vnl_matrix<double> ctor.

Definition at line 21 of file vnl_int_matrix.h.

Member Typedef Documentation

◆ abs_t

typedef vnl_c_vector<int >::abs_t vnl_matrix< int >::abs_t
inherited

Type def for norms.

Definition at line 499 of file vnl_matrix.h.

◆ Base

typedef vnl_matrix<int> vnl_int_matrix::Base
private

Definition at line 23 of file vnl_int_matrix.h.

◆ const_iterator

typedef int const* vnl_matrix< int >::const_iterator
inherited

Const iterators.

Definition at line 625 of file vnl_matrix.h.

◆ element_type

typedef int vnl_matrix< int >::element_type
inherited

Definition at line 615 of file vnl_matrix.h.

◆ iterator

typedef int * vnl_matrix< int >::iterator
inherited

Iterators.

Definition at line 618 of file vnl_matrix.h.

Constructor & Destructor Documentation

◆ vnl_int_matrix() [1/6]

vnl_int_matrix::vnl_int_matrix ( )
default

◆ vnl_int_matrix() [2/6]

vnl_int_matrix::vnl_int_matrix ( char const *  filename)

Load from disk.

Definition at line 27 of file vnl_int_matrix.cxx.

◆ vnl_int_matrix() [3/6]

vnl_int_matrix::vnl_int_matrix ( unsigned  r,
unsigned  c 
)
inline

Definition at line 28 of file vnl_int_matrix.h.

◆ vnl_int_matrix() [4/6]

vnl_int_matrix::vnl_int_matrix ( unsigned  r,
unsigned  c,
int  fillvalue 
)
inline

Definition at line 29 of file vnl_int_matrix.h.

◆ vnl_int_matrix() [5/6]

vnl_int_matrix::vnl_int_matrix ( const vnl_matrix< double > &  d)

Construct from matrix of double.

The double-to-int conversion is simply the standard (int) cast.

Definition at line 15 of file vnl_int_matrix.cxx.

◆ vnl_int_matrix() [6/6]

vnl_int_matrix::vnl_int_matrix ( const vnl_matrix< int > &  d)
inline

Definition at line 31 of file vnl_int_matrix.h.

Member Function Documentation

◆ absolute_value_max()

abs_t vnl_matrix< int >::absolute_value_max ( ) const
inlineinherited

Return largest absolute value.

Definition at line 514 of file vnl_matrix.h.

◆ absolute_value_sum()

abs_t vnl_matrix< int >::absolute_value_sum ( ) const
inlineinherited

Return sum of absolute values of elements.

Definition at line 511 of file vnl_matrix.h.

◆ apply() [1/2]

vnl_matrix< int > vnl_matrix< int >::apply ( int (*)(int )  f) const
inherited

Make a new matrix by applying function to each element.

Return the matrix made by applying "f" to each element.

Definition at line 644 of file vnl_matrix.hxx.

◆ apply() [2/2]

vnl_matrix< int > vnl_matrix< int >::apply ( int (*)(int const &)  f) const
inherited

Make a new matrix by applying function to each element.

Return the matrix made by applying "f" to each element.

Definition at line 635 of file vnl_matrix.hxx.

◆ apply_columnwise()

vnl_vector< int > vnl_matrix< int >::apply_columnwise ( int (*)(vnl_vector< int > const &)  f) const
inherited

Make a vector by applying a function across columns.

Definition at line 667 of file vnl_matrix.hxx.

◆ apply_rowwise()

vnl_vector< int > vnl_matrix< int >::apply_rowwise ( int (*)(vnl_vector< int > const &)  f) const
inherited

Make a vector by applying a function across rows.

Definition at line 655 of file vnl_matrix.hxx.

◆ arg_max()

unsigned vnl_matrix< int >::arg_max ( ) const
inlineinherited

Return location of maximum value of elements.

Definition at line 541 of file vnl_matrix.h.

◆ arg_min()

unsigned vnl_matrix< int >::arg_min ( ) const
inlineinherited

Return location of minimum value of elements.

Definition at line 538 of file vnl_matrix.h.

◆ array_inf_norm()

abs_t vnl_matrix< int >::array_inf_norm ( ) const
inlineinherited

Return largest absolute element value.

Definition at line 508 of file vnl_matrix.h.

◆ array_one_norm()

abs_t vnl_matrix< int >::array_one_norm ( ) const
inlineinherited

Return sum of absolute values of elements.

Definition at line 502 of file vnl_matrix.h.

◆ array_two_norm()

abs_t vnl_matrix< int >::array_two_norm ( ) const
inlineinherited

Return square root of sum of squared absolute element values.

Definition at line 505 of file vnl_matrix.h.

◆ as_ref() [1/2]

vnl_matrix<int > const& vnl_matrix< int >::as_ref ( ) const
inlineinherited

Return a reference to this.

Useful in code which would prefer not to know if its argument is a matrix, matrix_ref or a matrix_fixed. Note that it doesn't return a matrix_ref, so it's only useful in templates or macros.

Definition at line 635 of file vnl_matrix.h.

◆ as_ref() [2/2]

vnl_matrix<int >& vnl_matrix< int >::as_ref ( )
inlineinherited

Return a reference to this.

Definition at line 638 of file vnl_matrix.h.

◆ assert_finite()

void vnl_matrix< int >::assert_finite ( ) const
inlineinherited

abort if matrix contains any INFs or NANs.

This function does or tests nothing if NDEBUG is defined

Definition at line 582 of file vnl_matrix.h.

◆ assert_finite_internal()

void vnl_matrix< int >::assert_finite_internal ( ) const
protectedinherited

Abort if any element of M is inf or nan.

Definition at line 1249 of file vnl_matrix.hxx.

◆ assert_size()

void vnl_matrix< int >::assert_size ( unsigned  VXL_USED_IN_DEBUGr,
unsigned  VXL_USED_IN_DEBUG
) const
inlineinherited

abort if size is not as expected.

This function does or tests nothing if NDEBUG is defined

Definition at line 574 of file vnl_matrix.h.

◆ assert_size_internal()

void vnl_matrix< int >::assert_size_internal ( unsigned  r,
unsigned  c 
) const
protectedinherited

Abort unless M has the given size.

Definition at line 1275 of file vnl_matrix.hxx.

◆ begin() [1/2]

iterator vnl_matrix< int >::begin ( )
inlineinherited

Iterator pointing to start of data.

Definition at line 620 of file vnl_matrix.h.

◆ begin() [2/2]

const_iterator vnl_matrix< int >::begin ( ) const
inlineinherited

Iterator pointing to start of data.

Definition at line 627 of file vnl_matrix.h.

◆ clear()

void vnl_matrix< int >::clear ( )
inherited

Make the matrix as if it had been default-constructed.

Definition at line 375 of file vnl_matrix.hxx.

◆ cols()

unsigned int vnl_matrix< int >::cols ( ) const
inlineinherited

Return the number of columns.

A synonym for columns().

Definition at line 183 of file vnl_matrix.h.

◆ columns()

unsigned int vnl_matrix< int >::columns ( ) const
inlineinherited

Return the number of columns.

A synonym for cols().

Definition at line 187 of file vnl_matrix.h.

◆ conjugate_transpose()

vnl_matrix< int > vnl_matrix< int >::conjugate_transpose ( ) const
inherited

Return conjugate transpose.

Definition at line 694 of file vnl_matrix.hxx.

◆ copy_in()

vnl_matrix< int > & vnl_matrix< int >::copy_in ( int const *  p)
inherited

Fills (laminates) this matrix with the given data, then returns it.

Fill this matrix with the given data.

We assume that the argument points to a contiguous rows*cols array, stored rowwise. No bounds checking on the array. Returning "*this" allows "chaining" two or more operations: e.g., to fill a square matrix column-wise, fill it rowwise then transpose:

M.copy_in(array).inplace_transpose();

Returning "*this" also allows passing a filled-in matrix as argument to a function f, without having to name the constructed matrix:

f(vnl_matrix<double>(3,3).copy_in(array));

We assume that p points to a contiguous rows*cols array, stored rowwise.

Definition at line 837 of file vnl_matrix.hxx.

◆ copy_out()

void vnl_matrix< int >::copy_out ( int *  p) const
inherited

Fills the given array with this matrix.

Fill the given array with this matrix.

We assume that the argument points to a contiguous rows*cols array, stored rowwise. No bounds checking on the array.

We assume that p points to a contiguous rows*cols array, stored rowwise.

Definition at line 846 of file vnl_matrix.hxx.

◆ data_array() [1/2]

int const* const* vnl_matrix< int >::data_array ( ) const
inlineinherited

Access the 2D array, so that elements can be accessed with array[row][col] directly.

2d array, [row][column].

Definition at line 609 of file vnl_matrix.h.

◆ data_array() [2/2]

int * * vnl_matrix< int >::data_array ( )
inlineinherited

Access the 2D array, so that elements can be accessed with array[row][col] directly.

2d array, [row][column].

Definition at line 613 of file vnl_matrix.h.

◆ data_block() [1/2]

int const* vnl_matrix< int >::data_block ( ) const
inlineinherited

Access the contiguous block storing the elements in the matrix row-wise. O(1).

1d array, row-major order.

Definition at line 601 of file vnl_matrix.h.

◆ data_block() [2/2]

int * vnl_matrix< int >::data_block ( )
inlineinherited

Access the contiguous block storing the elements in the matrix row-wise. O(1).

1d array, row-major order.

Definition at line 605 of file vnl_matrix.h.

◆ destroy()

void vnl_matrix< int >::destroy ( )
protectedinherited

Delete data.

Frees up the dynamic storage used by matrix.

O(m*n).

Definition at line 369 of file vnl_matrix.hxx.

◆ empty()

bool vnl_matrix< int >::empty ( ) const
inlineinherited

Return true iff the size is zero.

Definition at line 549 of file vnl_matrix.h.

◆ end() [1/2]

iterator vnl_matrix< int >::end ( )
inlineinherited

Iterator pointing to element beyond end of data.

Definition at line 622 of file vnl_matrix.h.

◆ end() [2/2]

const_iterator vnl_matrix< int >::end ( ) const
inlineinherited

Iterator pointing to element beyond end of data.

Definition at line 629 of file vnl_matrix.h.

◆ extract() [1/2]

vnl_matrix< int > vnl_matrix< int >::extract ( unsigned  rowz,
unsigned  colz,
unsigned  top = 0,
unsigned  left = 0 
) const
inherited

Extract a sub-matrix of size r x c, starting at (top,left).

Returns a copy of submatrix of THIS matrix, specified by the top-left corner and size in rows, cols. O(m*n).

Thus it contains elements [top,top+r-1][left,left+c-1]

Use update() to copy new values of this submatrix back into THIS matrix.

Definition at line 728 of file vnl_matrix.hxx.

◆ extract() [2/2]

void vnl_matrix< int >::extract ( vnl_matrix< int > &  sub_matrix,
unsigned  top = 0,
unsigned  left = 0 
) const
inherited

Extract a sub-matrix starting at (top,left).

The output is stored in sub_matrix, and it should have the required size on entry. Thus the result will contain elements [top,top+sub_matrix.rows()-1][left,left+sub_matrix.cols()-1]

Definition at line 736 of file vnl_matrix.hxx.

◆ fill()

vnl_matrix< int > & vnl_matrix< int >::fill ( int const &  value)
inherited

Sets all elements of matrix to specified value, and returns "*this".

Sets all elements of matrix to specified value. O(m*n).

Complexity $O(r.c)$ Returning "*this" allows "chaining" two or more operations: e.g., to set a matrix to a column-normalized all-elements-equal matrix, say

M.fill(1).normalize_columns();

Returning "*this" also allows passing such a matrix as argument to a function f, without having to name the constructed matrix:

Definition at line 419 of file vnl_matrix.hxx.

◆ fill_diagonal()

vnl_matrix< int > & vnl_matrix< int >::fill_diagonal ( int const &  value)
inherited

Sets all diagonal elements of matrix to specified value; returns "*this".

Sets all diagonal elements of matrix to specified value. O(n).

Complexity $O(\min(r,c))$ Returning "*this" allows "chaining" two or more operations: e.g., to set a 3x3 matrix to [5 0 0][0 10 0][0 0 15], just say

M.fill_diagonal(5).scale_row(1,2).scale_column(2,3);

Returning "*this" also allows passing a diagonal-filled matrix as argument to a function f, without having to name the constructed matrix:

Definition at line 430 of file vnl_matrix.hxx.

◆ flatten_column_major()

vnl_vector< int > vnl_matrix< int >::flatten_column_major ( ) const
inherited

Flatten column-major (Fortran-style).

Definition at line 1035 of file vnl_matrix.hxx.

◆ flatten_row_major()

vnl_vector< int > vnl_matrix< int >::flatten_row_major ( ) const
inherited

Flatten row-major (C-style).

Definition at line 1026 of file vnl_matrix.hxx.

◆ fliplr()

vnl_matrix< int > & vnl_matrix< int >::fliplr ( )
inherited

Reverses the order of columns, and returns "*this".

Reverse order of columns.

Returning "*this" allows "chaining" two or more operations: e.g., to flip both up-down and left-right, one could just say

M.flipud().fliplr();

Definition at line 1449 of file vnl_matrix.hxx.

◆ flipud()

vnl_matrix< int > & vnl_matrix< int >::flipud ( )
inherited

Reverses the order of rows, and returns "*this".

Reverse order of rows. Name is from Matlab, meaning "flip upside down".

Returning "*this" allows "chaining" two or more operations: e.g., to flip both up-down and left-right, one could just say

M.flipud().fliplr();

Definition at line 1429 of file vnl_matrix.hxx.

◆ fro_norm()

abs_t vnl_matrix< int >::fro_norm ( ) const
inlineinherited

Return Frobenius norm of matrix (sqrt of sum of squares of its elements).

Definition at line 526 of file vnl_matrix.h.

◆ frobenius_norm()

abs_t vnl_matrix< int >::frobenius_norm ( ) const
inlineinherited

Return Frobenius norm of matrix (sqrt of sum of squares of its elements).

Definition at line 523 of file vnl_matrix.h.

◆ get()

int vnl_matrix< int >::get ( unsigned  r,
unsigned  c 
) const
inlineinherited

get element with boundary checks if error checking is on.

Returns the value of the element at specified row and column. O(1).

Checks for valid range of indices.

Definition at line 684 of file vnl_matrix.h.

◆ get_column()

vnl_vector< int > vnl_matrix< int >::get_column ( unsigned  c) const
inherited

Get a vector equal to the given column.

Create a vector out of column[column_index].

Definition at line 977 of file vnl_matrix.hxx.

◆ get_columns()

vnl_matrix< int > vnl_matrix< int >::get_columns ( vnl_vector< unsigned int >  i) const
inherited

Get a matrix composed of columns from the indices specified in the supplied vector.

Create a vector out of column[column_index].

Definition at line 1006 of file vnl_matrix.hxx.

◆ get_diagonal()

vnl_vector< int > vnl_matrix< int >::get_diagonal ( ) const
inherited

Return a vector with the content of the (main) diagonal.

Definition at line 1016 of file vnl_matrix.hxx.

◆ get_n_columns()

vnl_matrix< int > vnl_matrix< int >::get_n_columns ( unsigned  colstart,
unsigned  n 
) const
inherited

Get n columns beginning at colstart.

Returns a copy of n columns, starting from "column".

Definition at line 946 of file vnl_matrix.hxx.

◆ get_n_rows()

vnl_matrix< int > vnl_matrix< int >::get_n_rows ( unsigned  rowstart,
unsigned  n 
) const
inherited

Get n rows beginning at rowstart.

Returns a copy of n rows, starting from "row".

Definition at line 933 of file vnl_matrix.hxx.

◆ get_row()

vnl_vector< int > vnl_matrix< int >::get_row ( unsigned  r) const
inherited

Get a vector equal to the given row.

Create a vector out of row[row_index].

Definition at line 962 of file vnl_matrix.hxx.

◆ get_rows()

vnl_matrix< int > vnl_matrix< int >::get_rows ( vnl_vector< unsigned int >  i) const
inherited

Get a matrix composed of rows from the indices specified in the supplied vector.

Create a vector out of row[row_index].

Definition at line 994 of file vnl_matrix.hxx.

◆ has_nans()

bool vnl_matrix< int >::has_nans ( ) const
inherited

Return true if matrix contains NaNs.

Return true if any element of (*this) is nan.

Definition at line 1225 of file vnl_matrix.hxx.

◆ inplace_transpose()

vnl_matrix< int > & vnl_matrix< int >::inplace_transpose ( )
inherited

Transposes this matrix efficiently, and returns it.

Transpose matrix M in place.

Returning "*this" allows "chaining" two or more operations: e.g., to fill a square matrix column-wise, fill it rowwise then transpose:

M.copy_in(array).inplace_transpose();

Works for rectangular matrices using an enormously clever algorithm from ACM TOMS.

Definition at line 1619 of file vnl_matrix.hxx.

◆ is_equal()

bool vnl_matrix< int >::is_equal ( vnl_matrix< int > const &  rhs,
double  tol 
) const
inherited

Return true if all elements of both matrices are equal, within given tolerance.

Definition at line 1153 of file vnl_matrix.hxx.

◆ is_finite()

bool vnl_matrix< int >::is_finite ( ) const
inherited

Return true if finite.

Return false if any element of (*this) is inf or nan.

Definition at line 1237 of file vnl_matrix.hxx.

◆ is_identity() [1/2]

bool vnl_matrix< int >::is_identity ( ) const
inherited

Return true if all elements equal to identity.

Definition at line 1171 of file vnl_matrix.hxx.

◆ is_identity() [2/2]

bool vnl_matrix< int >::is_identity ( double  tol) const
inherited

Return true if all elements equal to identity, within given tolerance.

Return true if maximum absolute deviation of M from identity is <= tol.

Definition at line 1186 of file vnl_matrix.hxx.

◆ is_zero() [1/2]

bool vnl_matrix< int >::is_zero ( ) const
inherited

Return true if all elements equal to zero.

Definition at line 1200 of file vnl_matrix.hxx.

◆ is_zero() [2/2]

bool vnl_matrix< int >::is_zero ( double  tol) const
inherited

Return true if all elements equal to zero, within given tolerance.

Return true if max(abs((*this))) <= tol.

Definition at line 1213 of file vnl_matrix.hxx.

◆ max_value()

int vnl_matrix< int >::max_value ( ) const
inlineinherited

Return maximum value of elements.

Definition at line 535 of file vnl_matrix.h.

◆ mean()

int vnl_matrix< int >::mean ( ) const
inlineinherited

Return mean of all matrix elements.

Definition at line 544 of file vnl_matrix.h.

◆ min_value()

int vnl_matrix< int >::min_value ( ) const
inlineinherited

Return minimum value of elements.

Definition at line 532 of file vnl_matrix.h.

◆ normalize_columns()

vnl_matrix< int > & vnl_matrix< int >::normalize_columns ( )
inherited

Normalizes each column so it is a unit vector, and returns "*this".

Make each column of the matrix have unit norm.

Zero columns are not modified Returning "*this" allows "chaining" two or more operations: e.g., to set a matrix to a column-normalized all-elements-equal matrix, say

M.fill(1).normalize_columns();

Returning "*this" also allows passing such a matrix as argument to a function f, without having to name the constructed matrix:

All-zero columns are ignored.

Definition at line 886 of file vnl_matrix.hxx.

◆ normalize_rows()

vnl_matrix< int > & vnl_matrix< int >::normalize_rows ( )
inherited

Normalizes each row so it is a unit vector, and returns "*this".

Make each row of the matrix have unit norm.

Zero rows are not modified Returning "*this" allows "chaining" two or more operations: e.g., to set a matrix to a row-normalized all-elements-equal matrix, say

M.fill(1).normalize_rows();

Returning "*this" also allows passing such a matrix as argument to a function f, without having to name the constructed matrix:

All-zero rows are ignored.

Definition at line 864 of file vnl_matrix.hxx.

◆ operator *() [1/2]

vnl_matrix<int > vnl_matrix< int >::operator * ( int const &  v) const
inlineinherited

Scalar multiplication of lhs matrix by rhs and return result in new matrix.

Definition at line 314 of file vnl_matrix.h.

◆ operator *() [2/2]

vnl_matrix<int > vnl_matrix< int >::operator * ( vnl_matrix< int > const &  rhs) const
inlineinherited

Matrix multiply lhs by rhs matrix and return result in new matrix.

Definition at line 324 of file vnl_matrix.h.

◆ operator *=() [1/2]

vnl_matrix< int > & vnl_matrix< int >::operator *= ( int  value)
inherited

Scalar multiplication in situ of lhs matrix by rhs.

Definition at line 551 of file vnl_matrix.hxx.

◆ operator *=() [2/2]

vnl_matrix<int >& vnl_matrix< int >::operator *= ( vnl_matrix< int > const &  rhs)
inlineinherited

Multiply lhs matrix in situ by rhs.

Definition at line 301 of file vnl_matrix.h.

◆ operator!=()

bool vnl_matrix< int >::operator!= ( vnl_matrix< int > const &  that) const
inlineinherited

Inequality operator.

Definition at line 649 of file vnl_matrix.h.

◆ operator()() [1/2]

int & vnl_matrix< int >::operator() ( unsigned  r,
unsigned  c 
)
inherited

Access an element for reading or writing.

There are assert style boundary checks - #define NDEBUG to turn them off.

Definition at line 455 of file vnl_matrix.hxx.

◆ operator()() [2/2]

int const & vnl_matrix< int >::operator() ( unsigned  r,
unsigned  c 
) const
inherited

Access an element for reading.

There are assert style boundary checks - #define NDEBUG to turn them off.

Definition at line 467 of file vnl_matrix.hxx.

◆ operator+() [1/2]

vnl_matrix<int > vnl_matrix< int >::operator+ ( int const &  v) const
inlineinherited

Add rhs to each element of lhs matrix and return result in new matrix.

Definition at line 308 of file vnl_matrix.h.

◆ operator+() [2/2]

vnl_matrix<int > vnl_matrix< int >::operator+ ( vnl_matrix< int > const &  rhs) const
inlineinherited

Matrix add rhs to lhs matrix and return result in new matrix.

Definition at line 320 of file vnl_matrix.h.

◆ operator+=() [1/2]

vnl_matrix< int > & vnl_matrix< int >::operator+= ( int  value)
inherited

Add rhs to each element of lhs matrix in situ.

Definition at line 533 of file vnl_matrix.hxx.

◆ operator+=() [2/2]

vnl_matrix< int > & vnl_matrix< int >::operator+= ( vnl_matrix< int > const &  rhs)
inherited

Add rhs to lhs matrix in situ.

Adds lhs matrix with rhs matrix, and stores in place in lhs matrix.

O(m*n). The dimensions of the two matrices must be identical.

Definition at line 573 of file vnl_matrix.hxx.

◆ operator-() [1/3]

vnl_matrix< int > vnl_matrix< int >::operator- ( ) const
inherited

Negate all elements of matrix.

Returns new matrix which is the negation of THIS matrix.

O(m*n).

Definition at line 624 of file vnl_matrix.hxx.

◆ operator-() [2/3]

vnl_matrix<int > vnl_matrix< int >::operator- ( int const &  v) const
inlineinherited

Subtract rhs from each element of lhs matrix and return result in new matrix.

Definition at line 311 of file vnl_matrix.h.

◆ operator-() [3/3]

vnl_matrix<int > vnl_matrix< int >::operator- ( vnl_matrix< int > const &  rhs) const
inlineinherited

Matrix subtract rhs from lhs and return result in new matrix.

Definition at line 322 of file vnl_matrix.h.

◆ operator-=() [1/2]

vnl_matrix< int > & vnl_matrix< int >::operator-= ( int  value)
inherited

Subtract rhs from each element of lhs matrix in situ.

Definition at line 542 of file vnl_matrix.hxx.

◆ operator-=() [2/2]

vnl_matrix< int > & vnl_matrix< int >::operator-= ( vnl_matrix< int > const &  rhs)
inherited

Subtract rhs from lhs matrix in situ.

Subtract lhs matrix with rhs matrix and store in place in lhs matrix.

O(m*n). The dimensions of the two matrices must be identical.

Definition at line 594 of file vnl_matrix.hxx.

◆ operator/()

vnl_matrix<int > vnl_matrix< int >::operator/ ( int const &  v) const
inlineinherited

Scalar division of lhs matrix by rhs and return result in new matrix.

Definition at line 317 of file vnl_matrix.h.

◆ operator/=()

vnl_matrix< int > & vnl_matrix< int >::operator/= ( int  value)
inherited

Scalar division of lhs matrix in situ by rhs.

Definition at line 560 of file vnl_matrix.hxx.

◆ operator=()

vnl_int_matrix& vnl_int_matrix::operator= ( const vnl_matrix< int > &  d)
inline

Definition at line 32 of file vnl_int_matrix.h.

◆ operator==()

bool vnl_matrix< int >::operator== ( vnl_matrix< int > const &  that) const
inlineinherited

Equality operator.

Definition at line 646 of file vnl_matrix.h.

◆ operator[]() [1/2]

int * vnl_matrix< int >::operator[] ( unsigned  r)
inlineinherited

return pointer to given row.

No boundary checking here.

Definition at line 197 of file vnl_matrix.h.

◆ operator[]() [2/2]

int const* vnl_matrix< int >::operator[] ( unsigned  r) const
inlineinherited

return pointer to given row.

No boundary checking here.

Definition at line 201 of file vnl_matrix.h.

◆ operator_eq()

bool vnl_matrix< int >::operator_eq ( vnl_matrix< int > const &  rhs) const
inherited

Return true if *this == rhs.

Two matrices are equal if and only if they have the same dimensions and the same values.

O(m*n). Elements are compared with operator== as default. Change this default with set_compare() at run time or by specializing vnl_matrix_compare at compile time.

Definition at line 1136 of file vnl_matrix.hxx.

◆ operator_inf_norm()

vnl_matrix< int >::abs_t vnl_matrix< int >::operator_inf_norm ( ) const
inherited

Definition at line 1486 of file vnl_matrix.hxx.

◆ operator_one_norm()

vnl_matrix< int >::abs_t vnl_matrix< int >::operator_one_norm ( ) const
inherited

Definition at line 1470 of file vnl_matrix.hxx.

◆ print()

void vnl_matrix< int >::print ( std::ostream &  os) const
inherited

Print matrix to os in some hopefully sensible format.

Definition at line 500 of file vnl_matrix.hxx.

◆ put()

void vnl_matrix< int >::put ( unsigned  r,
unsigned  c,
int const &  v 
)
inlineinherited

set element with boundary checks if error checking is on.

Puts value into element at specified row and column. O(1).

Checks for valid range of indices.

Definition at line 700 of file vnl_matrix.h.

◆ read()

vnl_matrix< int > vnl_matrix< int >::read ( std::istream &  s)
staticinherited

Read a vnl_matrix from an ascii std::istream, automatically determining file size if the input matrix has zero size.

Read a vnl_matrix from an ascii std::istream.

Automatically determines file size if the input matrix has zero size. This is a static method so you can type <verb> vnl_matrix<float> M = vnl_matrix<float>::read(cin); </verb> which many people prefer to the ">>" alternative.

Definition at line 1412 of file vnl_matrix.hxx.

◆ read_ascii()

bool vnl_matrix< int >::read_ascii ( std::istream &  s)
inherited

Read a vnl_matrix from an ascii std::istream.

Automatically determines file size if the input matrix has zero size.

Definition at line 1287 of file vnl_matrix.hxx.

◆ rms()

abs_t vnl_matrix< int >::rms ( ) const
inlineinherited

Return RMS of all elements.

Definition at line 529 of file vnl_matrix.h.

◆ rows()

unsigned int vnl_matrix< int >::rows ( ) const
inlineinherited

Return the number of rows.

Definition at line 179 of file vnl_matrix.h.

◆ scale_column()

vnl_matrix< int > & vnl_matrix< int >::scale_column ( unsigned  col,
int  value 
)
inherited

Scales elements in given column by a factor T, and returns "*this".

Multiply column[column_index] by value.

Returning "*this" allows "chaining" two or more operations: e.g., to set a 3x3 matrix to [3 0 0][0 2 0][0 0 1], one could say

M.set_identity().scale_row(0,3).scale_column(1,2);

Definition at line 920 of file vnl_matrix.hxx.

◆ scale_row()

vnl_matrix< int > & vnl_matrix< int >::scale_row ( unsigned  row,
int  value 
)
inherited

Scales elements in given row by a factor T, and returns "*this".

Multiply row[row_index] by value.

Returning "*this" allows "chaining" two or more operations: e.g., to set a 3x3 matrix to [3 0 0][0 2 0][0 0 1], one could say

M.set_identity().scale_row(0,3).scale_column(1,2);

Definition at line 907 of file vnl_matrix.hxx.

◆ set()

vnl_matrix& vnl_matrix< int >::set ( int const *  d)
inlineinherited

Fills (laminates) this matrix with the given data, then returns it.

A synonym for copy_in()

Definition at line 265 of file vnl_matrix.h.

◆ set_column() [1/3]

vnl_matrix< int > & vnl_matrix< int >::set_column ( unsigned  i,
int const *  v 
)
inherited

Set the elements of the i'th column to v[i] (No bounds checking).

Set column[column_index] to data at given address.

Definition at line 1080 of file vnl_matrix.hxx.

◆ set_column() [2/3]

vnl_matrix< int > & vnl_matrix< int >::set_column ( unsigned  i,
int  value 
)
inherited

Set the elements of the i'th column to value, then return *this.

Set column[column_index] to given value.

Definition at line 1101 of file vnl_matrix.hxx.

◆ set_column() [3/3]

vnl_matrix< int > & vnl_matrix< int >::set_column ( unsigned  j,
vnl_vector< int > const &  v 
)
inherited

Set j-th column to v, then return *this.

Set column[column_index] to given vector.

Definition at line 1089 of file vnl_matrix.hxx.

◆ set_columns()

vnl_matrix< int > & vnl_matrix< int >::set_columns ( unsigned  starting_column,
vnl_matrix< int > const &  M 
)
inherited

Set columns to those in M, starting at starting_column, then return *this.

Set columns starting at starting_column to given matrix.

Definition at line 1111 of file vnl_matrix.hxx.

◆ set_diagonal()

vnl_matrix< int > & vnl_matrix< int >::set_diagonal ( vnl_vector< int > const &  diag)
inherited

Sets the diagonal elements of this matrix to the specified list of values.

Returning "*this" allows "chaining" two or more operations: see the reasoning (and the examples) in the documentation for method fill_diagonal().

Definition at line 440 of file vnl_matrix.hxx.

◆ set_identity()

vnl_matrix< int > & vnl_matrix< int >::set_identity ( )
inherited

Sets this matrix to an identity matrix, then returns "*this".

Fill this matrix with a matrix having 1s on the main diagonal and 0s elsewhere.

Returning "*this" allows e.g. passing an identity matrix as argument to a function f, without having to name the constructed matrix:

Returning "*this" also allows "chaining" two or more operations: e.g., to set a 3x3 matrix to [3 0 0][0 2 0][0 0 1], one could say

M.set_identity().scale_row(0,3).scale_column(1,2);

If the matrix is not square, anyhow set main diagonal to 1, the rest to 0.

Definition at line 853 of file vnl_matrix.hxx.

◆ set_row() [1/3]

vnl_matrix< int > & vnl_matrix< int >::set_row ( unsigned  i,
int const *  v 
)
inherited

Set the elements of the i'th row to v[i] (No bounds checking).

Set row[row_index] to data at given address. No bounds check.

Definition at line 1048 of file vnl_matrix.hxx.

◆ set_row() [2/3]

vnl_matrix< int > & vnl_matrix< int >::set_row ( unsigned  i,
int  value 
)
inherited

Set the elements of the i'th row to value, then return *this.

Set row[row_index] to given value.

Definition at line 1069 of file vnl_matrix.hxx.

◆ set_row() [3/3]

vnl_matrix< int > & vnl_matrix< int >::set_row ( unsigned  i,
vnl_vector< int > const &  v 
)
inherited

Set the i-th row.

Set row[row_index] to given vector.

Definition at line 1057 of file vnl_matrix.hxx.

◆ set_size()

bool vnl_matrix< int >::set_size ( unsigned  r,
unsigned  c 
)
inherited

Resize to r rows by c columns. Old data lost.

Returns true if size changed.

Definition at line 390 of file vnl_matrix.hxx.

◆ size()

unsigned int vnl_matrix< int >::size ( ) const
inlineinherited

Return the total number of elements stored by the matrix.

This equals rows() * cols()

Definition at line 176 of file vnl_matrix.h.

◆ swap()

void vnl_matrix< int >::swap ( vnl_matrix< int > &  that)
inherited

Swap this matrix with that matrix.

Definition at line 1420 of file vnl_matrix.hxx.

◆ transpose()

vnl_matrix< int > vnl_matrix< int >::transpose ( ) const
inherited

Return transpose.

Returns new matrix with rows and columns transposed.

O(m*n).

Definition at line 682 of file vnl_matrix.hxx.

◆ update()

vnl_matrix< int > & vnl_matrix< int >::update ( vnl_matrix< int > const &  m,
unsigned  top = 0,
unsigned  left = 0 
)
inherited

Set values of this matrix to those of M, starting at [top,left].

Replaces the submatrix of THIS matrix, starting at top left corner, by the elements of matrix m. O(m*n).

This is the reverse of extract().

Definition at line 707 of file vnl_matrix.hxx.

Friends And Related Function Documentation

◆ operator *() [1/7]

vnl_matrix_fixed< int , R, C > operator * ( vnl_matrix_fixed< int , R, C > const &  A,
vnl_diag_matrix_fixed< int , C > const &  D 
)
related

Multiply a vnl_matrix by a vnl_diag_matrix_fixed. Just scales the columns - mn flops.

Definition at line 234 of file vnl_diag_matrix_fixed.h.

◆ operator *() [2/7]

vnl_matrix< int > operator * ( vnl_matrix< int > const &  A,
vnl_diag_matrix< int > const &  D 
)
related

Multiply a vnl_matrix by a vnl_diag_matrix. Just scales the columns - mn flops.

Definition at line 239 of file vnl_diag_matrix.h.

◆ operator *() [3/7]

vnl_matrix_fixed< int , R, C > operator * ( vnl_diag_matrix_fixed< int , R > const &  D,
vnl_matrix_fixed< int , R, C > const &  A 
)
related

Multiply a vnl_diag_matrix_fixed by a vnl_matrix. Just scales the rows - mn flops.

Definition at line 247 of file vnl_diag_matrix_fixed.h.

◆ operator *() [4/7]

vnl_matrix< int > operator * ( vnl_diag_matrix< int > const &  D,
vnl_matrix< int > const &  A 
)
related

Multiply a vnl_diag_matrix by a vnl_matrix. Just scales the rows - mn flops.

Definition at line 253 of file vnl_diag_matrix.h.

◆ operator *() [5/7]

vnl_sparse_matrix< int > operator * ( int const &  value,
vnl_sparse_matrix< int > const &  m 
)
related

Definition at line 310 of file vnl_sparse_matrix.h.

◆ operator *() [6/7]

vnl_vector< int > operator * ( vnl_matrix< int > const &  m,
vnl_vector< int > const &  v 
)
related

multiply matrix and (column) vector. O(m*n).

Definition at line 442 of file vnl_vector.h.

◆ operator *() [7/7]

vnl_matrix< int > operator * ( int const &  value,
vnl_matrix< int > const &  m 
)
related

Definition at line 717 of file vnl_matrix.h.

◆ operator+() [1/5]

vnl_matrix_fixed< int , N, N > operator+ ( vnl_matrix_fixed< int , N, N > const &  A,
vnl_diag_matrix_fixed< int , N > const &  D 
)
related

Add a vnl_diag_matrix_fixed to a vnl_matrix. n adds, mn copies.

Definition at line 272 of file vnl_diag_matrix_fixed.h.

◆ operator+() [2/5]

vnl_matrix< int > operator+ ( vnl_matrix< int > const &  A,
vnl_diag_matrix< int > const &  D 
)
related

Add a vnl_diag_matrix to a vnl_matrix. n adds, mn copies.

Definition at line 280 of file vnl_diag_matrix.h.

◆ operator+() [3/5]

vnl_matrix_fixed< int , N, N > operator+ ( vnl_diag_matrix_fixed< int , N > const &  D,
vnl_matrix_fixed< int , N, N > const &  A 
)
related

Add a vnl_matrix to a vnl_diag_matrix_fixed. n adds, mn copies.

Definition at line 285 of file vnl_diag_matrix_fixed.h.

◆ operator+() [4/5]

vnl_matrix< int > operator+ ( vnl_diag_matrix< int > const &  D,
vnl_matrix< int > const &  A 
)
related

Add a vnl_matrix to a vnl_diag_matrix. n adds, mn copies.

Definition at line 295 of file vnl_diag_matrix.h.

◆ operator+() [5/5]

vnl_matrix< int > operator+ ( int const &  value,
vnl_matrix< int > const &  m 
)
related

Definition at line 725 of file vnl_matrix.h.

◆ operator-() [1/4]

vnl_matrix_fixed< int , N, N > operator- ( vnl_matrix_fixed< int , N, N > const &  A,
vnl_diag_matrix_fixed< int , N > const &  D 
)
related

Subtract a vnl_diag_matrix_fixed from a vnl_matrix. n adds, mn copies.

Definition at line 305 of file vnl_diag_matrix_fixed.h.

◆ operator-() [2/4]

vnl_matrix< int > operator- ( vnl_matrix< int > const &  A,
vnl_diag_matrix< int > const &  D 
)
related

Subtract a vnl_diag_matrix from a vnl_matrix. n adds, mn copies.

Definition at line 316 of file vnl_diag_matrix.h.

◆ operator-() [3/4]

vnl_matrix_fixed< int , N, N > operator- ( vnl_diag_matrix_fixed< int , N > const &  D,
vnl_matrix_fixed< int , N, N > const &  A 
)
related

Subtract a vnl_matrix from a vnl_diag_matrix_fixed. n adds, mn copies.

Definition at line 318 of file vnl_diag_matrix_fixed.h.

◆ operator-() [4/4]

vnl_matrix< int > operator- ( vnl_diag_matrix< int > const &  D,
vnl_matrix< int > const &  A 
)
related

Subtract a vnl_matrix from a vnl_diag_matrix. n adds, mn copies.

Definition at line 331 of file vnl_diag_matrix.h.

◆ operator<()

VNL_EXPORT bool operator< ( vnl_matrix< int > const &  lhs,
vnl_matrix< int > const &  rhs 
)
related

Define a complete ordering on vnl_matrix.

This is useful to create a set, or map of matrices.

The ordering itself is implementation defined - so don't rely on the meaning of less here.

Definition at line 48 of file vnl_operators.h.

◆ swap()

void swap ( vnl_matrix< int > &  A,
vnl_matrix< int > &  B 
)
related

Swap two matrices.

Definition at line 733 of file vnl_matrix.h.

◆ vnl_complexify() [1/2]

VNL_EXPORT vnl_matrix< std::complex< int > > vnl_complexify ( vnl_matrix< int > const &  R)
related

Return complexified version of real matrix R.

Definition at line 57 of file vnl_complex_ops.hxx.

◆ vnl_complexify() [2/2]

VNL_EXPORT vnl_matrix< std::complex< int > > vnl_complexify ( vnl_matrix< int > const &  R,
vnl_matrix< int > const &  I 
)
related

Return complex matrix R+j*I from two real matrices R and I.

Definition at line 105 of file vnl_complex_ops.hxx.

◆ vnl_determinant()

int vnl_determinant ( vnl_matrix< int > const &  M,
bool  balance = false 
)
related

evaluation using direct methods for sizes of 2x2, 3x3, and 4x4 or qr decomposition for other matrices.

◆ vnl_imag()

VNL_EXPORT vnl_matrix< int > vnl_imag ( vnl_matrix< std::complex< int > > const &  C)
related

Matrix of imaginary parts of vnl_matrix<std::complex<T> >.

Definition at line 240 of file vnl_complex_ops.hxx.

◆ vnl_inverse()

vnl_matrix< int > vnl_inverse ( vnl_matrix< int > const &  m)
related

Calculates inverse of a small vnl_matrix_fixed (not using svd).

This allows you to write e.g.

x = vnl_inverse(A) * b;

Note that this function is inlined (except for the call to vnl_det()), which makes it much faster than the vnl_matrix_inverse class in vnl/algo since that one is using svd.

Definition at line 171 of file vnl_inverse.h.

◆ vnl_inverse_transpose()

vnl_matrix< int > vnl_inverse_transpose ( vnl_matrix< int > const &  m)
related

Calculates transpose of the inverse of a small vnl_matrix_fixed (not using svd).

This allows you to write e.g.

x = vnl_inverse_transpose(A) * b;

Note that this function is inlined (except for the call to vnl_det()), which makes it much faster than the vnl_matrix_inverse class in vnl/algo since that one is using svd. This is also faster than using

x = vnl_inverse(A).transpose() * b;

Definition at line 339 of file vnl_inverse.h.

◆ vnl_matlab_print()

VNL_EXPORT std::ostream & vnl_matlab_print ( std::ostream &  ,
vnl_matrix< int > const &  ,
char const *  variable_name = nullptr,
vnl_matlab_print_format  = vnl_matlab_print_format_default 
)
related

print a vnl_matrix<T>.

◆ vnl_matrix_update()

void vnl_matrix_update ( vnl_matrix< int > &  M,
const vnl_vector< int > &  a,
const vnl_vector< int > &  b 
)
related

Perform rank 1 update of M: M+=(a*b').

Requires a.size()==M.rows(), b.size()==M.columns()

Definition at line 20 of file vnl_matrix_update.h.

◆ vnl_orthogonal_complement()

vnl_matrix< int > vnl_orthogonal_complement ( vnl_vector< int > const &  v)
related

Return a matrix whose columns span is the orthogonal complement of v.

◆ vnl_power()

vnl_matrix< int > vnl_power ( vnl_matrix< int > const &  m,
int  n 
)
related

Calculates nth power of a square vnl_matrix (not using svd).

This allows you to write e.g.

x = vnl_power(A,7) * vnl_power(B,-4) * b;

Note that this function is inlined (except for the call to vnl_inverse()), which makes it much faster than a full-fledged square matrix power implementation using svd, which belongs in vnl/algo.

Definition at line 63 of file vnl_power.h.

◆ vnl_rank()

VNL_EXPORT unsigned int vnl_rank ( vnl_matrix< int > const &  mat,
vnl_rank_type  = vnl_rank_both 
)
related

Returns the rank of a matrix.

By default, the row rank of the matrix is determined. Specify vnl_rank_column to obtain the column rank.

◆ vnl_rank_column_reduce()

VNL_EXPORT vnl_matrix< int > vnl_rank_column_reduce ( vnl_matrix< int > const &  mat,
vnl_rank_pivot_type  = vnl_rank_pivot_all 
)
related

Column reduce a matrix.

◆ vnl_rank_row_column_reduce()

VNL_EXPORT vnl_matrix< int > vnl_rank_row_column_reduce ( vnl_matrix< int > const &  mat,
vnl_rank_pivot_type  = vnl_rank_pivot_all 
)
related

Row and column reduce a matrix.

Perform both row reduction and column reduction on a matrix. The resulting matrix will in general no longer span the same row space (or column space) as the original matrix, but the rank will not have changed, and the number of nonzero elements will be minimal (viz at most one per row and one per column).

◆ vnl_rank_row_reduce()

VNL_EXPORT vnl_matrix< int > vnl_rank_row_reduce ( vnl_matrix< int > const &  mat,
vnl_rank_pivot_type  = vnl_rank_pivot_all 
)
related

Row reduce a matrix.

First try to use 1 or -1 as pivot element in each row, to avoid divisions; then use any nonzero element as candidate pivot. Repeat this process until the matrix does not change any more. At that point, the matrix spans the same row space as before and contains as many zeros as possible.

When specifying vnl_rank_pivot_one is given as second argument, only elements with value 1 or -1 are used as candidate pivot elements.

Note that for integer matrices, the resulting matrix is still integer, and is guaranteed to be row equivalent with the original matrix.

◆ vnl_real()

VNL_EXPORT vnl_matrix< int > vnl_real ( vnl_matrix< std::complex< int > > const &  C)
related

Matrix of real parts of vnl_matrix<std::complex<T> >.

Definition at line 169 of file vnl_complex_ops.hxx.

◆ vnl_rotation_matrix()

VNL_EXPORT vnl_matrix< double > vnl_rotation_matrix ( vnl_vector< double > const &  axis)
related

Returns an orthogonal 3x3 matrix which is a rotation about the axis, by an angle equal to ||axis||.

Definition at line 69 of file vnl_rotation_matrix.cxx.

◆ vnl_trace()

int vnl_trace ( vnl_matrix< int > const &  M)
related

Calculate trace of a matrix.

Definition at line 22 of file vnl_trace.h.

◆ vsl_b_read()

void vsl_b_read ( vsl_b_istream &  is,
vnl_matrix< int > &  v 
)
related

Binary load vnl_matrix from stream.

◆ vsl_b_write()

void vsl_b_write ( vsl_b_ostream &  os,
const vnl_matrix< int > &  v 
)
related

Binary save vnl_matrix to stream.

◆ vsl_print_summary()

void vsl_print_summary ( std::ostream &  os,
const vnl_matrix< int > &  b 
)
related

Print human readable summary of object to a stream.

◆ x_write()

void VNL_EXPORT x_write ( std::ostream &  os,
vnl_matrix< int > const &  v,
std::string  name = "vnl_matrix< int >" 
)
related

XML save vnl_matrix to stream.

◆ x_write_tree()

void VNL_EXPORT x_write_tree ( std::ostream &  os,
vnl_matrix< int > const &  v,
std::string  name = "vnl_matrix< int >" 
)
related

XML save vnl_matrix as a 3-level tree to stream.

Member Data Documentation

◆ data

int ** vnl_matrix< int >::data
protectedinherited

Definition at line 666 of file vnl_matrix.h.

◆ num_cols

unsigned vnl_matrix< int >::num_cols
protectedinherited

Definition at line 665 of file vnl_matrix.h.

◆ num_rows

unsigned vnl_matrix< int >::num_rows
protectedinherited

Definition at line 664 of file vnl_matrix.h.


The documentation for this class was generated from the following files: