Sync public subset from Flux (private)
This commit is contained in:
31
include/numerics/mean.h
Normal file
31
include/numerics/mean.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef _mean_n_
|
||||
#define _mean_n_
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
T mean(utils::Vector<T>& A) {
|
||||
|
||||
T mean(T{0});
|
||||
|
||||
const uint64_t rows = A.rows();
|
||||
const uint64_t cols = A.cols();
|
||||
|
||||
|
||||
for (uint64_t i = 0; i < cols; ++i) {
|
||||
for (uint64_t j = 0; j < rows; ++j) {
|
||||
mean += A(j, i);
|
||||
}
|
||||
}
|
||||
mean /= (static_cast<T>(rows)* static_cast<T>(cols));
|
||||
return mean;
|
||||
}
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
#endif // _mean_n_
|
||||
Reference in New Issue
Block a user