AFF --- A container for numbers (array) by Friederich and Forbriger.
rms.h
Go to the documentation of this file.
1
37
// include guard
38
#ifndef AFF_RMS_H_VERSION
39
40
#define AFF_RMS_H_VERSION \
41
"AFF_RMS_H V1.2"
42
43
#include<cmath>
44
#include<
aff/lib/collector.h
>
45
46
namespace
aff
{
47
48
namespace
func {
49
50
namespace
util {
51
59
template
<
class
C>
60
class
Extractrms
{
61
typedef
typename
C::Tcoc
Tcont
;
62
typedef
typename
C::Tvalue
Tvalue
;
63
public
:
64
typedef
Tvalue
Tretval
;
66
Extractrms
(
const
Tcont
& c):
Msum
(0),
Mn
(0) { }
68
void
operator()
(
const
Tvalue
& v) {
Msum
+=(v*v); ++
Mn
; }
70
Tretval
result
()
const
{
return
(std::sqrt(
Msum
/
Tvalue
(
Mn
))); }
71
private
:
72
Tvalue
Msum
;
73
int
Mn
;
74
};
// class Extractrms
75
76
}
// namespace util
77
78
/*----------------------------------------------------------------------*/
79
90
template
<
class
C>
91
typename
C::Tvalue
rms
(
const
C& c)
92
{
93
return
(aff::func::util::collect<C, aff::func::util::Extractrms>(c));
94
}
// rms()
95
96
}
// namespace func
97
98
}
// namespace aff
99
100
#endif // AFF_RMS_H_VERSION (includeguard)
101
102
/* ----- END OF rms.h ----- */
aff
Root namespace of library.
Definition:
array.h:148
collector.h
collect values (prototypes)
aff::func::util::Extractrms::Mn
int Mn
Definition:
rms.h:73
aff::func::util::Extractrms::operator()
void operator()(const Tvalue &v)
collect another value
Definition:
rms.h:68
aff::func::rms
C::Tvalue rms(const C &c)
Definition:
rms.h:91
aff::func::util::Extractrms
Definition:
rms.h:60
aff::func::util::Extractrms::Tvalue
C::Tvalue Tvalue
Definition:
rms.h:62
aff::func::util::Extractrms::Tcont
C::Tcoc Tcont
Definition:
rms.h:61
aff::func::util::Extractrms::Tretval
Tvalue Tretval
Definition:
rms.h:64
aff::func::util::Extractrms::Extractrms
Extractrms(const Tcont &c)
initialize member data
Definition:
rms.h:66
aff::func::util::Extractrms::result
Tretval result() const
return result of operation
Definition:
rms.h:70
aff::func::util::Extractrms::Msum
Tvalue Msum
Definition:
rms.h:72
functions
rms.h
Generated on Mon Aug 21 2023 17:36:08 for AFF --- A container for numbers (array) by Friederich and Forbriger. by
1.8.14