make vectors actually have bipolar function

v2
Brett 2024-10-05 01:13:24 -04:00
parent dafbe6ea8b
commit ce4e1807de
3 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 2.1.0) set(BLT_VERSION 2.1.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -168,10 +168,7 @@ namespace blt
{ {
matrix_t copy = *this; matrix_t copy = *this;
for (auto& v : copy.data) for (auto& v : copy.data)
{ v = v.bipolar();
for (auto& d : blt::iterate(v.begin(), v.end()))
d = d >= 0 ? 1 : -1;
}
return copy; return copy;
} }

View File

@ -134,6 +134,14 @@ namespace blt
return copy; return copy;
} }
[[nodiscard]] constexpr inline vec<T, size> bipolar() const
{
auto copy = *this;
for (auto& v : copy.elements)
v = v >= 0 ? 1 : -1;
return copy;
}
[[nodiscard]] constexpr inline T magnitude() const [[nodiscard]] constexpr inline T magnitude() const
{ {
T total = 0; T total = 0;