~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/mod/mth/shl/Rgivens.hpp

  • Committer: Package Import Robot
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2015-07-11 02:00:35 UTC
  • mfrom: (10.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150711020035-2nhpztq7s15qyc0v
Tags: 2.5.1-1
* New upstream release. (Closes: #789968)
* Update debian/control.
  - Update Standards-Version to 3.9.6.
* Add support mips64(el) and ppc64el. (Closes: #741508, #748146)
* Add patches/support-gcc-5.x.patch. (Closes: #777767)
  - Fix build with gcc-5.x.
* Add patches/Disable-NET0001.als.patch.
  - Disable test of NET0001.als.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ---------------------------------------------------------------------------
 
2
// - Rgivens.hpp                                                             -
 
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.                  -
 
7
// -                                                                         -
 
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
// ---------------------------------------------------------------------------
 
16
 
 
17
#ifndef  AFNIX_RGIVENS_HPP
 
18
#define  AFNIX_RGIVENS_HPP
 
19
 
 
20
#ifndef  AFNIX_RMD_HPP
 
21
#include "Rmd.hpp"
 
22
#endif
 
23
 
 
24
namespace afnix {
 
25
 
 
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
 
34
 
 
35
  class Rgivens : public Object {
 
36
  public:
 
37
    /// the givens rotation
 
38
    struct s_givens {
 
39
      /// the row datum
 
40
      t_long d_row;
 
41
      /// the column datum
 
42
      t_long d_col;
 
43
      /// the givens c coefficients
 
44
      t_real d_c;
 
45
      /// the givens s coefficients
 
46
      t_real d_s;
 
47
      /// create a givens rotation
 
48
      s_givens (void);
 
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);
 
71
    };
 
72
 
 
73
  protected:
 
74
    /// the givens size
 
75
    long d_size;
 
76
    /// the givens length
 
77
    long d_glen;
 
78
    ///  the givens rotations
 
79
    s_givens* p_grot;
 
80
 
 
81
  public:
 
82
    /// create a default givens array
 
83
    Rgivens (void);
 
84
 
 
85
    /// destroy this object
 
86
    ~Rgivens (void);
 
87
 
 
88
    /// @return the class name
 
89
    String repr (void) const;
 
90
 
 
91
    /// @return the givens array length
 
92
    virtual long length (void) const;
 
93
 
 
94
    /// add a givens rotation
 
95
    /// @param gr the givens rotation
 
96
    virtual long add (const s_givens& gr);
 
97
 
 
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);
 
102
    
 
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);
 
110
    
 
111
    /// @return the givens rotation by index
 
112
    virtual s_givens get (const long index) const;
 
113
 
 
114
    /// @return the givens row by index
 
115
    virtual t_long getrow (const long index) const;
 
116
 
 
117
    /// @return the givens column by index
 
118
    virtual t_long getcol (const long index) const;
 
119
 
 
120
    /// @return the givens c value by index
 
121
    virtual t_real getc (const long index) const;
 
122
 
 
123
    /// @return the givens s value by index
 
124
    virtual t_real gets (const long index) const;
 
125
 
 
126
  public:
 
127
    /// @return the givens rotation by index (no lock)
 
128
    virtual s_givens nlget (const long index) const;
 
129
 
 
130
    /// @return the givens row by index (no lock)
 
131
    virtual t_long nlgrow (const long index) const;
 
132
 
 
133
    /// @return the givens column by index (no lock)
 
134
    virtual t_long nlgcol (const long index) const;
 
135
 
 
136
    /// @return the givens c value by index (no lock)
 
137
    virtual t_real nlgc (const long index) const;
 
138
 
 
139
    /// @return the givens s value by index (no lock)
 
140
    virtual t_real nlgs (const long index) const;
 
141
 
 
142
  private:
 
143
    // make the copy constructor private
 
144
    Rgivens (const Rgivens&);
 
145
    // make the assignement operator private
 
146
    Rgivens& operator = (const Rgivens&);
 
147
 
 
148
  public:
 
149
    /// create a new object in a generic way
 
150
    /// @param argv the argument vector
 
151
    static Object* mknew (Vector* argv);
 
152
 
 
153
    /// @return true if the given quark is defined
 
154
    bool isquark (const long quark, const bool hflg) const;
 
155
 
 
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,
 
162
                   Vector* argv);
 
163
  };
 
164
}
 
165
 
 
166
#endif