TNT Namespace Reference

Data Structures

class  Array1D
class  Array2D
class  Array3D
class  Fortran_Array1D
class  Fortran_Array2D
class  Fortran_Array3D
class  i_refvec
class  Matrix
class  Sparse_Matrix
class  Sparse_Vector_Element
class  Sparse_Vector
class  Stopwatch
class  Vector

Typedefs

typedef TNT_SUBSCRIPT_TYPE Subscript

Functions

template<class T >
std::ostream & operator<< (std::ostream &s, const Array1D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Array1D< T > &A)
template<class T >
Array1D< T > operator+ (const Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > operator- (const Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > operator* (const Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > operator/ (const Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > & operator+= (Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > & operator-= (Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > & operator*= (Array1D< T > &A, const Array1D< T > &B)
template<class T >
Array1D< T > & operator/= (Array1D< T > &A, const Array1D< T > &B)
template<class T >
std::ostream & operator<< (std::ostream &s, const Array2D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Array2D< T > &A)
template<class T >
Array2D< T > operator+ (const Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > operator- (const Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > operator* (const Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > operator/ (const Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > & operator+= (Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > & operator-= (Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > & operator*= (Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > & operator/= (Array2D< T > &A, const Array2D< T > &B)
template<class T >
Array2D< T > matmult (const Array2D< T > &A, const Array2D< T > &B)
template<class T >
std::ostream & operator<< (std::ostream &s, const Array3D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Array3D< T > &A)
template<class T >
Array3D< T > operator+ (const Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > operator- (const Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > operator* (const Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > operator/ (const Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > & operator+= (Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > & operator-= (Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > & operator*= (Array3D< T > &A, const Array3D< T > &B)
template<class T >
Array3D< T > & operator/= (Array3D< T > &A, const Array3D< T > &B)
template<class T >
std::ostream & operator<< (std::ostream &s, const Fortran_Array1D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Fortran_Array1D< T > &A)
template<class T >
Fortran_Array1D< T > operator+ (const Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > operator- (const Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > operator* (const Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > operator/ (const Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > & operator+= (Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > & operator-= (Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > & operator*= (Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
Fortran_Array1D< T > & operator/= (Fortran_Array1D< T > &A, const Fortran_Array1D< T > &B)
template<class T >
std::ostream & operator<< (std::ostream &s, const Fortran_Array2D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Fortran_Array2D< T > &A)
template<class T >
Fortran_Array2D< T > operator+ (const Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > operator- (const Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > operator* (const Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > operator/ (const Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > & operator+= (Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > & operator-= (Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > & operator*= (Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
Fortran_Array2D< T > & operator/= (Fortran_Array2D< T > &A, const Fortran_Array2D< T > &B)
template<class T >
std::ostream & operator<< (std::ostream &s, const Fortran_Array3D< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Fortran_Array3D< T > &A)
template<class T >
Fortran_Array3D< T > operator+ (const Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > operator- (const Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > operator* (const Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > operator/ (const Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > & operator+= (Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > & operator-= (Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > & operator*= (Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
template<class T >
Fortran_Array3D< T > & operator/= (Fortran_Array3D< T > &A, const Fortran_Array3D< T > &B)
Fortran_Array2D< double > Lapack_LinearSolve (const Fortran_Array2D< double > &A, const Fortran_Array2D< double > &B)
template<class Real >
Real hypot (const Real &a, const Real &b)
template<class T >
std::ostream & operator<< (std::ostream &s, const Matrix< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Matrix< T > &A)
template<class T >
Matrix< T > & mult (Matrix< T > &C, const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > mult (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > operator* (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Vector< T > mult (const Matrix< T > &A, const Vector< T > &b)
template<class T >
Vector< T > operator* (const Matrix< T > &A, const Vector< T > &b)
template<class T >
Matrix< T > mult (const T &s, const Matrix< T > &A)
template<class T >
Matrix< T > mult (const Matrix< T > &A, const T &s)
template<class T >
Matrix< T > mult_eq (const T &s, const Matrix< T > &A)
template<class T >
Matrix< T > mult_eq (const Matrix< T > &A, const T &a)
template<class T >
Matrix< T > transpose_mult (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Vector< T > transpose_mult (const Matrix< T > &A, const Vector< T > &b)
template<class T >
Matrix< T > add (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > operator+ (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > & add_eq (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > operator+= (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > minus (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > operator- (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > mult_element (const Matrix< T > &A, const Matrix< T > &B)
template<class T >
Matrix< T > & mult_element_eq (Matrix< T > &A, const Matrix< T > &B)
template<class T >
double norm (const Matrix< T > &A)
template<class T >
Matrix< T > transpose (const Matrix< T > &A)
template<class T >
Vector< T > upper_triangular_solve (const Matrix< T > &A, const Vector< T > &b)
template<class T >
Vector< T > lower_triangular_solve (const Matrix< T > &A, const Vector< T > &b)
template<class T >
Vector< T > operator* (const Sparse_Matrix< T > &S, const Vector< T > &x)
template<class T >
double norm (const Sparse_Matrix< T > &S)
template<class T >
std::ostream & operator<< (std::ostream &s, const Sparse_Matrix< T > &A)
template<class T >
dot_product (const Sparse_Vector< T > &s, const Vector< T > &x)
template<class T >
dot_product (const Vector< T > &x, const Sparse_Vector< T > &s)
template<class T >
operator* (const Vector< T > &x, const Sparse_Vector< T > &s)
template<class T >
operator* (const Sparse_Vector< T > &s, const Vector< T > &x)
template<class T >
double norm (const Sparse_Vector< T > &s)
template<class T >
std::ostream & operator<< (std::ostream &s, const Sparse_Vector< T > &A)
template<class T >
std::ostream & operator<< (std::ostream &s, const Vector< T > &A)
template<class T >
std::istream & operator>> (std::istream &s, Vector< T > &A)
template<class T >
Vector< T > operator+ (const Vector< T > &A, const Vector< T > &B)
template<class T >
Vector< T > operator+= (Vector< T > &A, const Vector< T > &B)
template<class T >
Vector< T > operator- (const Vector< T > &A, const Vector< T > &B)
template<class T >
Vector< T > operator-= (Vector< T > &A, const Vector< T > &B)
template<class T >
Vector< T > elementwise_mult (const Vector< T > &A, const Vector< T > &B)
template<class T >
double norm (const Vector< T > &A)
template<class T >
dot_prod (const Vector< T > &A, const Vector< T > &B)
template<class T >
dot_product (const Vector< T > &A, const Vector< T > &B)
template<class T >
operator* (const Vector< T > &A, const Vector< T > &B)
template<class T >
Vector< T > operator* (const T &a, const Vector< T > &A)
template<class T >
Vector< T > operator* (const Vector< T > &A, const T &a)

Detailed Description

This file is an exmaple of how one integrates TNT arrays with external libraries.

C-Lapack is a translation of the LAPACK Fortran code into C. This package contains methods for solving linear systems of equations and eigenvalue problems.

Lapack_LinearSolve() calls one of the C-Lapack drivers to solve the equation AX = B, where A and B are given. The function returns X as the solution.

To compile and link this file, you NEED the C-Lapack library installed. See http://www.netlib.org/clapack/ for details. In particular, your link needs to include LAPACK library, as well as the BLAS library, TMGLIB and libF77.a library of F2C.


Function Documentation

template<class T >
Matrix<T> TNT::add ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix addition: compute A + B

Parameters:
A matrix of size M x N.
B matrix of size M x N.
the sum A+B.
template<class T >
Matrix<T>& TNT::add_eq ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix addition, in place : compute A = A + B.

Parameters:
A matrix of size M x N.
B matrix of size M x N.
the sum A+B.
template<class Real >
Real TNT::hypot ( const Real &  a,
const Real &  b 
) [inline]
Returns:
hypotenuse of real (non-complex) scalars a and b by avoiding underflow/overflow using (a * sqrt( 1 + (b/a) * (b/a))), rather than sqrt(a*a + b*b).
template<class T >
Vector<T> TNT::lower_triangular_solve ( const Matrix< T > &  A,
const Vector< T > &  b 
) [inline]

Solve the triangular system A_L *x=b, where A_L is the lower triangular

portion (including the diagonal) of A.

Parameters:
A a square matrix of size N x N.
b the right-hand-side (solution vector) of size N.
Returns:
x, such that A_u * x = b.
template<class T >
Array2D<T> TNT::matmult ( const Array2D< T > &  A,
const Array2D< T > &  B 
) [inline]

Matrix Multiply: compute C = A*B, where C[i][j] is the dot-product of row i of A and column j of B.

Parameters:
A an (m x n) array
B an (n x k) array
Returns:
the (m x k) array A*B, or a null array (0x0) if the matrices are non-conformant (i.e. the number of columns of A are different than the number of rows of B.)
template<class T >
Matrix<T> TNT::minus ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix subtraction : compute A - B.

Parameters:
A matrix of size M x N.
B matrix of size M x N.
Returns:
the result A-B.
template<class T >
Matrix<T> TNT::mult ( const Matrix< T > &  A,
const T &  s 
) [inline]

Matrix scaling: multiply each element of A by scalar s.

Same as mult(A,s), as this is a commutative operation.

NOTE: this creates a new copy of A. To scale "in place",

use *= or mult_eq().

Parameters:
A matrix: to be scaled.
s scalar: multiplier.
Returns:
s*A, a new matrix with same size of A.
template<class T >
Matrix<T> TNT::mult ( const T &  s,
const Matrix< T > &  A 
) [inline]

Matrix scaling: multiply each element of A by scalar s.

NOTE: this creates a new copy of A. To scale "in place",

use *= or mult_eq().

Parameters:
A matrix: to be scaled.
s scalar: multiplier.
Returns:
s*A, a new matrix with same size of A.
template<class T >
Vector<T> TNT::mult ( const Matrix< T > &  A,
const Vector< T > &  b 
) [inline]

Matrix/vector multiplication: compute A * b.

Parameters:
A matrix: left side operand (number of columns of A, must match

the number of elements in b.)

Parameters:
b vector: right side operand.
Returns:
A*b (a new vector of size M.)
template<class T >
Matrix<T> TNT::mult ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix/matrix multiplication: compute A * B.

Parameters:
A matrix: left side operand (size M x N).
B matrix: right side operand (size N x K).
Returns:
A*B (a new matirx of size M x K).
template<class T >
Matrix<T>& TNT::mult ( Matrix< T > &  C,
const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix-Matrix multiplication: C = A * B.

This is an optimizied (trinary) version of matrix multiply, where

the destination matrix has already been allocated.

Parameters:
A matrix of size M x N.
B matrix of size N x K.
C the result A*B, of size M x K.
Returns:
a reference to C, after multiplication.
template<class T >
Matrix<T> TNT::mult_element ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix element-by-elment multiplication: for each (i,j)

compute A(i,j) * B(i,j).

Parameters:
A matrix of size M x N.
B matrix of size M x N.
Returns:
new matrix, where each (i,j) is A(i,j) * B(i,j);
template<class T >
Matrix<T>& TNT::mult_element_eq ( Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix element-by-elment multiplication, in place: for each (i,j)

compute A(i,j) = A(i,j) * B(i,j).

Parameters:
A matrix of size M x N.
B matrix of size M x N.
Returns:
the resultant A, where A(i,j) *= B(i,j);
template<class T >
Matrix<T> TNT::mult_eq ( const T &  s,
const Matrix< T > &  A 
) [inline]

Matrix scale in-place, i.e. compute A *= s, where each element

of A is multiplied (scaled) by the value s.

NOTE: this creates a new copy of A. To scale "in place",

use *= or mult_eq().

Parameters:
A matrix: to be scaled.
s scalar: multiplier.
Returns:
A, after scaling.
template<class T >
double TNT::norm ( const Matrix< T > &  A  )  [inline]

Compute Frobenius norm of matrix. This is the

square root of the sum of squares of each matrix entry, i.e.

			$$ \sqrt{ \sum_{i=1}{N} \sum_{j=1}{N} A_{i,j}^{2} } $$.
	

.

Parameters:
A the matrix to compute its Frobeinus norm.
Returns:
the Frobenius norm of A.
template<class T >
Vector<T> TNT::operator* ( const Matrix< T > &  A,
const Vector< T > &  b 
) [inline]

Matrix/vector multiplication: compute A * b.

Parameters:
A matrix: left side operand (number of columns of A, must match

the number of elements in b.)

Parameters:
b vector: right side operand.
Returns:
A*b (a new vector of size M.)
template<class T >
Matrix<T> TNT::operator* ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix/matrix multiplication: compute A * B.

Parameters:
A matrix: left side operand (size M x N).
B matrix: right side operand (size N x K).
Returns:
A*B (a new matirx of size M x K).
template<class T >
Matrix<T> TNT::operator+ ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix addition: compute A + B.

NOTE: this is shorthand notation for add(A,B).

Parameters:
A matrix of size M x N.
B matrix of size M x N.
the sum A+B.
template<class T >
Matrix<T> TNT::operator+= ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix addition, in place: compute A = A + B.

NOTE: this is shorthand notation for add_eq(A,B).

Parameters:
A matrix of size M x N.
B matrix of size M x N.
Returns:
the sum A+B.
template<class T >
Matrix<T> TNT::operator- ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix subtraction : compute A - B.

This is shorthand notation for minus(A,B).

Parameters:
A matrix of size M x N.
B matrix of size M x N.
Returns:
the result A-B.
template<class T >
std::ostream& TNT::operator<< ( std::ostream &  s,
const Fortran_Array1D< T > &  A 
) [inline]

Write an array to a character outstream. Output format is one that can be read back in via the in-stream operator: one integer denoting the array dimension (n), followed by n elements, one per line.

template<class T >
std::istream& TNT::operator>> ( std::istream &  s,
Fortran_Array1D< T > &  A 
) [inline]

Read an array from a character stream. Input format is one integer, denoting the dimension (n), followed by n whitespace-separated elments. Newlines are ignored

Note: the array being read into references new memory storage. If the intent is to fill an existing conformant array, use cin >> B; A.inject(B) ); instead or read the elements in one-a-time by hand.

Parameters:
s the charater to read from (typically std::in)
A the array to read into.
template<class T >
Matrix<T> TNT::transpose ( const Matrix< T > &  A  )  [inline]

Matrix tranpose: return a new matrix B, where B(i,j)

is A(j,i).

Parameters:
A matrix MxN
Returns:
new matrix of size N x M, where each (i,j) is

A(j,i).

template<class T >
Vector<T> TNT::transpose_mult ( const Matrix< T > &  A,
const Vector< T > &  b 
) [inline]

Matrix-Vector tranpose multiplication, i.e. compute tranpose(A)*b.

NOTE: this is more efficient than computing the tranpose(A) explicitly,

and then multiplying, as the tranpose of A is not explicitly constructed.

Parameters:
A Matrix: size M x N.
b Vector: size M.
Returns:
a new vector of size N.
template<class T >
Matrix<T> TNT::transpose_mult ( const Matrix< T > &  A,
const Matrix< T > &  B 
) [inline]

Matrix-Matrix tranpose multiplication, i.e. compute tranpose(A)*B.

NOTE: this is more efficient than computing the tranpose(A) explicitly,

and then multiplying, as the tranpose of A is never really constructed.

Parameters:
A matrix: size M x N.
B matrix: size M x K.
Returns:
a new matrix of size N x K.
template<class T >
Vector<T> TNT::upper_triangular_solve ( const Matrix< T > &  A,
const Vector< T > &  b 
) [inline]

Solve the triangular system A_u *x=b, where A_u is the upper triangular

portion (including the diagonal) of A.

Parameters:
A a square matrix of size N x N.
b the right-hand-side (solution vector) of size N.
Returns:
x, such that A_u * x = b.
 All Data Structures Namespaces Functions Variables Typedefs

Generated on 22 Sep 2009 for Cali Cam by  doxygen 1.6.1