sparseqr.hh

Go to the documentation of this file.
1 
7 /*----------------------------------------------------------------------------
8 Sparse QR solver for linear systems of equations or least squares problems
9 Copyright (C) 1996, 1997, 1998 Thomas H. Robey
10 
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
15 
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20 
21 You should have received a copy of the GNU Library General Public
22 License along with this library; if not, write to the Free
23 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 
25 Inquiries can be directed to trobey@arc.unm.edu or
26 
27 Thomas H. Robey
28 925 Madison NE
29 Albuquerque, NM 87110
30 USA
31 ----------------------------------------------------------------------------*/
32 
33 #ifndef sparseqr_hh
34 #define sparseqr_hh
35 
36 #include <iostream>
37 #include <cstddef>
38 #include <cassert>
39 #include <cfloat>
40 
41 #ifdef DEBUG
42 # define QRSTAT
43 #endif
44 
45 namespace sparseqr {
46 
52  class Packed {
53  public:
55  int *col;
57  double *value;
59  unsigned size;
63  Packed(unsigned cnt=0);
67  void init(unsigned cnt=0);
70  void Sort();
71  };
72 
73  std::ostream& operator<<(std::ostream& os, const Packed& p);
74 
80  class J {
81  public:
82  int row1,row2;
83  double c,s;
85  void *operator new(size_t,double,double,int,int,J *);
86  };
87 
88  std::ostream& operator<<(std::ostream& os, const J& j);
89 
96  class Qmatrix {
97  public:
99  double *ApplyQ(double *);
102  };
103 
104  std::ostream& operator<<(std::ostream& os, const Qmatrix& q);
105 
110  class Smatrix {
111  public:
112  int row,col;
113  double value;
115  int match(Smatrix *);
119  void *operator new(size_t size,int r,int c,double v,Smatrix *rptr=NULL,
120  Smatrix *dptr=NULL);
121  };
122 
128  class QR {
129  public:
130  int nr,nc,*prow,*pcol;
133  unsigned *nrow;
134 #ifdef QRSTAT
135  long int fillin,flops,ngivens;
136 #endif
137  double ztol,rtol,*b;
145  void BackSolve(int rank,double * x);
147  int givens(int,int,int);
166  QR(Packed *qrpmatrix,int qrnr,int qrnc,double *qrb=NULL,Qmatrix *qrq=NULL,
167  int *qrprow=NULL,int *qrpcol=NULL,double qrztol=DBL_EPSILON,
168  double qrrtol=0.0);
169  ~QR();
170  void RemoveEntry(int,int);
176  int sparseqr();
177  };
178 
179 } // namespace sparseqr
180 
181 #endif // sparseqr_hh
void Sort()
Sorts the entries of each row.
Smatrix * MarkEntry(Smatrix **sptr)
int * prow
Definition: sparseqr.hh:130
J * previous
Definition: sparseqr.hh:84
Row of a sparse matrix.
Definition: sparseqr.hh:52
double c
Definition: sparseqr.hh:83
Given's rotations.
Definition: sparseqr.hh:80
bool del_pcol
Definition: sparseqr.hh:132
double ztol
Definition: sparseqr.hh:137
double s
Definition: sparseqr.hh:83
void RemoveEntry(int, int)
QR factorization.
Definition: sparseqr.hh:128
Smatrix ** scol
Definition: sparseqr.hh:139
bool del_prow
Stores if delete[] of prow and pcol is allowed.
Definition: sparseqr.hh:132
int * pcol
Definition: sparseqr.hh:130
Smatrix * down
Definition: sparseqr.hh:114
int givens(int, int, int)
Performs Given's rotations.
SparseQR solver.
Definition: driver.hh:19
unsigned * nrow
Definition: sparseqr.hh:133
void init(unsigned cnt=0)
Initializes the dynamic storage.
Smatrix * RemoveEntry(int, int, Smatrix *, Smatrix *)
double * ApplyQ(double *)
Packed * pmatrix
Definition: sparseqr.hh:138
QR(Packed *qrpmatrix, int qrnr, int qrnc, double *qrb=NULL, Qmatrix *qrq=NULL, int *qrprow=NULL, int *qrpcol=NULL, double qrztol=DBL_EPSILON, double qrrtol=0.0)
Constructor.
Packed(unsigned cnt=0)
Constructor.
double rtol
Definition: sparseqr.hh:137
int sparseqr()
Performs QR factorization.
double * b
Definition: sparseqr.hh:137
Smatrix * MoveDown(Smatrix **)
double * value
Values of the entries.
Definition: sparseqr.hh:57
int match(Smatrix *)
int RemoveMarkedEntries(int)
unsigned size
Number of entries in the row.
Definition: sparseqr.hh:59
int * col
Column indices of the entries.
Definition: sparseqr.hh:55
Qmatrix * q
Definition: sparseqr.hh:140
std::ostream & operator<<(std::ostream &os, const Packed &p)
Smatrix ** srow
Definition: sparseqr.hh:139
void BackSolve(int rank, double *x)
Performes backsolve.
Smatrix * right
Definition: sparseqr.hh:114
Q matrix of the QR factorization.
Definition: sparseqr.hh:96
Smatrix * MoveRight(Smatrix **)
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich