All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LSE.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_PROBLEMS_LSE_H_
23 #define _BLAZE_MATH_PROBLEMS_LSE_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <cmath>
33 #include <blaze/math/Functions.h>
34 #include <blaze/math/Infinity.h>
35 #include <blaze/util/Types.h>
36 
37 
38 namespace blaze {
39 
40 //=================================================================================================
41 //
42 // CLASS DEFINITION
43 //
44 //=================================================================================================
45 
46 //*************************************************************************************************
52 struct LSE
53 {
54  public:
55  //**Utility functions***************************************************************************
58  inline size_t size () const;
59  inline void project ( size_t index );
60  inline real lbound ( size_t index ) const;
61  inline real ubound ( size_t index ) const;
62  inline real residual( size_t index ) const;
63  inline real residual() const;
65  //**********************************************************************************************
66 
67  //**Member variables****************************************************************************
71  VecN b_;
72  VecN x_;
73 
74  //**********************************************************************************************
75 };
76 //*************************************************************************************************
77 
78 
79 
80 
81 //=================================================================================================
82 //
83 // UTILITY FUNCTIONS
84 //
85 //=================================================================================================
86 
87 //*************************************************************************************************
92 inline size_t LSE::size() const
93 {
94  return x_.size();
95 }
96 //*************************************************************************************************
97 
98 
99 //*************************************************************************************************
105 inline void LSE::project( size_t /*index*/ )
106 {}
107 //*************************************************************************************************
108 
109 
110 //*************************************************************************************************
116 inline real LSE::lbound( size_t /*index*/ ) const
117 {
118  return -inf;
119 }
120 //*************************************************************************************************
121 
122 
123 //*************************************************************************************************
129 inline real LSE::ubound( size_t /*index*/ ) const
130 {
131  return inf;
132 }
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
142 inline real LSE::residual( size_t index ) const
143 {
144  return ( A_ * x_ )[index] + b_[index];
145 }
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
154 inline real LSE::residual() const
155 {
156  real rmax( 0 );
157 
158  for( size_t i=0; i<size(); ++i ) {
159  rmax = max( rmax, std::fabs( residual( i ) ) );
160  }
161 
162  return rmax;
163 }
164 //*************************************************************************************************
165 
166 } // namespace blaze
167 
168 #endif