/
uzer_007
/
reindexer
Обзор
Документация
Войти
/
uzer_007
/
reindexer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
cpp_src/tools/normalize.h
39 строк
1 KB
madschemas
Update to version v5.12.0
20 мар 2026, 08:17
20 мар 2026, 08:17
2eef2e6
Код
Авторство
О чём код?
#pragma once #include <cstdint> #include <cstring> #include <memory> #include "estl/defines.h" #include "tools/assertrx.h" namespace reindexer::ann { namespace impl { extern float (*normalizeVectorPtr)(float*, int32_t) noexcept; extern float (*calculateL2ModulePtr)(const float*, int32_t) noexcept; } // namespace impl RX_ALWAYS_INLINE float CalculateL2Module(const float* x, int32_t d) noexcept { return impl::calculateL2ModulePtr(x, d); } RX_ALWAYS_INLINE float NormalizeVector(float* x, int32_t d) noexcept { return impl::normalizeVectorPtr(x, d); } RX_ALWAYS_INLINE float NormalizeCopyVector(const float* x, int32_t d, float* out) noexcept { assertrx_dbg(d >= 0); std::memcpy(out, x, d * sizeof(float)); return impl::normalizeVectorPtr(out, d); } RX_ALWAYS_INLINE std::unique_ptr<float[]> NormalizeCopyVector(const float* x, int32_t d) noexcept { auto ret = std::make_unique<float[]>(d); std::ignore = NormalizeCopyVector(x, d, ret.get()); return ret; } RX_ALWAYS_INLINE std::unique_ptr<float[]> NormalizeCopyVectors(const float* x, size_t n, int32_t d) noexcept { assertrx_dbg(d >= 0); auto ret = std::make_unique<float[]>(n * d); std::memcpy(ret.get(), x, n * d * sizeof(float)); auto ptr = ret.get(); for (size_t i = 0; i < n; ++i, ptr += d) { impl::normalizeVectorPtr(ptr, d); } return ret; } } // namespace reindexer::ann