Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types
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]

List of all members.

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

void assert_size_internal (unsigned r, unsigned c) const
void assert_finite_internal () const
void destroy ()
 Delete data.

Static Protected Member Functions

static void inline_function_tickler ()

Protected Attributes

unsigned num_rows
unsigned num_cols
int ** data

Private Types

typedef vnl_matrix< int > Base

Detailed Description

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

Definition at line 22 of file vnl_int_matrix.h.


Member Typedef Documentation

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

Type def for norms.

Definition at line 490 of file vnl_matrix.h.

typedef vnl_matrix<int> vnl_int_matrix::Base [private]

Definition at line 24 of file vnl_int_matrix.h.

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

Const iterators.

Definition at line 616 of file vnl_matrix.h.

typedef int vnl_matrix< int >::element_type [inherited]

Definition at line 606 of file vnl_matrix.h.

typedef int * vnl_matrix< int >::iterator [inherited]

Iterators.

Definition at line 609 of file vnl_matrix.h.


Constructor & Destructor Documentation

vnl_int_matrix::vnl_int_matrix ( ) [inline]

Definition at line 27 of file vnl_int_matrix.h.

vnl_int_matrix::vnl_int_matrix ( char const *  filename)

Load from disk.

Definition at line 30 of file vnl_int_matrix.cxx.

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

Definition at line 29 of file vnl_int_matrix.h.

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

Definition at line 30 of file vnl_int_matrix.h.

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 18 of file vnl_int_matrix.cxx.

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

Definition at line 32 of file vnl_int_matrix.h.


Member Function Documentation

abs_t vnl_matrix< int >::absolute_value_max ( ) const [inline, inherited]

Return largest absolute value.

Definition at line 505 of file vnl_matrix.h.

abs_t vnl_matrix< int >::absolute_value_sum ( ) const [inline, inherited]

Return sum of absolute values of elements.

Definition at line 502 of file vnl_matrix.h.

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.

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.

unsigned vnl_matrix< int >::arg_max ( ) const [inline, inherited]

Return location of maximum value of elements.

Definition at line 532 of file vnl_matrix.h.

unsigned vnl_matrix< int >::arg_min ( ) const [inline, inherited]

Return location of minimum value of elements.

Definition at line 529 of file vnl_matrix.h.

abs_t vnl_matrix< int >::array_inf_norm ( ) const [inline, inherited]

Return largest absolute element value.

Definition at line 499 of file vnl_matrix.h.

abs_t vnl_matrix< int >::array_one_norm ( ) const [inline, inherited]

Return sum of absolute values of elements.

Definition at line 493 of file vnl_matrix.h.

abs_t vnl_matrix< int >::array_two_norm ( ) const [inline, inherited]

Return square root of sum of squared absolute element values.

Definition at line 496 of file vnl_matrix.h.

vnl_matrix<int > const& vnl_matrix< int >::as_ref ( ) const [inline, inherited]

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 626 of file vnl_matrix.h.

vnl_matrix<int >& vnl_matrix< int >::as_ref ( ) [inline, inherited]

Return a reference to this.

Definition at line 629 of file vnl_matrix.h.

void vnl_matrix< int >::assert_finite ( ) const [inline, inherited]

abort if matrix contains any INFs or NANs.

This function does or tests nothing if NDEBUG is defined

Definition at line 573 of file vnl_matrix.h.

void vnl_matrix< int >::assert_finite_internal ( ) const [protected, inherited]

Abort if any element of M is inf or nan.

void vnl_matrix< int >::assert_size ( unsigned  r,
unsigned  c 
) const [inline, inherited]

abort if size is not as expected.

This function does or tests nothing if NDEBUG is defined

Definition at line 565 of file vnl_matrix.h.

void vnl_matrix< int >::assert_size_internal ( unsigned  r,
unsigned  c 
) const [protected, inherited]

Abort unless M has the given size.

iterator vnl_matrix< int >::begin ( ) [inline, inherited]

Iterator pointing to start of data.

Definition at line 611 of file vnl_matrix.h.

const_iterator vnl_matrix< int >::begin ( ) const [inline, inherited]

Iterator pointing to start of data.

Definition at line 618 of file vnl_matrix.h.

void vnl_matrix< int >::clear ( ) [inherited]

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

