Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

APPSPACK::Matrix Class Reference

#include <APPSPACK_Matrix.hpp>

Collaboration diagram for APPSPACK::Matrix:

Collaboration graph
[legend]
List of all members.

Detailed Description

Stores a matrix A. All indices begin at zero.

Vectorized storage

When interfacing with BLAS and LAPACK routines it is necessary to first write matrix elements to a vector of columns, and/or a vector of rows. To enhance computational efficiency when such a copy is made, it will be automatically be stored. If A is written to a vector by columns, a copy is stored in fmatvec and fmatvecSet is set to true. Similarly, if A is written to vector by rows, a copy is stored in fmatvecT and fmatvecTSet is set to true. To ensure that the vectorized forms of A are kept current, both fmatvecSet and fmatvecTSet are set to false upon instantiation and whenever a non-const method is called.

Warning:
To ensure that vectorized storage of A is kept current, it is crucial that every non-const method call method Matrix::matrixChanged() which resets fmatvecSet and fmatvecTSet to false.
See also:
Matrix::copyToFortranVector();

Definition at line 69 of file APPSPACK_Matrix.hpp.

Public Types

enum  TransposeType { Transpose, NoTranspose }
 Indicator for transpose operations. More...

Public Member Functions

 Matrix ()
 Constructor. Creates an empty matrix.
 Matrix (const Matrix &B, TransposeType ttype=NoTranspose)
 Copy constructor.
 Matrix (const Matrix &B, const Vector &s, TransposeType ttype=NoTranspose)
 Copy constructor with scaling.
 Matrix (double **Aptr, int nrows, int ncols)
 Resizes A to be nrows by ncols. Sets A(i,j) = Aptr[i][j].
 ~Matrix ()
 Destructor.
Accessors
bool empty () const
 Returns true if A is empty, i.e., the number of rows is zero.
int getNrows () const
 Returns number of rows in A.
int getNcols () const
 Returns number of columns in A.
const VectorgetRow (int i) const
 Return ith row of A.
Modifiers
void getRowPointers (vector< double * > &Aptr)
 On exit Aptr[i] points to row i of A.
void clear ()
 Empty the matrix A.
void addRow (const Vector &r)
 Append a copy of r to the bottom of A.
void deleteRow (int i)
 Deletes the ith row of A.
void addRow (const Vector &r, double alpha)
 Append alpha * r (i.e., a scaled copy of r) to the bottom of A.
void addMatrix (const Matrix &B)
 Append copies of the rows of matrix B to the bottom of A.
void addMatrix (const Matrix &B, double alpha)
 Append the matrix alpha * B (i.e., a scaled copy of B) to the bottom of A.
void addMatrix (const Matrix &B, const Vector &s)
 Append matrix B scaled columnwise to the bottom of A.
void addUniqueRows (const Matrix &B, double epsilon)
 Selectivly appends the rows which are unique to B to the bottom of A.
void operator= (const Matrix &B)
 Copy matrix (A = B).
