Class documentation of Concepts

Loading...
Searching...
No Matches
sparseqr.hh
Go to the documentation of this file.
1
7/*----------------------------------------------------------------------------
8Sparse QR solver for linear systems of equations or least squares problems
9Copyright (C) 1996, 1997, 1998 Thomas H. Robey
10
11This library is free software; you can redistribute it and/or
12modify it under the terms of the GNU Library General Public
13License as published by the Free Software Foundation; either
14version 2 of the License, or (at your option) any later version.
15
16This library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19Library General Public License for more details.
20
21You should have received a copy of the GNU Library General Public
22License along with this library; if not, write to the Free
23Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25Inquiries can be directed to trobey@arc.unm.edu or
26
27Thomas H. Robey
28925 Madison NE
29Albuquerque, NM 87110
30USA
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
45namespace 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);
68 ~Packed();
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;
84 J *next,*previous;
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:
98 J *qbegin,*qend;
99 double *ApplyQ(double *);
100 Qmatrix();
101 ~Qmatrix();
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;
114 Smatrix *right,*down;
115 int match(Smatrix *);
116 Smatrix *MoveDown(Smatrix **);
117 Smatrix *MoveRight(Smatrix **);
118 Smatrix *MarkEntry(Smatrix **sptr);
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;
132 bool del_prow, del_pcol;
133 unsigned *nrow;
134#ifdef QRSTAT
135 long int fillin,flops,ngivens;
136#endif
137 double ztol,rtol,*b;
138 Packed *pmatrix;
139 Smatrix **srow,**scol;
140 Qmatrix *q;
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);
171 Smatrix *RemoveEntry(int,int,Smatrix *,Smatrix *);
172 int RemoveMarkedEntries(int);
176 int sparseqr();
177 };
178
179} // namespace sparseqr
180
181#endif // sparseqr_hh
double * value
Values of the entries.
Definition sparseqr.hh:57
void init(unsigned cnt=0)
void Sort()
Sorts the entries of each row.
int * col
Column indices of the entries.
Definition sparseqr.hh:55
unsigned size
Number of entries in the row.
Definition sparseqr.hh:59
Packed(unsigned cnt=0)
void BackSolve(int rank, double *x)
bool del_prow
Stores if delete[] of prow and pcol is allowed.
Definition sparseqr.hh:132
int givens(int, int, int)
Performs Given's rotations.
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)