Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

sparseqr/sparseqr.hh
Go to the documentation of this file.
00001 /*----------------------------------------------------------------------------
00002 Sparse QR solver for linear systems of equations or least squares problems
00003 Copyright (C) 1996, 1997, 1998 Thomas H. Robey
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Library General Public
00007 License as published by the Free Software Foundation; either
00008 version 2 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Library General Public License for more details.
00014 
00015 You should have received a copy of the GNU Library General Public
00016 License along with this library; if not, write to the Free
00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 Inquiries can be directed to trobey@arc.unm.edu or
00020 
00021 Thomas H. Robey
00022 925 Madison NE
00023 Albuquerque, NM  87110
00024 USA
00025 ----------------------------------------------------------------------------*/
00026 
00027 #ifndef sparseqr_hh
00028 #define sparseqr_hh
00029 
00030 #include <iostream>
00031 #include <cstddef>
00032 #include <cassert>
00033 #include <cfloat>
00034 
00035 #ifdef DEBUG
00036 #  define QRSTAT
00037 #endif
00038 
00039 namespace sparseqr {
00040 
00046   class Packed {
00047   public:
00049     int *col;
00051     double *value;
00053     unsigned size;
00057     Packed(unsigned cnt=0);
00061     void init(unsigned cnt=0);
00062     ~Packed();
00064     void Sort();
00065   };
00066 
00067   std::ostream& operator<<(std::ostream& os, const Packed& p);
00068 
00074   class J {
00075   public:
00076     int row1,row2;
00077     double c,s;
00078     J *next,*previous;
00079     void *operator new(size_t,double,double,int,int,J *);
00080   };
00081 
00082   std::ostream& operator<<(std::ostream& os, const J& j);
00083 
00090   class Qmatrix {
00091   public:
00092     J *qbegin,*qend;
00093     double *ApplyQ(double *);
00094     Qmatrix();
00095     ~Qmatrix();
00096   };
00097 
00098   std::ostream& operator<<(std::ostream& os, const Qmatrix& q);
00099 
00104   class Smatrix {
00105   public:
00106     int row,col;
00107     double value;
00108     Smatrix *right,*down;
00109     int match(Smatrix *);
00110     Smatrix *MoveDown(Smatrix **);
00111     Smatrix *MoveRight(Smatrix **);
00112     Smatrix *MarkEntry(Smatrix **sptr);
00113     void *operator new(size_t size,int r,int c,double v,Smatrix *rptr=NULL,
00114            Smatrix *dptr=NULL);
00115   };
00116 
00122   class QR {
00123   public:
00124     int nr,nc,*prow,*pcol;
00126     bool del_prow, del_pcol;
00127     unsigned *nrow;
00128 #ifdef QRSTAT
00129     long int fillin,flops,ngivens;
00130 #endif
00131     double ztol,rtol,*b;
00132     Packed *pmatrix;
00133     Smatrix **srow,**scol;
00134     Qmatrix *q;
00139     void BackSolve(int rank,double * x);
00141     int givens(int,int,int);
00160     QR(Packed *qrpmatrix,int qrnr,int qrnc,double *qrb=NULL,Qmatrix *qrq=NULL,
00161        int *qrprow=NULL,int *qrpcol=NULL,double qrztol=DBL_EPSILON,
00162        double qrrtol=0.0);
00163     ~QR();
00164     void RemoveEntry(int,int);
00165     Smatrix *RemoveEntry(int,int,Smatrix *,Smatrix *);
00166     int RemoveMarkedEntries(int);
00170     int sparseqr();
00171   };
00172 
00173 } // namespace sparseqr
00174 
00175 #endif // sparseqr_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)