void transpose (const Matrix &B)
 Copy transposed matrix (A = B').
void scale (const Matrix &B, const Vector &s)
 Copy and scale matrix.
void scale (const Vector &s)
 Scale matrix.
void setToIdentity (int n)
 Sets A = I, an n by n identity matrix.
void normalize ()
 Normalizes the rows of A.
Calculations involving A
void multVec (const Vector &x, Vector &y, TransposeType ttype=NoTranspose) const
 Compute y = Ax (or y = A'x if ttype = Transpose).
void svd (Matrix &U, Vector &s, Matrix &VT) const
 Compute the singular value decomposition (SVD) of A.
void multMat (const Matrix &B, TransposeType ttype=NoTranspose)
 On exit A = A*B if ttype = NoTranspose, and A = A*B' otherwise.
void multMat (const Matrix &B, Matrix &C, TransposeType ttype=NoTranspose) const
 On exit C = A*B if ttype = NoTranspose, and C = A*B' otherwise.
void nullSpace (Matrix &ZT, double tol) const
 On exit the rows of ZT form an orthonormal basis for null(A).
bool getRighInvAndNullBasis (Matrix &RT, Matrix &NT, double tol) const
 Computes right inverse and null space basis matrix for A (if possible).
void pruneDependentRows (Vector &b, double epsilon)
 Deletes dependent rows of A and corresponding entries in b. On exit, Ax = b forms a consistent system.
void constrainedLSQR (Vector &x, const Vector &b) const
 Solve a constrained least-squares problem for the case when A has full row rank.
Printing help
ostream & leftshift (ostream &stream) const
 Print object to the given stream

Private Member Functions

void matrixChanged ()
 Sets fmatvecSet and fmatvecTSet to false.
const VectorgetMatrixVector (TransposeType ttype=NoTranspose) const
 Private member variables fmatvec and fmatvecTSet should never be access directly. Instead method getMatrixVector() should be called. If ttype equals NoTranspose, A is returns as a single vector stored column-wise. If ttype equals Transpose, A is returns as a single vector stored row-wise.
void copyToFortranVector (Vector &Avec, TransposeType ttype=NoTranspose) const
 Converts A to a Fortran-style vector.
void copyFromFortranVector (const Vector &Avec, int nrows, int ncols, TransposeType ttype=NoTranspose)
 Unpack A from a Fortran-style vector.
void resize (int m, int n)
 Resize A to have m rows and n columns.
void copySubMatrix (int istart, int iextent, const Matrix &B)
 Sets A equal to the specified block-row submatrix of B.
void multMatWithBlas (const APPSPACK::Matrix &Bin, APPSPACK::Matrix &C, TransposeType ttype) const
 Performs a matrix multiply using Blas 3 routine DGEMM_F77().
void multMatWithoutBlas (const APPSPACK::Matrix &Bin, APPSPACK::Matrix &C, TransposeType ttype) const
 Performs a matrix multiply by hand without blas subroutines.
void multVecWithBlas (const Vector &x, Vector &y, TransposeType ttype=NoTranspose) const
 Performs a matrix-vector multiply with Blas subroutine DGEMV_F77().
void multVecWithoutBlas (const Vector &x, Vector &y, TransposeType ttype=NoTranspose) const
 Performs a matrix-vector multiply by hand without blas subroutines.

Private Attributes

vector< Vectormatrix
 The matrix A.
Vectorized matrix storage.
Vector fmatvec
bool fmatvecSet
Vector fmatvecT
bool fmatvecTSet


Member Enumeration Documentation

enum APPSPACK::Matrix::TransposeType
 

Indicator for transpose operations.

Enumeration values:
Transpose  Transpose the matrix.
NoTranspose  Do not transpose the matrix.

Definition at line 74 of file APPSPACK_Matrix.hpp.


Constructor & Destructor Documentation

APPSPACK::Matrix::Matrix  ) 
 

Constructor. Creates an empty matrix.

Definition at line 43 of file APPSPACK_Matrix.cpp.

APPSPACK::Matrix::Matrix const Matrix B,
TransposeType  ttype = NoTranspose
 

Copy constructor.

Sets A = B (or A = B' if ttype = Transpose).

Definition at line 49 of file APPSPACK_Matrix.cpp.

References operator=(), and transpose().

APPSPACK::Matrix::Matrix const Matrix B,
const Vector s,
TransposeType  ttype = NoTranspose
 

Copy constructor with scaling.

Copies B into A and scales column j by s[j]. In other words,

\[ A_{ij} = s_j B_{ij}. \]

If ttype = Transpose, the

\[ A_{ij} = s_j B_{ji}. \]

Definition at line 59 of file APPSPACK_Matrix.cpp.

References operator=(), scale(), and transpose().

APPSPACK::Matrix::Matrix double **  Aptr,
int  nrows,
int  ncols
 

Resizes A to be nrows by ncols. Sets A(i,j) = Aptr[i][j].

Definition at line 70 of file APPSPACK_Matrix.cpp.

References matrix, and resize().

APPSPACK::Matrix::~Matrix  ) 
 

Destructor.

Definition at line 80 of file APPSPACK_Matrix.cpp.


Member Function Documentation

bool APPSPACK::Matrix::empty  )  const
 

