1
// ---------------------------------------------------------------------------
3
// - afnix:mth module - real givens matrix class definitions -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2015 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_RGIVENS_HPP
18
#define AFNIX_RGIVENS_HPP
26
/// The Rgivens class is the real givens matrix class that provides
27
/// the essential mechanism to nullify a particular position in a matrix.
28
/// The givens matrix is an essential component of the QR factorization
29
/// process. The givens matrix is represented by two coefficients (c) and
30
/// (s). The (c) coefficients is at coordinates (row, row) and (col,col)
31
/// while the (-s) coefficient is at (row, col) (s) is at (col, row).
32
/// A givens matrix is essentially an orthogonal rotation matrix.
33
/// @author amaury darsch
35
class Rgivens : public Object {
37
/// the givens rotation
43
/// the givens c coefficients
45
/// the givens s coefficients
47
/// create a givens rotation
49
/// create a givens rotation by datum
50
/// @param rmr the matrix row datum
51
/// @param rmc the matrix col datum
52
s_givens (const Rmd& rmr, const Rmd& rmc);
53
/// create a givens rotation by values
54
/// @param row the row coordinates
55
/// @param col the col coordinate
56
/// @param rcv the row/col value
57
/// @param ccv the col/col value
58
s_givens (const t_long row, const t_long col,
59
const t_real rcv, const t_real ccv);
60
/// set a givens rotation by datum
61
/// @param rmr the matrix row datum
62
/// @param rmc the matrix col datum
63
void set (const Rmd& rmr, const Rmd& rmc);
64
/// set a givens rotation by values
65
/// @param row the row coordinates
66
/// @param col the col coordinate
67
/// @param rcv the row/col value
68
/// @param ccv the col/col value
69
void set (const t_long row, const t_long col,
70
const t_real rcv, const t_real ccv);
78
/// the givens rotations
82
/// create a default givens array
85
/// destroy this object
88
/// @return the class name
89
String repr (void) const;
91
/// @return the givens array length
92
virtual long length (void) const;
94
/// add a givens rotation
95
/// @param gr the givens rotation
96
virtual long add (const s_givens& gr);
98
/// add a givens rotation by datum
99
/// @param rmr the matrix row datum
100
/// @param rmc the matrix col datum
101
virtual long add (const Rmd& rmr, const Rmd& rmc);
103
/// add a givens rotation by values
104
/// @param row the row coordinates
105
/// @param col the col coordinate
106
/// @param xr the matrix row value
107
/// @param xr the matrix col value
108
virtual long add (const t_long row, const t_long col,
109
const t_real xr, const t_real xc);
111
/// @return the givens rotation by index
112
virtual s_givens get (const long index) const;
114
/// @return the givens row by index
115
virtual t_long getrow (const long index) const;
117
/// @return the givens column by index
118
virtual t_long getcol (const long index) const;
120
/// @return the givens c value by index
121
virtual t_real getc (const long index) const;
123
/// @return the givens s value by index
124
virtual t_real gets (const long index) const;
127
/// @return the givens rotation by index (no lock)
128
virtual s_givens nlget (const long index) const;
130
/// @return the givens row by index (no lock)
131
virtual t_long nlgrow (const long index) const;
133
/// @return the givens column by index (no lock)
134
virtual t_long nlgcol (const long index) const;
136
/// @return the givens c value by index (no lock)
137
virtual t_real nlgc (const long index) const;
139
/// @return the givens s value by index (no lock)
140
virtual t_real nlgs (const long index) const;
143
// make the copy constructor private
144
Rgivens (const Rgivens&);
145
// make the assignement operator private
146
Rgivens& operator = (const Rgivens&);
149
/// create a new object in a generic way
150
/// @param argv the argument vector
151
static Object* mknew (Vector* argv);
153
/// @return true if the given quark is defined
154
bool isquark (const long quark, const bool hflg) const;
156
/// apply this object with a set of arguments and a quark
157
/// @param robj the current runnable
158
/// @param nset the current nameset
159
/// @param quark the quark to apply these arguments
160
/// @param argv the arguments to apply
161
Object* apply (Runnable* robj, Nameset* nset, const long quark,