Copyright (C) 1991 Texas Instruments Incorporated. More...
#include <cstdio>#include <cstdlib>#include <cctype>#include <iostream>#include <vector>#include <algorithm>#include "vnl_matrix.h"#include <cassert>#include <vnl/vnl_math.h>#include <vnl/vnl_vector.h>#include <vnl/vnl_c_vector.h>#include <vnl/vnl_numeric_traits.h>Go to the source code of this file.
Macros | |
| #define | vnl_matrix_construct_hack() |
| #define | vnl_matrix_alloc_blah() |
| #define | vnl_matrix_free_blah |
| #define | VNL_MATRIX_INSTANTIATE(T) |
Functions | |
| template<class T > | |
| std::ostream & | operator<< (std::ostream &os, vnl_matrix< T > const &m) |
| Prints the 2D array of elements of a matrix out to a stream. More... | |
| template<class T > | |
| std::istream & | operator>> (std::istream &s, vnl_matrix< T > &M) |
| Read a vnl_matrix from an ascii std::istream. More... | |
| template<class T > | |
| vnl_matrix< T > | operator- (T const &value, vnl_matrix< T > const &m) |
| template<class T > | |
| T | dot_product (vnl_matrix< T > const &m1, vnl_matrix< T > const &m2) |
| Returns the dot product of the two matrices. O(m*n). More... | |
| template<class T > | |
| T | inner_product (vnl_matrix< T > const &m1, vnl_matrix< T > const &m2) |
| Hermitian inner product. More... | |
| template<class T > | |
| T | cos_angle (vnl_matrix< T > const &a, vnl_matrix< T > const &b) |
| template<class T > | |
| vnl_matrix< T > | element_product (vnl_matrix< T > const &m1, vnl_matrix< T > const &m2) |
| Returns new matrix whose elements are the products m1[ij]*m2[ij]. More... | |
| template<class T > | |
| vnl_matrix< T > | element_quotient (vnl_matrix< T > const &m1, vnl_matrix< T > const &m2) |
| Returns new matrix whose elements are the quotients m1[ij]/m2[ij]. More... | |
| template<class doublereal > | |
| int | vnl_inplace_transpose (doublereal *a, unsigned m, unsigned n, char *move, unsigned iwrk) |
Copyright (C) 1991 Texas Instruments Incorporated.
Copyright (C) 1992 General Electric Company.
Permission is granted to any individual or institution to use, copy, modify, and distribute this software, provided that this complete copyright and permission notice is maintained, intact, in all copies and supporting documentation.
Texas Instruments Incorporated, General Electric Company, provides this software "as is" without express or implied warranty.
Created: MBN Apr 21, 1989 Initial design and implementation Updated: MBN Jun 22, 1989 Removed non-destructive methods Updated: LGO Aug 09, 1989 Inherit from Generic Updated: MBN Aug 20, 1989 Changed template usage to reflect new syntax Updated: MBN Sep 11, 1989 Added conditional exception handling and base class Updated: LGO Oct 05, 1989 Don't re-allocate data in operator= when same size Updated: LGO Oct 19, 1989 Add extra parameter to varargs constructor Updated: MBN Oct 19, 1989 Added optional argument to set_compare method Updated: LGO Dec 08, 1989 Allocate column data in one chunk Updated: LGO Dec 08, 1989 Clean-up get and put, add const everywhere. Updated: LGO Dec 19, 1989 Remove the map and reduce methods Updated: MBN Feb 22, 1990 Changed size arguments from int to unsigned int Updated: MJF Jun 30, 1990 Added base class name to constructor initializer Updated: VDN Feb 21, 1992 New lite version Updated: VDN May 05, 1992 Use envelope to avoid unnecessary copying Updated: VDN Sep 30, 1992 Matrix inversion with singular value decomposition Updated: AWF Aug 21, 1996 set_identity, normalize_rows, scale_row. Updated: AWF Sep 30, 1996 set_row/column methods. Const-correct data_block(). Updated: AWF 14 Feb 1997 get_n_rows, get_n_columns. Updated: PVR 20 Mar 1997 get_row, get_column.
The parameterized vnl_matrix<T> class implements two dimensional arithmetic matrices of a user specified type. The only constraint placed on the type is that it must overload the following operators: +, -, *, and /. Thus, it will be possible to have a vnl_matrix over std::complex<T>. The vnl_matrix<T> class is static in size, that is once a vnl_matrix<T> of a particular size has been created, there is no dynamic growth method available. You can resize the matrix, with the loss of any existing data using set_size().
Each matrix contains a protected data section that has a T** slot that points to the physical memory allocated for the two dimensional array. In addition, two integers specify the number of rows and columns for the matrix. These values are provided in the constructors. A single protected slot contains a pointer to a compare function to be used in equality operations. The default function used is the built-in == operator.
Four different constructors are provided. The first constructor takes two integer arguments specifying the row and column size. Enough memory is allocated to hold row*column elements of type Type. The second constructor takes the same two first arguments, but also accepts an additional third argument that is a reference to an object of the appropriate type whose value is used as an initial fill value. The third constructor is similar to the third, except that it accepts a variable number of initialization values for the Matrix. If there are fewer values than elements, the rest are set to zero. Finally, the last constructor takes a single argument consisting of a reference to a Matrix and duplicates its size and element values.
Methods are provided for destructive scalar and Matrix addition, multiplication, check for equality and inequality, fill, reduce, and access and set individual elements. Finally, both the input and output operators are overloaded to allow for formatted input and output of matrix elements.
Good matrix inversion is needed. We choose singular value decomposition, since it is general and works great for nearly singular cases. Singular value decomposition is preferred to LU decomposition, since the accuracy of the pivots is independent from the left->right top->down elimination. LU decomposition also does not give eigenvectors and eigenvalues when the matrix is symmetric.
Several different constructors are provided. See .h file for brief descriptions.
Definition in file vnl_matrix.hxx.
| #define vnl_matrix_alloc_blah | ( | ) |
Definition at line 102 of file vnl_matrix.hxx.
| #define vnl_matrix_construct_hack | ( | ) |
Definition at line 99 of file vnl_matrix.hxx.
| #define vnl_matrix_free_blah |
Definition at line 120 of file vnl_matrix.hxx.
| #define VNL_MATRIX_INSTANTIATE | ( | T | ) |
Definition at line 1647 of file vnl_matrix.hxx.
| T cos_angle | ( | vnl_matrix< T > const & | a, |
| vnl_matrix< T > const & | b | ||
| ) |
Definition at line 785 of file vnl_matrix.hxx.
| T dot_product | ( | vnl_matrix< T > const & | m1, |
| vnl_matrix< T > const & | m2 | ||
| ) |
Returns the dot product of the two matrices. O(m*n).
This is the sum of all pairwise products of the elements m1[i,j]*m2[i,j].
Definition at line 756 of file vnl_matrix.hxx.
| vnl_matrix<T> element_product | ( | vnl_matrix< T > const & | m1, |
| vnl_matrix< T > const & | m2 | ||
| ) |
Returns new matrix whose elements are the products m1[ij]*m2[ij].
O(m*n).
Definition at line 800 of file vnl_matrix.hxx.
| vnl_matrix<T> element_quotient | ( | vnl_matrix< T > const & | m1, |
| vnl_matrix< T > const & | m2 | ||
| ) |
Returns new matrix whose elements are the quotients m1[ij]/m2[ij].
O(m*n).
Definition at line 819 of file vnl_matrix.hxx.
| T inner_product | ( | vnl_matrix< T > const & | m1, |
| vnl_matrix< T > const & | m2 | ||
| ) |
| vnl_matrix<T> operator- | ( | T const & | value, |
| vnl_matrix< T > const & | m | ||
| ) |
Definition at line 611 of file vnl_matrix.hxx.
| std::ostream& operator<< | ( | std::ostream & | os, |
| vnl_matrix< T > const & | m | ||
| ) |
Prints the 2D array of elements of a matrix out to a stream.
O(m*n).
Definition at line 513 of file vnl_matrix.hxx.
| std::istream& operator>> | ( | std::istream & | s, |
| vnl_matrix< T > & | M | ||
| ) |
Read a vnl_matrix from an ascii std::istream.
Automatically determines file size if the input matrix has zero size.
Definition at line 526 of file vnl_matrix.hxx.
| int vnl_inplace_transpose | ( | doublereal * | a, |
| unsigned | m, | ||
| unsigned | n, | ||
| char * | move, | ||
| unsigned | iwrk | ||
| ) |
Definition at line 1500 of file vnl_matrix.hxx.
1.8.15