Returns true if A is empty, i.e., the number of rows is zero.

Definition at line 84 of file APPSPACK_Matrix.cpp.

References matrix.

Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildTangentCone(), APPSPACK::Directions::buildWithLapack(), APPSPACK::Directions::computeNewDirections(), constrainedLSQR(), APPSPACK::Directions::empty(), APPSPACK::Constraints::Linear::errorCheck(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Directions::generateForLinear(), APPSPACK::Constraints::Linear::isBoundsOnly(), APPSPACK::Constraints::Linear::maxStep(), APPSPACK::Constraints::Linear::print(), APPSPACK::Constraints::Linear::setupMatrix(), and APPSPACK::Constraints::Linear::setupScaledSystem().

int APPSPACK::Matrix::getNrows  )  const
 

Returns number of rows in A.

Definition at line 89 of file APPSPACK_Matrix.cpp.

References matrix.

Referenced by addMatrix(), addUniqueRows(), APPSPACK::Directions::buildWithCddlib(), constrainedLSQR(), copySubMatrix(), copyToFortranVector(), deleteRow(), APPSPACK::Constraints::Linear::errorCheck(), APPSPACK::Constraints::Linear::formDistanceVector(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Constraints::Linear::getActiveIndex(), getRighInvAndNullBasis(), getRow(), getRowPointers(), APPSPACK::Constraints::Linear::isEqualityFeasible(), APPSPACK::Constraints::Linear::isInequalityFeasible(), leftshift(), APPSPACK::Constraints::Linear::maxStep(), multMat(), multMatWithBlas(), multMatWithoutBlas(), multVec(), multVecWithBlas(), multVecWithoutBlas(), normalize(), nullSpace(), pruneDependentRows(), scale(), APPSPACK::Constraints::Linear::setupRhs(), APPSPACK::Constraints::Linear::setupScaledSystem(), svd(), transpose(), and APPSPACK::Directions::updateDirectionInfo().

int APPSPACK::Matrix::getNcols  )  const
 

Returns number of columns in A.

Definition at line 94 of file APPSPACK_Matrix.cpp.

References matrix.

Referenced by addRow(), addUniqueRows(), APPSPACK::Directions::buildWithLapack(), constrainedLSQR(), copyToFortranVector(), APPSPACK::Constraints::Linear::formSnapSystem(), getRighInvAndNullBasis(), leftshift(), multMat(), multMatWithBlas(), multMatWithoutBlas(), multVec(), multVecWithBlas(), multVecWithoutBlas(), nullSpace(), pruneDependentRows(), scale(), APPSPACK::Constraints::Linear::setupMatrix(), APPSPACK::Constraints::Linear::setupScaledSystem(), svd(), and transpose().

const APPSPACK::Vector & APPSPACK::Matrix::getRow int  i  )  const
 

Return ith row of A.

Definition at line 102 of file APPSPACK_Matrix.cpp.

References getNrows(), and matrix.

Referenced by addMatrix(), addUniqueRows(), APPSPACK::Directions::buildNormalCone(), copySubMatrix(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Directions::getDirection(), APPSPACK::Constraints::Linear::getEqState(), APPSPACK::Constraints::Linear::getIneqState(), APPSPACK::Directions::print(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::getRowPointers vector< double * > &  Aptr  ) 
 

On exit Aptr[i] points to row i of A.

Definition at line 114 of file APPSPACK_Matrix.cpp.

References getNrows(), matrix, matrixChanged(), and APPSPACK::Vector::push_back().

void APPSPACK::Matrix::clear  ) 
 

