Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 }
00174
00175 #endif // sparseqr_hh