unsigned vnl_matrix< int >::cols ( ) const [inline, inherited]

Return number of columns.

A synonym for columns()

Definition at line 178 of file vnl_matrix.h.

unsigned vnl_matrix< int >::columns ( ) const [inline, inherited]

Return number of columns.

A synonym for cols()

Definition at line 174 of file vnl_matrix.h.

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

Return conjugate transpose.

vnl_matrix& vnl_matrix< int >::copy_in ( int const *  ) [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.

void vnl_matrix< int >::copy_out ( int *  ) 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.

int const* const* vnl_matrix< int >::data_array ( ) const [inline, inherited]

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

2d array, [row][column].

Definition at line 600 of file vnl_matrix.h.

int * * vnl_matrix< int >::data_array ( ) [inline, inherited]

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

2d array, [row][column].

Definition at line 604 of file vnl_matrix.h.

int const* vnl_matrix< int >::data_block ( ) const [inline, inherited]

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

1d array, row-major order.

Definition at line 592 of file vnl_matrix.h.

int * vnl_matrix< int >::data_block ( ) [inline, inherited]

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

1d array, row-major order.

Definition at line 596 of file vnl_matrix.h.

void vnl_matrix< int >::destroy ( ) [protected, inherited]

Delete data.

Frees up the dynamic storage used by matrix.

O(m*n).

bool vnl_matrix< int >::empty ( ) const [inline, inherited]

Return true iff the size is zero.

Definition at line 540 of file vnl_matrix.h.

iterator vnl_matrix< int >::end ( ) [inline, inherited]

Iterator pointing to element beyond end of data.

Definition at line 613 of file vnl_matrix.h.

const_iterator vnl_matrix< int >::end ( ) const [inline, inherited]

Iterator pointing to element beyond end of data.

Definition at line 620 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::extract ( unsigned  r,
unsigned  c,
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.

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]

vnl_matrix& vnl_matrix< int >::fill ( int const &  ) [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:

vnl_matrix& vnl_matrix< int >::fill_diagonal ( int const &  ) [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:

vnl_matrix& 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();
vnl_matrix& 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();
abs_t vnl_matrix< int >::fro_norm ( ) const [inline, inherited]

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

Definition at line 517 of file vnl_matrix.h.

abs_t vnl_matrix< int >::frobenius_norm ( ) const [inline, inherited]

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

Definition at line 514 of file vnl_matrix.h.

int vnl_matrix< int >::get ( unsigned  r,
unsigned  c 
) const [inherited]

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.

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].

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

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

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".

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".

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].

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

Return true if matrix contains NaNs.

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

static void vnl_matrix< int >::inline_function_tickler ( ) [static, protected, inherited]
vnl_matrix& 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.

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.

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

Return true if finite.

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

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

Return true if all elements equal to identity.

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.

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

Return true if all elements equal to zero.

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.

int vnl_matrix< int >::max_value ( ) const [inline, inherited]

Return maximum value of elements.

Definition at line 526 of file vnl_matrix.h.

int vnl_matrix< int >::mean ( ) const [inline, inherited]

Return mean of all matrix elements.

Definition at line 535 of file vnl_matrix.h.

int vnl_matrix< int >::min_value ( ) const [inline, inherited]

Return minimum value of elements.

Definition at line 523 of file vnl_matrix.h.

vnl_matrix& 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.

vnl_matrix& 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.

bool vnl_matrix< int >::operator!= ( vnl_matrix< int > const &  that) const [inline, inherited]

Inequality operator.

Definition at line 640 of file vnl_matrix.h.

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

Access an element for reading or writing.

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

Definition at line 200 of file vnl_matrix.h.

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

Access an element for reading.

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

Definition at line 211 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::operator* ( int const &  v) const [inline, inherited]

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

Definition at line 323 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::operator* ( vnl_matrix< int > const &  rhs) const [inline, inherited]

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

Definition at line 333 of file vnl_matrix.h.

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

Scalar multiplication in situ of lhs matrix by rhs.

vnl_matrix<int >& vnl_matrix< int >::operator*= ( vnl_matrix< int > const &  rhs) [inline, inherited]

Multiply lhs matrix in situ by rhs.

Definition at line 310 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::operator+ ( int const &  v) const [inline, inherited]

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

Definition at line 317 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::operator+ ( vnl_matrix< int > const &  rhs) const [inline, inherited]

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

Definition at line 329 of file vnl_matrix.h.

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

Add rhs to each element of lhs matrix in situ.

vnl_matrix<int >& vnl_matrix< int >::operator+= ( vnl_matrix< int > const &  ) [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.

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

vnl_matrix<int > vnl_matrix< int >::operator- ( int const &  v) const [inline, inherited]

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

Definition at line 320 of file vnl_matrix.h.

vnl_matrix<int > vnl_matrix< int >::operator- ( vnl_matrix< int > const &  rhs) const [inline, inherited]

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

Definition at line 331 of file vnl_matrix.h.

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

Subtract rhs from each element of lhs matrix in situ.

vnl_matrix<int >& vnl_matrix< int >::operator-= ( vnl_matrix< int > const &  ) [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.

vnl_matrix<int > vnl_matrix< int >::operator/ ( int const &  v) const [inline, inherited]

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

Definition at line 326 of file vnl_matrix.h.

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

Scalar division of lhs matrix in situ by rhs.

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

Copies all elements of rhs matrix into lhs matrix.

Complexity $O(\min(r,c))$

Reimplemented from vnl_matrix< int >.

Definition at line 33 of file vnl_int_matrix.h.

bool vnl_matrix< int >::operator== ( vnl_matrix< int > const &  that) const [inline, inherited]

Equality operator.

Definition at line 637 of file vnl_matrix.h.

int * vnl_matrix< int >::operator[] ( unsigned  r) [inline, inherited]

return pointer to given row.

No boundary checking here.

Definition at line 192 of file vnl_matrix.h.

int const* vnl_matrix< int >::operator[] ( unsigned  r) const [inline, inherited]

return pointer to given row.

No boundary checking here.

Definition at line 196 of file vnl_matrix.h.

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.

abs_t vnl_matrix< int >::operator_inf_norm ( ) const [inherited]
abs_t vnl_matrix< int >::operator_one_norm ( ) const [inherited]
void vnl_matrix< int >::print ( vcl_ostream &  os) const [inherited]

Print matrix to os in some hopefully sensible format.

void vnl_matrix< int >::put ( unsigned  r,
unsigned  c,
int const &   
) [inherited]

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.

static vnl_matrix<int > vnl_matrix< int >::read ( vcl_istream &  s) [static, inherited]

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

Read a vnl_matrix from an ascii vcl_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.

bool vnl_matrix< int >::read_ascii ( vcl_istream &  s) [inherited]

Read a vnl_matrix from an ascii vcl_istream.

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

abs_t vnl_matrix< int >::rms ( ) const [inline, inherited]

Return RMS of all elements.

Definition at line 520 of file vnl_matrix.h.

unsigned vnl_matrix< int >::rows ( ) const [inline, inherited]

Return number of rows.

Definition at line 170 of file vnl_matrix.h.

vnl_matrix& 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);
vnl_matrix& 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);
vnl_matrix& vnl_matrix< int >::set ( int const *  d) [inline, inherited]

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

A synonym for copy_in()

Definition at line 274 of file vnl_matrix.h.

vnl_matrix& 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.

vnl_matrix& 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.

vnl_matrix& 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.

vnl_matrix& 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.

vnl_matrix& vnl_matrix< int >::set_diagonal ( vnl_vector< int > const &  ) [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().

vnl_matrix& 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.

vnl_matrix& 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.

vnl_matrix& 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.

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

Set the i-th row.

Set row[row_index] to given vector.

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.

unsigned vnl_matrix< int >::size ( ) const [inline, inherited]

Return number of elements.

This equals rows() * cols()

Definition at line 182 of file vnl_matrix.h.

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

Swap this matrix with that matrix.

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

Return transpose.

Returns new matrix with rows and columns transposed.

O(m*n).

vnl_matrix<int >& vnl_matrix< int >::update ( vnl_matrix< int > const &  ,
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().


Member Data Documentation

int ** vnl_matrix< int >::data [protected, inherited]

Definition at line 657 of file vnl_matrix.h.

unsigned vnl_matrix< int >::num_cols [protected, inherited]

Definition at line 656 of file vnl_matrix.h.

unsigned vnl_matrix< int >::num_rows [protected, inherited]

Definition at line 655 of file vnl_matrix.h.


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