Empty the matrix A.

Definition at line 121 of file APPSPACK_Matrix.cpp.

References matrixChanged(), and resize().

Referenced by APPSPACK::Directions::buildWithCddlib(), APPSPACK::Directions::buildWithLapack(), APPSPACK::Directions::buildWithNothing(), copySubMatrix(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Directions::generateForLinear(), APPSPACK::Directions::generateUnconstrained(), and getRighInvAndNullBasis().

void APPSPACK::Matrix::addRow const Vector r  ) 
 

Append a copy of r to the bottom of A.

Definition at line 127 of file APPSPACK_Matrix.cpp.

References getNcols(), matrix, matrixChanged(), APPSPACK::Vector::push_back(), and APPSPACK::Vector::size().

Referenced by addMatrix(), addRow(), addUniqueRows(), APPSPACK::Directions::buildNormalCone(), APPSPACK::Directions::buildWithNothing(), copySubMatrix(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Directions::generateUnconstrained(), and APPSPACK::processTextInputFileLine().

void APPSPACK::Matrix::deleteRow int  i  ) 
 

Deletes the ith row of A.

Definition at line 140 of file APPSPACK_Matrix.cpp.

References APPSPACK::Vector::erase(), getNrows(), matrix, and matrixChanged().

Referenced by normalize(), and pruneDependentRows().

void APPSPACK::Matrix::addRow const Vector r,
double  alpha
 

Append alpha * r (i.e., a scaled copy of r) to the bottom of A.

Definition at line 153 of file APPSPACK_Matrix.cpp.

References addRow(), matrix, matrixChanged(), and APPSPACK::Vector::scale().

void APPSPACK::Matrix::addMatrix const Matrix B  ) 
 

Append copies of the rows of matrix B to the bottom of A.

Definition at line 160 of file APPSPACK_Matrix.cpp.

References addRow(), getNrows(), getRow(), and matrixChanged().

Referenced by APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildNormalCone(), APPSPACK::Directions::buildWithCddlib(), APPSPACK::Directions::buildWithLapack(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::addMatrix const Matrix B,
double  alpha
 

Append the matrix alpha * B (i.e., a scaled copy of B) to the bottom of A.

Definition at line 167 of file APPSPACK_Matrix.cpp.

References addRow(), getNrows(), getRow(), and matrixChanged().

void APPSPACK::Matrix::addMatrix const Matrix B,
const Vector s
 

Append matrix B scaled columnwise to the bottom of A.

In other words the matrix $\hat{B}$ is added to the bottom of A, where

\[ \hat{B}_{ij} = s_j B_{ij}. \]

Definition at line 174 of file APPSPACK_Matrix.cpp.

References addRow(), getNrows(), getRow(), matrix, matrixChanged(), and APPSPACK::Vector::scale().

void APPSPACK::Matrix::addUniqueRows const Matrix B,
double  epsilon
 

Selectivly appends the rows which are unique to B to the bottom of A.

In other words, the ith row $ b_i $ is added to the end of A if

\[ \|a_j - b_i\|_2 \le \epsilon \;\;\forall\;\; a_j \in A. \]

Here $ a_j $ is used to denote the jth row of A.

Note:
It is assumed that there is no repitition amongst the rows of B.

Definition at line 184 of file APPSPACK_Matrix.cpp.

References addRow(), getNcols(), getNrows(), getRow(), matrixChanged(), and APPSPACK::Vector::norm().

Referenced by APPSPACK::Directions::addCompassDirections(), and APPSPACK::Directions::appendNewDirections().

void APPSPACK::Matrix::operator= const Matrix B  ) 
 

Copy matrix (A = B).

Definition at line 213 of file APPSPACK_Matrix.cpp.

References matrix, and matrixChanged().

Referenced by Matrix().

void APPSPACK::Matrix::transpose const Matrix B  ) 
 

