#include <vnl_matrix.h>
Inheritance diagram for vnl_matrix< T >:

The vnl_matrix<T> class implements two-dimensional arithmetic matrices for a user-specified numeric data type. Using the parameterized types facility of C++, it is possible, for example, for the user to create a matrix of rational numbers by parameterizing the vnl_matrix class over the Rational class. The only requirement for the type is that it supports the basic arithmetic operators.
Note: Unlike the other sequence classes, the vnl_matrix<T> class is fixed-size. It will not grow once the size has been specified to the constructor or changed by the assignment or multiplication operators. The vnl_matrix<T> class is row-based with addresses of rows being cached, and elements accessed as m[row][col].
Note: The matrix can, however, be resized using the set_size(nr,nc) function.
Note: Indexing of the matrix is zero-based, so the top-left element is M(0,0).
Note: Inversion of matrix M, and other operations such as solving systems of linear equations are handled by the matrix decomposition classes in vnl/algo, such as matrix_inverse, svd, qr etc.
Note: Use a vnl_vector<T> with these matrices.
Definition at line 83 of file vnl_matrix.h.
Public Types | |
| typedef vnl_c_vector< T >::abs_t | abs_t |
| Type def for norms. | |
| typedef T | element_type |
| typedef T * | iterator |
| Iterators. | |
| typedef T const * | const_iterator |
| Const iterators. | |
Public Member Functions | |
| vnl_matrix () | |
| Default constructor creates an empty matrix of size 0,0. | |
| vnl_matrix (unsigned r, unsigned c) | |
| Construct a matrix of size r rows by c columns. | |
| vnl_matrix (unsigned r, unsigned c, T const &v0) | |
| Construct a matrix of size r rows by c columns, and all emelemnts equal to v0. | |
| vnl_matrix (unsigned r, unsigned c, vnl_matrix_type t) | |
| Construct a matrix of size r rows by c columns, with a special type. | |
| vnl_matrix (unsigned r, unsigned c, unsigned n, T const values[]) | |
| Construct a matrix of size r rows by c columns, initialised by an automatic array. | |
| vnl_matrix (T const *data_block, unsigned r, unsigned c) | |
| Construct a matrix of size r rows by c columns, initialised by a memory block. | |
| vnl_matrix (vnl_matrix< T > const &) | |
| Copy construct a matrix. | |
| vnl_matrix (vnl_matrix< T > const &, vnl_matrix< T > const &, vnl_tag_add) | |
| vnl_matrix (vnl_matrix< T > const &, vnl_matrix< T > const &, vnl_tag_sub) | |
| vnl_matrix (vnl_matrix< T > const &, T, vnl_tag_mul) | |
| vnl_matrix (vnl_matrix< T > const &, T, vnl_tag_div) | |
| vnl_matrix (vnl_matrix< T > const &, T, vnl_tag_add) | |
| vnl_matrix (vnl_matrix< T > const &, T, vnl_tag_sub) | |
| vnl_matrix (vnl_matrix< T > const &, vnl_matrix< T > const &, vnl_tag_mul) | |
| vnl_matrix (vnl_matrix< T > &that, vnl_tag_grab) | |
| ~vnl_matrix () | |
| Matrix destructor. | |
| 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, T const &) |
| set element with boundary checks if error checking is on. | |
| T | get (unsigned r, unsigned c) const |
| get element with boundary checks if error checking is on. | |
| T * | operator[] (unsigned r) |
| return pointer to given row. | |
| T const * | operator[] (unsigned r) const |
| return pointer to given row. | |
| T & | operator() (unsigned r, unsigned c) |
| Access an element for reading or writing. | |
| T const & | operator() (unsigned r, unsigned c) const |
| Access an element for reading. | |
| void | fill (T const &) |
| Set all elements of matrix to specified value. | |
| void | fill_diagonal (T const &) |
| Set all diagonal elements of matrix to specified value. | |
| void | copy_in (T const *) |
| Fill (laminate) this matrix with the given data. | |
| void | set (T const *d) |
| Fill (laminate) this matrix with the given data. | |
| void | copy_out (T *) const |
| Fill the given array with this matrix. | |
| vnl_matrix< T > & | operator= (T const &v) |
| Set all elements to value v. | |
| vnl_matrix< T > & | operator= (vnl_matrix< T > const &) |
| Copies all elements of rhs matrix into lhs matrix. | |
| vnl_matrix< T > & | operator+= (T value) |
| Add rhs to each element of lhs matrix in situ. | |
| vnl_matrix< T > & | operator-= (T value) |
| Subtract rhs from each element of lhs matrix in situ. | |
| vnl_matrix< T > & | operator *= (T value) |
| Scalar multiplication in situ of lhs matrix by rhs. | |
| vnl_matrix< T > & | operator/= (T value) |
| Scalar division of lhs matrix in situ by rhs. | |
| vnl_matrix< T > & | operator+= (vnl_matrix< T > const &) |
| Add rhs to lhs matrix in situ. | |
| vnl_matrix< T > & | operator-= (vnl_matrix< T > const &) |
| Subtract rhs from lhs matrix in situ. | |
| vnl_matrix< T > & | operator *= (vnl_matrix< T > const &rhs) |
| Multiply lhs matrix in situ by rhs. | |
| vnl_matrix< T > | operator- () const |
| Negate all elements of matrix. | |
| vnl_matrix< T > | operator+ (T const &v) const |
| Add rhs to each element of lhs matrix and return result in new matrix. | |
| vnl_matrix< T > | operator- (T const &v) const |
| Subtract rhs from each element of lhs matrix and return result in new matrix. | |
| vnl_matrix< T > | operator * (T const &v) const |
| Scalar multiplication of lhs matrix by rhs and return result in new matrix. | |
| vnl_matrix< T > | operator/ (T const &v) const |
| Scalar division of lhs matrix by rhs and return result in new matrix. | |
| vnl_matrix< T > | operator+ (vnl_matrix< T > const &rhs) const |
| Matrix add rhs to lhs matrix and return result in new matrix. | |
| vnl_matrix< T > | operator- (vnl_matrix< T > const &rhs) const |
| Matrix subtract rhs from lhs and return result in new matrix. | |
| vnl_matrix< T > | operator * (vnl_matrix< T > const &rhs) const |
| Matrix multiply lhs by rhs matrix and return result in new matrix. | |
| vnl_matrix< T > | apply (T(*f)(T)) const |
| Make a new matrix by applying function to each element. | |
| vnl_matrix< T > | apply (T(*f)(T const &)) const |
| Make a new matrix by applying function to each element. | |
| vnl_matrix< T > | transpose () const |
| Return transpose. | |
| vnl_matrix< T > | conjugate_transpose () const |
| Return conjugate transpose. | |
| vnl_matrix< T > & | update (vnl_matrix< T > const &, unsigned top=0, unsigned left=0) |
| Set values of this matrix to those of M, starting at [top,left]. | |
| void | set_column (unsigned i, T const *v) |
| Set the elements of the i'th column to v[j] (No bounds checking). | |
| void | set_column (unsigned i, T value) |
| Set the elements of the i'th column to value. | |
| void | set_column (unsigned j, vnl_vector< T > const &v) |
| Set j-th column to v. | |
| void | set_columns (unsigned starting_column, vnl_matrix< T > const &M) |
| Set columns to those in M, starting at starting_column. | |
| void | set_row (unsigned i, T const *v) |
| Set the elements of the i'th row to v[j] (No bounds checking). | |
| void | set_row (unsigned i, T value) |
| Set the elements of the i'th row to value. | |
| void | set_row (unsigned i, vnl_vector< T > const &) |
| Set the i-th row. | |
| vnl_matrix< T > | 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). | |
| vnl_vector< T > | get_row (unsigned r) const |
| Get a vector equal to the given row. | |
| vnl_vector< T > | get_column (unsigned c) const |
| Get a vector equal to the given column. | |
| vnl_matrix< T > | get_n_rows (unsigned rowstart, unsigned n) const |
| Get n rows beginning at rowstart. | |
| vnl_matrix< T > | get_n_columns (unsigned colstart, unsigned n) const |
| Get n columns beginning at colstart. | |
| void | set_identity () |
| Set this matrix to an identity matrix. | |
| void | inplace_transpose () |
| Transpose this matrix efficiently. | |
| void | flipud () |
| Reverse order of rows. | |
| void | fliplr () |
| Reverse order of columns. | |
| void | normalize_rows () |
| Normalize each row so it is a unit vector. | |
| void | normalize_columns () |
| Normalize each column so it is a unit vector. | |
| void | scale_row (unsigned row, T value) |
| Scale elements in given row by a factor of T. | |
| void | scale_column (unsigned col, T value) |
| Scale elements in given column by a factor of T. | |
| void | swap (vnl_matrix< T > &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. | |
| T | min_value () const |
| Return minimum value of elements. | |
| T | max_value () const |
| Return maximum value of elements. | |
| T | 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_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) |
| Read a vnl_matrix from an ascii vcl_istream. | |
| T const * | data_block () const |
| Access the contiguous block storing the elements in the matrix row-wise. O(1). | |
| T * | data_block () |
| Access the contiguous block storing the elements in the matrix row-wise. O(1). | |
| T const *const * | data_array () const |
| Access the 2D array, so that elements can be accessed with array[row][col] directly. | |
| T ** | 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. | |
| iterator | end () |
| Iterator pointing to element beyond end of data. | |
| const_iterator | begin () const |
| Iterator pointing to start of data. | |
| const_iterator | end () const |
| Iterator pointing to element beyond end of data. | |
| vnl_matrix< T > const & | as_ref () const |
| Return a reference to this. | |
| vnl_matrix< T > & | as_ref () |
| Return a reference to this. | |
| bool | operator_eq (vnl_matrix< T > const &rhs) const |
| Return true if *this == rhs. | |
| bool | operator== (vnl_matrix< T > const &that) const |
| Equality operator. | |
| bool | operator!= (vnl_matrix< T > 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< T > | 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 |
| Abort unless M has the given size. | |
| void | assert_finite_internal () const |
| Abort if any element of M is inf or nan. | |
| void | destroy () |
| Delete data. | |
Static Protected Member Functions | |
| static void | inline_function_tickler () |
Protected Attributes | |
| unsigned | num_rows |
| unsigned | num_cols |
| T ** | data |
Related Functions | |
| (Note that these are not member functions.) | |
| vnl_matrix< vcl_complex< T > > | vnl_complexify (vnl_matrix< T > const &R) |
| Return complexified version of real matrix R. | |
| vnl_matrix< vcl_complex< T > > | vnl_complexify (vnl_matrix< T > const &R, vnl_matrix< T > const &I) |
| Return complex matrix R+j*I from two real matrices R and I. | |
| T | vnl_det (vnl_matrix_fixed< T, 1, 1 > const &m) |
| Determinant of small size matrices. | |
| T | vnl_det (vnl_matrix_fixed< T, 2, 2 > const &m) |
| Determinant of small size matrices. | |
| T | vnl_det (vnl_matrix_fixed< T, 3, 3 > const &m) |
| Determinant of small size matrices. | |
| T | vnl_det (vnl_matrix_fixed< T, 4, 4 > const &m) |
| Determinant of small size matrices. | |
| vnl_matrix< T > | operator * (vnl_matrix< T > const &A, vnl_diag_matrix< T > const &D) |
| Multiply a vnl_matrix by a vnl_diag_matrix. Just scales the columns - mn flops. | |
| vnl_matrix< T > | operator * (vnl_diag_matrix< T > const &D, vnl_matrix< T > const &A) |
| Multiply a vnl_diag_matrix by a vnl_matrix. Just scales the rows - mn flops. | |
| vnl_matrix< T > | operator+ (vnl_matrix< T > const &A, vnl_diag_matrix< T > const &D) |
| Add a vnl_diag_matrix to a vnl_matrix. n adds, mn copies. | |
| vnl_matrix< T > | operator+ (vnl_diag_matrix< T > const &D, vnl_matrix< T > const &A) |
| Add a vnl_matrix to a vnl_diag_matrix. n adds, mn copies. | |
| vnl_matrix< T > | operator- (vnl_matrix< T > const &A, vnl_diag_matrix< T > const &D) |
| Subtract a vnl_diag_matrix from a vnl_matrix. n adds, mn copies. | |
| vnl_matrix< T > | operator- (vnl_diag_matrix< T > const &D, vnl_matrix< T > const &A) |
| Subtract a vnl_matrix from a vnl_diag_matrix. n adds, mn copies. | |
| vnl_matrix< T > | vnl_imag (vnl_matrix< vcl_complex< T > > const &C) |
| Matrix of imaginary parts of vnl_matrix<vcl_complex<T> >. | |
| vnl_matrix< T > | operator * (T const &value, vnl_matrix< T > const &m) |
| vnl_matrix< T > | operator+ (T const &value, vnl_matrix< T > const &m) |
| void | swap (vnl_matrix< T > &A, vnl_matrix< T > &B) |
| Swap two matrices. | |
| bool | operator< (vnl_matrix< T > const &lhs, vnl_matrix< T > const &rhs) |
| Define a complete ordering on vnl_matrix. | |
| unsigned int | vnl_rank (vnl_matrix< T > const &mat, vnl_rank_type=vnl_rank_both) |
| Returns the rank of a matrix. | |
| vnl_matrix< T > | vnl_rank_row_reduce (vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all) |
| Row reduce a matrix. | |
| vnl_matrix< T > | vnl_rank_column_reduce (vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all) |
| Column reduce a matrix. | |
| vnl_matrix< T > | vnl_rank_row_column_reduce (vnl_matrix< T > const &mat, vnl_rank_pivot_type=vnl_rank_pivot_all) |
| Row and column reduce a matrix. | |
| vnl_matrix< T > | vnl_real (vnl_matrix< vcl_complex< T > > const &C) |
| Matrix of real parts of vnl_matrix<vcl_complex<T> >. | |
| 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||. | |
| T | vnl_trace (vnl_matrix< T > const &M) |
| Calculate trace of a matrix. | |
| vnl_vector< T > | operator * (vnl_matrix< T > const &m, vnl_vector< T > const &v) |
| multiply matrix and (column) vector. O(m*n). | |
|
|||||
|
Type def for norms.
Definition at line 361 of file vnl_matrix.h. |
|
|||||
|
Const iterators.
Definition at line 478 of file vnl_matrix.h. |
|
|||||
|
Definition at line 468 of file vnl_matrix.h. |
|
|||||
|
Iterators.
Definition at line 471 of file vnl_matrix.h. |
|
|||||||||
|
Default constructor creates an empty matrix of size 0,0.
Definition at line 87 of file vnl_matrix.h. |
|
||||||||||||||||
|
Construct a matrix of size r rows by c columns.
Contents are unspecified. Complexity Definition at line 141 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Construct a matrix of size r rows by c columns, and all emelemnts equal to v0.
Complexity Definition at line 150 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Construct a matrix of size r rows by c columns, with a special type.
Contents are specified by t Complexity Definition at line 161 of file vnl_matrix.txx. |
|
||||||||||||||||||||||||
|
Construct a matrix of size r rows by c columns, initialised by an automatic array.
The first n elements, are initialised row-wise, to values. Complexity Definition at line 177 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Construct a matrix of size r rows by c columns, initialised by a memory block.
The values are initialise row wise from the data. Complexity Definition at line 193 of file vnl_matrix.txx. |
|
||||||||||
|
Copy construct a matrix.
Complexity Definition at line 208 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 229 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 249 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 269 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 283 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 297 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 311 of file vnl_matrix.txx. |
|
||||||||||||||||||||
|
Definition at line 325 of file vnl_matrix.txx. |
|
||||||||||||||||
|
Definition at line 133 of file vnl_matrix.h. |
|
|||||||||
|
Matrix destructor.
Definition at line 352 of file vnl_matrix.txx. |
|
|||||||||
|
Return largest absolute value.
Definition at line 376 of file vnl_matrix.h. |
|
|||||||||
|
Return sum of absolute values of elements.
Definition at line 373 of file vnl_matrix.h. |
|
||||||||||
|
Make a new matrix by applying function to each element.
Definition at line 678 of file vnl_matrix.txx. |
|
||||||||||
|
Make a new matrix by applying function to each element.
Definition at line 687 of file vnl_matrix.txx. |
|
|||||||||
|
Return largest absolute element value.
Definition at line 370 of file vnl_matrix.h. |
|
|||||||||
|
Return sum of absolute values of elements.
Definition at line 364 of file vnl_matrix.h. |
|
|||||||||
|
Return square root of sum of squared absolute element values.
Definition at line 367 of file vnl_matrix.h. |
|
|||||||||
|
Return a reference to this.
Definition at line 491 of file vnl_matrix.h. |
|
|||||||||
|
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 488 of file vnl_matrix.h. |
|
|||||||||
|
abort if matrix contains any INFs or NANs. This function does or tests nothing if NDEBUG is defined Definition at line 435 of file vnl_matrix.h. |
|
|||||||||
|
Abort if any element of M is inf or nan.
Definition at line 1188 of file vnl_matrix.txx. |
|
||||||||||||||||
|
abort if size is not as expected. This function does or tests nothing if NDEBUG is defined Definition at line 427 of file vnl_matrix.h. |
|
||||||||||||||||
|
Abort unless M has the given size.
Definition at line 1214 of file vnl_matrix.txx. |
|
|||||||||
|
Iterator pointing to start of data.
Definition at line 480 of file vnl_matrix.h. |
|
|||||||||
|
Iterator pointing to start of data.
Definition at line 473 of file vnl_matrix.h. |
|
|||||||||
|
Make the matrix as if it had been default-constructed.
Definition at line 372 of file vnl_matrix.txx. |
|
|||||||||
|
Return number of columns. A synonym for columns() Definition at line 153 of file vnl_matrix.h. |
|
|||||||||
|
Return number of columns. A synonym for cols() Definition at line 149 of file vnl_matrix.h. |
|
|||||||||
|
Return conjugate transpose.
Definition at line 712 of file vnl_matrix.txx. |
|
||||||||||
|
Fill (laminate) this matrix with the given data. We assume that p points to a contiguous rows*cols array, stored rowwise. Definition at line 848 of file vnl_matrix.txx. |
|
||||||||||
|
Fill the given array with this matrix. We assume that p points to a contiguous rows*cols array, stored rowwise. No bounds checking on the array. Definition at line 859 of file vnl_matrix.txx. |
|
|||||||||
|
Access the 2D array, so that elements can be accessed with array[row][col] directly. 2d array, [row][column]. Definition at line 466 of file vnl_matrix.h. |
|
|||||||||
|
Access the 2D array, so that elements can be accessed with array[row][col] directly. 2d array, [row][column]. Definition at line 462 of file vnl_matrix.h. |
|
|||||||||
|
Access the contiguous block storing the elements in the matrix row-wise. O(1). 1d array, row-major order. Definition at line 458 of file vnl_matrix.h. |
| |||||