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

Go to the documentation of this file.
00001 // $Id: APPSPACK_Matrix.hpp,v 1.52 2005/10/15 00:13:06 jgriffi Exp $ 
00002 // $Source: /space/CVS-Acro/acro/packages/appspack/appspack/src/APPSPACK_Matrix.hpp,v $ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //          APPSPACK: Asynchronous Parallel Pattern Search
00008 //                 Copyright (2003) Sandia Corporation
00009 // 
00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00011 // license for use of this work by or on behalf of the U.S. Government.
00012 // 
00013 // This library is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Lesser General Public License as
00015 // published by the Free Software Foundation; either version 2.1 of the
00016 // License, or (at your option) any later version.
00017 //  
00018 // This library is distributed in the hope that it will be useful, but
00019 // WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //                                                                                 
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00026 // USA.                                                                           .
00027 // 
00028 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) 
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00038 #ifndef APPSPACK_MATRIX_HPP
00039 #define APPSPACK_MATRIX_HPP
00040 
00041 #include "APPSPACK_Common.hpp"
00042 #include "APPSPACK_Vector.hpp"
00043 
00044 namespace APPSPACK
00045 {
00046 
00048 
00069 class Matrix
00070 {
00071 public:
00072 
00074   enum TransposeType {
00076     Transpose,
00078     NoTranspose
00079   };
00080 
00082   Matrix();
00083    
00085 
00086   Matrix(const Matrix& B, TransposeType ttype = NoTranspose);
00087 
00089 
00098   Matrix(const Matrix& B, const Vector& s, TransposeType ttype = NoTranspose);
00099 
00101   Matrix(double** Aptr, int nrows, int ncols);
00102 
00104   ~Matrix();
00105 
00107 
00109   bool empty() const;
00110 
00112   int getNrows() const;
00113   
00115   int getNcols() const;
00116 
00118   const Vector& getRow(int i) const;
00119 
00121 
00123 
00125   void getRowPointers(vector< double *>& Aptr);
00126 
00128   void clear();
00129 
00131   void addRow(const Vector& r);
00132 
00134   void deleteRow(int i);
00135 
00137   void addRow(const Vector& r, double alpha);
00138 
00140   void addMatrix(const Matrix& B);
00141  
00143   void addMatrix(const Matrix& B, double alpha);
00144 
00146 
00151   void addMatrix(const Matrix& B, const Vector& s);
00152 
00154 
00161   void addUniqueRows(const Matrix& B, double epsilon);
00162 
00163 
00165   void operator=(const Matrix& B);  
00166 
00168   void transpose(const Matrix& B);
00169 
00171 
00176   void scale(const Matrix& B, const Vector& s);
00177 
00179 
00184   void scale(const Vector& s);
00185 
00187   void setToIdentity(int n);
00188   
00190 
00191   void normalize();
00192 
00194 
00196 
00198   void multVec(const Vector& x, Vector& y, TransposeType ttype = NoTranspose) const;
00199 
00201 
00222   void svd(Matrix& U, Vector &s, Matrix& VT) const;           
00223   
00225   void multMat(const Matrix& B, TransposeType ttype = NoTranspose);
00226   
00228   void multMat(const Matrix& B, Matrix& C,TransposeType ttype = NoTranspose) const;
00229 
00231 
00240   void nullSpace(Matrix& ZT, double tol) const;
00241             
00243 
00262   bool getRighInvAndNullBasis(Matrix& RT, Matrix& NT, double tol) const;
00263 
00287   void pruneDependentRows(Vector& b, double epsilon);
00288 
00290 
00308   void constrainedLSQR(Vector& x, const Vector& b) const;
00309 
00311 
00313 
00315   ostream& leftshift(ostream& stream) const;
00316 
00318 
00319 private:
00320 
00322 
00323   void matrixChanged();
00324 
00331   const Vector& getMatrixVector(TransposeType ttype = NoTranspose) const;
00332   
00334 
00359   void copyToFortranVector(Vector& Avec, TransposeType ttype = NoTranspose) const;
00360 
00362 
00365   void copyFromFortranVector(const Vector& Avec, int nrows, int ncols, TransposeType ttype = NoTranspose);
00366  
00368   void resize(int m, int n);
00369   
00371 
00384   void copySubMatrix(int istart, int iextent, const Matrix& B);
00385 
00387 
00389   void multMatWithBlas(const APPSPACK::Matrix& Bin, APPSPACK::Matrix& C,
00390                        TransposeType ttype) const;
00391 
00393 
00394   void multMatWithoutBlas(const APPSPACK::Matrix& Bin, APPSPACK::Matrix& C,
00395                           TransposeType ttype) const;
00396    
00398 
00400   void multVecWithBlas(const Vector& x, Vector& y, TransposeType ttype = NoTranspose) const;
00401   
00403 
00404   void multVecWithoutBlas(const Vector& x, Vector& y, TransposeType ttype = NoTranspose) const;
00405 
00406 private:
00407 
00414   vector<Vector> matrix;
00415 
00417   
00419   mutable Vector fmatvec;
00420   
00422   mutable bool fmatvecSet;
00423   
00425   mutable Vector fmatvecT;
00426   
00428   mutable bool fmatvecTSet;
00429   
00431   
00432 };
00433 
00434 }
00435   
00437 ostream& operator<<(ostream& stream, const APPSPACK::Matrix& x);
00438 
00439 
00440 
00441 
00442 #endif

 

© Sandia Corporation | Site Contact | Privacy and Security

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