Copy transposed matrix (A = B').

Definition at line 219 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), matrix, matrixChanged(), and resize().

Referenced by Matrix().

void APPSPACK::Matrix::scale const Matrix B,
const Vector s
 

Copy and scale matrix.

Copies B into A and scales column j by s[j]. In other words,

\[ A_{ij} = s_j B_{ij}. \]

Definition at line 232 of file APPSPACK_Matrix.cpp.

References matrix, and matrixChanged().

Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildWithCddlib(), APPSPACK::Directions::buildWithLapack(), getRighInvAndNullBasis(), Matrix(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::scale const Vector s  ) 
 

Scale matrix.

Scales column j by s[j]. In other words,

\[ A_{ij} = s_j A_{ij}. \]

Definition at line 242 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), matrix, and matrixChanged().

void APPSPACK::Matrix::setToIdentity int  n  ) 
 

Sets A = I, an n by n identity matrix.

Definition at line 253 of file APPSPACK_Matrix.cpp.

References matrix, matrixChanged(), resize(), and APPSPACK::Vector::zero().

Referenced by APPSPACK::Directions::buildWithLapack(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::normalize  ) 
 

Normalizes the rows of A.

Warning:
All rows of A with norm equal to zero are deleted from A.

Definition at line 264 of file APPSPACK_Matrix.cpp.

References deleteRow(), getNrows(), matrix, matrixChanged(), APPSPACK::Vector::norm(), and APPSPACK::Vector::scale().

Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildWithCddlib(), and APPSPACK::Directions::buildWithLapack().

void APPSPACK::Matrix::multVec const Vector x,
Vector y,
TransposeType  ttype = NoTranspose
const
 

Compute y = Ax (or y = A'x if ttype = Transpose).

Definition at line 277 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), multVecWithBlas(), multVecWithoutBlas(), and APPSPACK::Vector::size().

Referenced by APPSPACK::Constraints::Linear::formDistanceVector(), APPSPACK::Constraints::Linear::formSnapSystem(), APPSPACK::Constraints::Linear::maxStep(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::svd Matrix U,
Vector s,
Matrix VT
const
 

Compute the singular value decomposition (SVD) of A.

Compute $ A = U \Sigma V^{T}$ where U is an m x m orthogonal matrix, V is an n x n orthogonal matrix, and $\Sigma$ is an m x n diagonal matrix where

\[ \Sigma = \left[ \begin{array}{cccc} s_{1} & 0 & \cdots & 0 \\ 0 & s_2 & \cdots & 0 \\ \vdots &\vdots & \ddots &\vdots \\ 0 & 0 & 0 & s_{p}\\ \end{array} \right], \]

with $s_1 \geq s_2 \geq \cdots \geq s_p$ and p = min{m,n}.

Parameters:
U (output) Matrix U from the SVD
s (output) diagonal of $\Sigma$ from the SVD
VT (output) Matrix V' from the SVD (note that this is transposed!)
Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 320 of file APPSPACK_Matrix.cpp.

References copyFromFortranVector(), APPSPACK::DGESVD_F77(), getMatrixVector(), getNcols(), getNrows(), and APPSPACK::Vector::resize().

Referenced by getRighInvAndNullBasis(), and nullSpace().

void APPSPACK::Matrix::multMat const Matrix B,
TransposeType  ttype = NoTranspose
 

On exit A = A*B if ttype = NoTranspose, and A = A*B' otherwise.

Definition at line 363 of file APPSPACK_Matrix.cpp.

References matrix, and matrixChanged().

Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildWithLapack(), getRighInvAndNullBasis(), and APPSPACK::Constraints::Linear::setupScaledSystem().

void APPSPACK::Matrix::multMat const Matrix B,
Matrix C,
TransposeType  ttype = NoTranspose
const
 

On exit C = A*B if ttype = NoTranspose, and C = A*B' otherwise.

Definition at line 372 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), multMatWithBlas(), and multMatWithoutBlas().

