MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / horizontal_avg

Function horizontal_avg

include/rabitqlib/utils/tools.hpp:116–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115template <typename T>
116std::vector<T> horizontal_avg(const std::vector<std::vector<T>>& data) {
117 size_t rows = data.size();
118 size_t cols = data[0].size();
119
120 std::vector<T> avg(cols, 0);
121 for (auto& row : data) {
122 for (size_t j = 0; j < cols; ++j) {
123 avg[j] += row[j];
124 }
125 }
126
127 for (size_t j = 0; j < cols; ++j) {
128 avg[j] /= rows;
129 }
130
131 return avg;
132}
133} // namespace rabitqlib

Callers 3

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected