support vectors with 1/(vec<T>)

v1
Brett 2024-05-01 21:25:29 -04:00
parent 8a5794cfee
commit 37da0bd76d
2 changed files with 18 additions and 9 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.16.18) set(BLT_VERSION 0.16.19)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -292,20 +292,20 @@ namespace blt
} }
template<typename T, blt::u32 size> template<typename T, blt::u32 size>
inline constexpr vec<T, size> operator+(const vec<T, size>& left, T f) inline constexpr vec<T, size> operator+(const vec<T, size>& left, T right)
{ {
vec<T, size> initializer{}; vec<T, size> initializer{};
for (blt::u32 i = 0; i < size; i++) for (blt::u32 i = 0; i < size; i++)
initializer[i] = left[i] + f; initializer[i] = left[i] + right;
return initializer; return initializer;
} }
template<typename T, blt::u32 size> template<typename T, blt::u32 size>
inline constexpr vec<T, size> operator-(const vec<T, size>& left, T f) inline constexpr vec<T, size> operator-(const vec<T, size>& left, T right)
{ {
vec<T, size> initializer{}; vec<T, size> initializer{};
for (blt::u32 i = 0; i < size; i++) for (blt::u32 i = 0; i < size; i++)
initializer[i] = left[i] + f; initializer[i] = left[i] + right;
return initializer; return initializer;
} }
@ -337,11 +337,11 @@ namespace blt
} }
template<typename T, blt::u32 size> template<typename T, blt::u32 size>
inline constexpr vec<T, size> operator*(const vec<T, size>& left, T f) inline constexpr vec<T, size> operator*(const vec<T, size>& left, T right)
{ {
vec<T, size> initializer{}; vec<T, size> initializer{};
for (blt::u32 i = 0; i < size; i++) for (blt::u32 i = 0; i < size; i++)
initializer[i] = left[i] * f; initializer[i] = left[i] * right;
return initializer; return initializer;
} }
@ -355,11 +355,20 @@ namespace blt
} }
template<typename T, blt::u32 size> template<typename T, blt::u32 size>
inline constexpr vec<T, size> operator/(const vec<T, size>& left, T f) inline constexpr vec<T, size> operator/(const vec<T, size>& left, T right)
{ {
vec<T, size> initializer{}; vec<T, size> initializer{};
for (blt::u32 i = 0; i < size; i++) for (blt::u32 i = 0; i < size; i++)
initializer[i] = left[i] / f; initializer[i] = left[i] / right;
return initializer;
}
template<typename T, blt::u32 size>
inline constexpr vec<T, size> operator/(T left, const vec<T, size>& right)
{
vec<T, size> initializer{};
for (blt::u32 i = 0; i < size; i++)
initializer[i] = left / right[i];
return initializer; return initializer;
} }