void APPSPACK::Matrix::nullSpace Matrix ZT,
double  tol
const
 

On exit the rows of ZT form an orthonormal basis for null(A).

Parameters:
ZT (output) ZT is a matrix of size $ n_z \times n $ where n is the number of columns in A and $ n_z = n - {\rm rank}(A) $ .
tol (input) Any singular value of A that is less than this value is considered to be zero for the purposes of determining the rank.
Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 403 of file APPSPACK_Matrix.cpp.

References copySubMatrix(), getNcols(), getNrows(), APPSPACK::Vector::size(), and svd().

Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildWithLapack(), and APPSPACK::Constraints::Linear::setupScaledSystem().

bool APPSPACK::Matrix::getRighInvAndNullBasis Matrix RT,
Matrix NT,
double  tol
const
 

Computes right inverse and null space basis matrix for A (if possible).

Let A be an $m \times n$ matrix. We assume $n < m$ and that A has full row rank (i.e., rank(A) = m); if not, the method returns false because a right inverse cannot be computed. Otherwise, matrices R and N are computed such that R is a right-inverse of A, i.e., $AR = I$, and the columns of N are an orthonormal basis for the null space of A so that $AN = 0$.

Parameters:
RT (output) The transpose of R, the right inverse of A
NT (output) The transpose N, whose columns span the null space of A
tol (input) Used in the rank determination, i.e., only singular values greater than or equal to tol are considered to be non-zero.
Returns:
True if the right inverse of A exists; false otherwise.
Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 436 of file APPSPACK_Matrix.cpp.

References clear(), copySubMatrix(), getNcols(), getNrows(), multMat(), scale(), APPSPACK::Vector::size(), and svd().

Referenced by APPSPACK::Directions::buildWithLapack().

void APPSPACK::Matrix::pruneDependentRows Vector b,
double  epsilon
 

Deletes dependent rows of A and corresponding entries in b. On exit, Ax = b forms a consistent system.

Parameters:
b Righthand-side vector in system Ax=b.
epsilon Error tolerance used when determining linearly independent subset.
A consistent system is returned on exit by deleting rows of A and entries of b corresponding to dependent rows.

Dependent rows are determined as follows:

An LQ factorization of A is first computed, where L denotes a lower triangular matrix and Q an orthogonal matrix. In exact arithmetic, the nonzero diagonal entries of L correspond to a linearly independent subset of the rows of A. To allow for numerical round off, row $ a_i^T $ and entry $ b_i $ are deleted from A and b respectively if

\[ |L(i,i)| < \epsilon. \]

Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 475 of file APPSPACK_Matrix.cpp.

References deleteRow(), APPSPACK::DGELQF_F77(), APPSPACK::Vector::erase(), getMatrixVector(), getNcols(), getNrows(), matrixChanged(), and NoTranspose.

Referenced by APPSPACK::Constraints::Linear::formSnapSystem().

void APPSPACK::Matrix::constrainedLSQR Vector x,
const Vector b
const
 

Solve a constrained least-squares problem for the case when A has full row rank.

Parameters:
x (input/output) On entry, x denotes current point. On exit, x equals the solution to the below constrained least-squares problem.
b (input) The right-hand side vector to system $ A \hat x = b.$
This method solves the following constrained least-squares problem:

\[ \begin{array}{ll} {\rm minimize} & \|\hat x - x\| \\ {\rm subject} & A \hat x = b, \end{array} \]

using LAPACK function DGGLSE_F77().

Note:
It is assumed that A has full row rank.

Method requires that APPSPACK be configured with LAPACK.

Definition at line 502 of file APPSPACK_Matrix.cpp.

References APPSPACK::DGGLSE_F77(), empty(), getMatrixVector(), getNcols(), and getNrows().

Referenced by APPSPACK::Constraints::Linear::snapToBoundary().

ostream & APPSPACK::Matrix::leftshift ostream &  stream  )  const
 

Print object to the given stream

