mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 15:33:26 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3df7d65ac1 | |||
| e1a1164136 | |||
| 23216279dc | |||
| 9e082f7dfa | |||
| 7750819e83 |
@@ -20,9 +20,10 @@ It provides the latest features, is highly customizable, has all for cheat devel
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**[<kbd> <br> Install <br> </kbd>][INSTALL]**
|
**[<kbd> <br> Install <br> </kbd>][INSTALL]**
|
||||||
**[<kbd> <br> Examples <br> </kbd>][EXAMPLES]**
|
**[<kbd> <br> Examples <br> </kbd>][EXAMPLES]**
|
||||||
**[<kbd> <br> Contribute <br> </kbd>][CONTRIBUTING]**
|
**[<kbd> <br> Contribute <br> </kbd>][CONTRIBUTING]**
|
||||||
|
**[<kbd> <br> Donate <br> </kbd>][SPONSOR]**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -125,3 +126,4 @@ for (auto ent: apex_sdk::EntityList::GetAllEntities())
|
|||||||
[INSTALL]: INSTALL.md
|
[INSTALL]: INSTALL.md
|
||||||
[CONTRIBUTING]: CONTRIBUTING.md
|
[CONTRIBUTING]: CONTRIBUTING.md
|
||||||
[EXAMPLES]: examples
|
[EXAMPLES]: examples
|
||||||
|
[SPONSOR]: https://boosty.to/orangecpp/purchase/3568644?ssource=DIRECT&share=subscription_link
|
||||||
|
|||||||
@@ -151,21 +151,39 @@ namespace omath
|
|||||||
};
|
};
|
||||||
} // namespace omath
|
} // namespace omath
|
||||||
|
|
||||||
template<class T, T MinV, T MaxV, omath::AngleFlags F, class CharT>
|
template<class T, T MinV, T MaxV, omath::AngleFlags F>
|
||||||
struct std::formatter<omath::Angle<T, MinV, MaxV, F>, CharT>
|
struct std::formatter<omath::Angle<T, MinV, MaxV, F>, char> // NOLINT(*-dcl58-cpp)
|
||||||
{
|
{
|
||||||
using AngleT = omath::Angle<T, MinV, MaxV, F>;
|
using AngleT = omath::Angle<T, MinV, MaxV, F>;
|
||||||
[[nodiscard]]
|
|
||||||
static constexpr auto parse(std::basic_format_parse_context<CharT>& ctx)
|
static constexpr auto parse(std::format_parse_context& ctx)
|
||||||
-> std::basic_format_parse_context<CharT>::iterator
|
|
||||||
{
|
{
|
||||||
return ctx.begin();
|
return ctx.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class FormatContext>
|
template<class FormatContext>
|
||||||
auto format(const AngleT& deg, FormatContext& ctx) const
|
auto format(const AngleT& a, FormatContext& ctx) const
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<typename FormatContext::char_type, char>)
|
static_assert(std::is_same_v<typename FormatContext::char_type, char>);
|
||||||
return std::format_to(ctx.out(), "{}deg", deg.as_degrees());
|
return std::format_to(ctx.out(), "{}deg", a.as_degrees());
|
||||||
return std::format_to(ctx.out(), L"{}deg", deg.as_degrees());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// wchar_t formatter
|
||||||
|
template<class T, T MinV, T MaxV, omath::AngleFlags F>
|
||||||
|
struct std::formatter<omath::Angle<T, MinV, MaxV, F>, wchar_t> // NOLINT(*-dcl58-cpp)
|
||||||
|
{
|
||||||
|
using AngleT = omath::Angle<T, MinV, MaxV, F>;
|
||||||
|
|
||||||
|
static constexpr auto parse(std::wformat_parse_context& ctx)
|
||||||
|
{
|
||||||
|
return ctx.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class FormatContext>
|
||||||
|
auto format(const AngleT& a, FormatContext& ctx) const
|
||||||
|
{
|
||||||
|
static_assert(std::is_same_v<typename FormatContext::char_type, wchar_t>);
|
||||||
|
return std::format_to(ctx.out(), L"{}deg", a.as_degrees());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -161,15 +161,16 @@ namespace omath
|
|||||||
#ifdef OMATH_USE_AVX2
|
#ifdef OMATH_USE_AVX2
|
||||||
if constexpr (StoreType == MatStoreType::ROW_MAJOR)
|
if constexpr (StoreType == MatStoreType::ROW_MAJOR)
|
||||||
return avx_multiply_row_major(other);
|
return avx_multiply_row_major(other);
|
||||||
if constexpr (StoreType == MatStoreType::COLUMN_MAJOR)
|
else if constexpr (StoreType == MatStoreType::COLUMN_MAJOR)
|
||||||
return avx_multiply_col_major(other);
|
return avx_multiply_col_major(other);
|
||||||
#else
|
#else
|
||||||
if constexpr (StoreType == MatStoreType::ROW_MAJOR)
|
if constexpr (StoreType == MatStoreType::ROW_MAJOR)
|
||||||
return cache_friendly_multiply_row_major(other);
|
return cache_friendly_multiply_row_major(other);
|
||||||
if constexpr (StoreType == MatStoreType::COLUMN_MAJOR)
|
else if constexpr (StoreType == MatStoreType::COLUMN_MAJOR)
|
||||||
return cache_friendly_multiply_col_major(other);
|
return cache_friendly_multiply_col_major(other);
|
||||||
#endif
|
#endif
|
||||||
std::unreachable();
|
else
|
||||||
|
std::unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Mat& operator*=(const Type& f) noexcept
|
constexpr Mat& operator*=(const Type& f) noexcept
|
||||||
@@ -377,12 +378,12 @@ namespace omath
|
|||||||
cache_friendly_multiply_row_major(const Mat<Columns, OtherColumns, Type, MatStoreType::ROW_MAJOR>& other) const
|
cache_friendly_multiply_row_major(const Mat<Columns, OtherColumns, Type, MatStoreType::ROW_MAJOR>& other) const
|
||||||
{
|
{
|
||||||
Mat<Rows, OtherColumns, Type, MatStoreType::ROW_MAJOR> result;
|
Mat<Rows, OtherColumns, Type, MatStoreType::ROW_MAJOR> result;
|
||||||
for (std::size_t i = 0; i < Rows; ++i)
|
for (std::size_t row_index = 0; row_index < Rows; ++row_index)
|
||||||
for (std::size_t k = 0; k < Columns; ++k)
|
for (std::size_t column_index = 0; column_index < Columns; ++column_index)
|
||||||
{
|
{
|
||||||
const Type aik = at(i, k);
|
const Type& current_number = at(row_index, column_index);
|
||||||
for (std::size_t j = 0; j < OtherColumns; ++j)
|
for (std::size_t other_column = 0; other_column < OtherColumns; ++other_column)
|
||||||
result.at(i, j) += aik * other.at(k, j);
|
result.at(row_index, other_column) += current_number * other.at(column_index, other_column);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -392,12 +393,12 @@ namespace omath
|
|||||||
const Mat<Columns, OtherColumns, Type, MatStoreType::COLUMN_MAJOR>& other) const
|
const Mat<Columns, OtherColumns, Type, MatStoreType::COLUMN_MAJOR>& other) const
|
||||||
{
|
{
|
||||||
Mat<Rows, OtherColumns, Type, MatStoreType::COLUMN_MAJOR> result;
|
Mat<Rows, OtherColumns, Type, MatStoreType::COLUMN_MAJOR> result;
|
||||||
for (std::size_t j = 0; j < OtherColumns; ++j)
|
for (std::size_t other_column = 0; other_column < OtherColumns; ++other_column)
|
||||||
for (std::size_t k = 0; k < Columns; ++k)
|
for (std::size_t column_index = 0; column_index < Columns; ++column_index)
|
||||||
{
|
{
|
||||||
const Type bkj = other.at(k, j);
|
const Type& current_number = other.at(column_index, other_column);
|
||||||
for (std::size_t i = 0; i < Rows; ++i)
|
for (std::size_t row_index = 0; row_index < Rows; ++row_index)
|
||||||
result.at(i, j) += at(i, k) * bkj;
|
result.at(row_index, other_column) += at(row_index, column_index) * current_number;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user