Definition at line 528 of file APPSPACK_Matrix.cpp.

References APPSPACK::Print::formatDouble(), getNcols(), getNrows(), and matrix.

Referenced by operator<<().

void APPSPACK::Matrix::matrixChanged  )  [private]
 

Sets fmatvecSet and fmatvecTSet to false.

Should be called inside ever non-const method.

Definition at line 542 of file APPSPACK_Matrix.cpp.

References fmatvecSet, and fmatvecTSet.

Referenced by addMatrix(), addRow(), addUniqueRows(), clear(), copyFromFortranVector(), copySubMatrix(), deleteRow(), getRowPointers(), multMat(), normalize(), operator=(), pruneDependentRows(), resize(), scale(), setToIdentity(), and transpose().

const APPSPACK::Vector & APPSPACK::Matrix::getMatrixVector TransposeType  ttype = NoTranspose  )  const [private]
 

Private member variables fmatvec and fmatvecTSet should never be access directly. Instead method getMatrixVector() should be called. If ttype equals NoTranspose, A is returns as a single vector stored column-wise. If ttype equals Transpose, A is returns as a single vector stored row-wise.

Definition at line 548 of file APPSPACK_Matrix.cpp.

References copyToFortranVector(), fmatvec, fmatvecSet, fmatvecT, and fmatvecTSet.

Referenced by constrainedLSQR(), multMatWithBlas(), multVecWithBlas(), pruneDependentRows(), and svd().

void APPSPACK::Matrix::copyToFortranVector Vector Avec,
TransposeType  ttype = NoTranspose
const [private]
 

Converts A to a Fortran-style vector.

Converts A to a vector stored columnwise so that the vector representation is

\[ \left[ \begin{array}{c} a_{11} \\ a_{21} \\ \vdots \\ a_{m1} \\ a_{12} \\ a_{22} \\ \vdots \\ a_{m2} \\ a_{13} \\ \vdots \\ \vdots \\ a_{mn} \end{array} \right] \]

The index mapping is:

\[ (i,j) \rightarrow (j * m) + i \]

Store A' instead if ttype = Transpose

Definition at line 570 of file APPSPACK_Matrix.cpp.

References APPSPACK::Vector::append(), getNcols(), getNrows(), matrix, APPSPACK::Vector::push_back(), APPSPACK::Vector::reserve(), and APPSPACK::Vector::resize().

Referenced by getMatrixVector().

void APPSPACK::Matrix::copyFromFortranVector const Vector Avec,
int  nrows,
int  ncols,
TransposeType  ttype = NoTranspose
[private]
 

Unpack A from a Fortran-style vector.

Assumes A' is stored in the vector if ttype = Transpose

Definition at line 595 of file APPSPACK_Matrix.cpp.

References matrix, matrixChanged(), and resize().

Referenced by multMatWithBlas(), and svd().

void APPSPACK::Matrix::resize int  m,
int  n
[private]
 

Resize A to have m rows and n columns.

Definition at line 624 of file APPSPACK_Matrix.cpp.

References matrix, matrixChanged(), and APPSPACK::Vector::resize().

Referenced by clear(), copyFromFortranVector(), APPSPACK::Constraints::Linear::getActiveIndex(), Matrix(), multMatWithoutBlas(), setToIdentity(), and transpose().

void APPSPACK::Matrix::copySubMatrix int  istart,
int  iextent,
const Matrix B
[private]
 

Sets A equal to the specified block-row submatrix of B.

Parameters:
istart Starting row of submatrix.
iextent Number of rows past istart to copy from B.
B Matrix to be copied from.
On exit A equals the block-row submatrix of B designated by rows istart through istart + iextent of B. Essentially,

\[ A(i,j) = B(istart+i, j), \; 0 \le i < iextent, \; 0 \le j < n_B \]

where $ n_B $ denotes the number of columns in $ B$. Hence $ A $ is an (iextent X $n_B$) matrix on exit.

Definition at line 633 of file APPSPACK_Matrix.cpp.

References addRow(), clear(), getNrows(), getRow(), and matrixChanged().

Referenced by getRighInvAndNullBasis(), and nullSpace().

void APPSPACK::Matrix::multMatWithBlas const APPSPACK::Matrix Bin,
APPSPACK::Matrix C,
TransposeType  ttype
const [private]
 

Performs a matrix multiply using Blas 3 routine DGEMM_F77().

On exit C = A*B if ttype = NoTranspose, and C = A*B' otherwise.

Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 648 of file APPSPACK_Matrix.cpp.

References copyFromFortranVector(), APPSPACK::DGEMM_F77(), getMatrixVector(), getNcols(), getNrows(), and Transpose.

Referenced by multMat().

void APPSPACK::Matrix::multMatWithoutBlas const APPSPACK::Matrix Bin,
APPSPACK::Matrix C,
TransposeType  ttype
const [private]
 

Performs a matrix multiply by hand without blas subroutines.

On exit C = A*B if ttype = NoTranspose, and C = A*B' otherwise.

Definition at line 698 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), matrix, and resize().

Referenced by multMat().

void APPSPACK::Matrix::multVecWithBlas const Vector x,
Vector y,
TransposeType  ttype = NoTranspose
const [private]
 

Performs a matrix-vector multiply with Blas subroutine DGEMV_F77().

Computes y = Ax (or y = A'x if ttype = Transpose).

Note:
Method requires that APPSPACK be configured with LAPACK.

Definition at line 754 of file APPSPACK_Matrix.cpp.

References APPSPACK::DGEMV_F77(), getMatrixVector(), getNcols(), and getNrows().

Referenced by multVec().

void APPSPACK::Matrix::multVecWithoutBlas const Vector x,
Vector y,
TransposeType  ttype = NoTranspose
const [private]
 

Performs a matrix-vector multiply by hand without blas subroutines.

Computes y = Ax (or y = A'x if ttype = Transpose).

Definition at line 733 of file APPSPACK_Matrix.cpp.

References getNcols(), getNrows(), matrix, and APPSPACK::Vector::zero().

Referenced by multVec().


Member Data Documentation

vector<Vector> APPSPACK::Matrix::matrix [private]
 

The matrix A.

The matrix is stored rowwise, i.e., matrix[i] is row i of A. and matrix[i][j] is A_ij.

Definition at line 414 of file APPSPACK_Matrix.hpp.

Referenced by addMatrix(), addRow(), copyFromFortranVector(), copyToFortranVector(), deleteRow(), empty(), getNcols(), getNrows(), getRow(), getRowPointers(), leftshift(), Matrix(), multMat(), multMatWithoutBlas(), multVecWithoutBlas(), normalize(), operator=(), resize(), scale(), setToIdentity(), and transpose().

Vector APPSPACK::Matrix::fmatvec [mutable, private]
 

Stores a current copy of A as a vector of columns if fmatvecSet=true

Definition at line 419 of file APPSPACK_Matrix.hpp.

Referenced by getMatrixVector().

bool APPSPACK::Matrix::fmatvecSet [mutable, private]
 

If true, fmatvec is up to date. If false, #fmatvex must be updated.

Definition at line 422 of file APPSPACK_Matrix.hpp.

Referenced by getMatrixVector(), and matrixChanged().

Vector APPSPACK::Matrix::fmatvecT [mutable, private]
 

Stores a current copy of A as a vector of rows if fmatvecT=true

Definition at line 425 of file APPSPACK_Matrix.hpp.

Referenced by getMatrixVector().

bool APPSPACK::Matrix::fmatvecTSet [mutable, private]
 

If true, fmatvecT is up to date. If false, fmatvecT must be updated.

Definition at line 428 of file APPSPACK_Matrix.hpp.

Referenced by getMatrixVector(), and matrixChanged().


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

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:36 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002