diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13f3b2b..94471d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,6 +102,10 @@ add_library(fennec STATIC
include/fennec/math/detail/__vector_traits.h
source/debug/assert_impl.cpp
+ include/fennec/math/detail/__math.h
+ include/fennec/lang/detail/__int.h
+ include/fennec/lang/detail/__stdlib.h
+ include/fennec/math/detail/__matrix.h
)
# add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled
diff --git a/include/fennec/lang/detail/__int.h b/include/fennec/lang/detail/__int.h
new file mode 100644
index 0000000..35c8170
--- /dev/null
+++ b/include/fennec/lang/detail/__int.h
@@ -0,0 +1,27 @@
+// =====================================================================================================================
+// fennec, a free and open source game engine
+// Copyright © 2025 Medusa Slockbower
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+// =====================================================================================================================
+
+#ifndef FENNEC_LANG_DETAIL_INT_H
+#define FENNEC_LANG_DETAIL_INT_H
+
+#pragma push_macro("__cplusplus")
+#undef __cplusplus
+#include
+#pragma pop_macro("__cplusplus")
+
+#endif // FENNEC_LANG_DETAIL_INT_H
diff --git a/include/fennec/lang/detail/__stdlib.h b/include/fennec/lang/detail/__stdlib.h
new file mode 100644
index 0000000..1545475
--- /dev/null
+++ b/include/fennec/lang/detail/__stdlib.h
@@ -0,0 +1,29 @@
+// =====================================================================================================================
+// fennec, a free and open source game engine
+// Copyright © 2025 Medusa Slockbower
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+// =====================================================================================================================
+
+#ifndef FENNEC_LANG_DETAIL_STDLIB_H
+#define FENNEC_LANG_DETAIL_STDLIB_H
+
+#pragma push_macro("__cplusplus")
+#undef __cplusplus
+extern "C" {
+#include
+}
+#pragma pop_macro("__cplusplus")
+
+#endif // FENNEC_LANG_DETAIL_STDLIB_H
diff --git a/include/fennec/lang/limits.h b/include/fennec/lang/limits.h
index deca9ed..89c7b13 100644
--- a/include/fennec/lang/limits.h
+++ b/include/fennec/lang/limits.h
@@ -201,8 +201,6 @@
///
///
-#include
-
#include
#include
diff --git a/include/fennec/lang/sequences.h b/include/fennec/lang/sequences.h
index 3a68b95..60930fd 100644
--- a/include/fennec/lang/sequences.h
+++ b/include/fennec/lang/sequences.h
@@ -203,23 +203,23 @@ template using concat_sequence_t
// Internal ============================================================================================================
-// Implementation for Generating an \ref integer_sequence
+// Implementation for Generating an integer_sequence
template struct make_integer_sequence : concat_sequence_t, make_integer_sequence_t>{};
-// Base Case of \f$N=0\f$
+// Base Case of N=0
template struct make_integer_sequence : integer_sequence {};
-// Base Case of \f$N=1\f$
+// Base Case of N=1
template struct make_integer_sequence : integer_sequence{};
-// Implementation for Generating an \ref integer_sequence
+// Implementation for Generating an index_sequence
template struct make_index_sequence : concat_sequence_t, make_index_sequence_t>{};
-// Base Case of \f$N=0\f$
+// Base Case of N=0
template<> struct make_index_sequence<0> : index_sequence<> {};
-// Base Case of \f$N=1\f$
+// Base Case of N=1
template<> struct make_index_sequence<1> : index_sequence<0>{};
diff --git a/include/fennec/lang/types.h b/include/fennec/lang/types.h
index 700bed6..78b0dd7 100644
--- a/include/fennec/lang/types.h
+++ b/include/fennec/lang/types.h
@@ -215,7 +215,7 @@
///
///
-#include
+#include
namespace fennec
{
diff --git a/include/fennec/lang/utility.h b/include/fennec/lang/utility.h
index 24da281..2c3023f 100644
--- a/include/fennec/lang/utility.h
+++ b/include/fennec/lang/utility.h
@@ -72,10 +72,10 @@ namespace fennec
/// \tparam T base type of the object
/// \param x reference to the object
/// \returns
-template constexpr T&& forward(remove_reference_t& x) noexcept { return x; }
+template constexpr T&& forward(remove_reference_t& x) noexcept { return static_cast(x); }
// specialization for T&&
-template constexpr T&& forward(remove_reference_t&& x) noexcept { return x; }
+template constexpr T&& forward(remove_reference_t&& x) noexcept { return static_cast(x); }
///
diff --git a/include/fennec/math/common.h b/include/fennec/math/common.h
index 19daa1b..34e5ffa 100644
--- a/include/fennec/math/common.h
+++ b/include/fennec/math/common.h
@@ -274,8 +274,7 @@
///
///
-
-#include
+#include
#include
@@ -357,7 +356,7 @@ constexpr vector sign(const vector& x)
/// \param x input value
template
constexpr genType floor(genType x)
- { return std::floor(x); }
+ { return ::floor(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -380,7 +379,7 @@ constexpr vector floor(const vector& x)
/// \param x input value
template
constexpr genType ceil(genType x)
- { return std::ceil(x); }
+ { return ::ceil(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -403,7 +402,7 @@ constexpr vector ceil(const vector& x)
///
/// \param x input value
template constexpr genType round(genType x)
- { return std::round(x); }
+ { return ::round(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -451,7 +450,7 @@ constexpr vector roundEven(const vector& x)
/// \param x input value
template
constexpr genType trunc(genType x)
- { return std::trunc(x); }
+ { return ::trunc(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -482,7 +481,7 @@ constexpr vector trunc(const vector& x)
/// \param x input value
template
constexpr genType fract(genType x)
- { return x - std::floor(x); }
+ { return x - ::floor(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -534,7 +533,7 @@ constexpr vector mod(const vector& x, const vector
/// \param i integral out
template
constexpr genType modf(genType x, genType& i)
- { return std::modf(x, &i); }
+ { return ::modf(x, &i); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -562,7 +561,7 @@ constexpr vector modf(const vector& x, vector requires(is_bool_v)
constexpr genBType isnan(genType x)
- { return std::isnan(x); }
+ { return ::isnan(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -585,7 +584,7 @@ constexpr vector isnan(const vector& x)
/// \param x input value
template requires(is_bool_v)
constexpr genBType isinf(genType x)
- { return std::isinf(x); }
+ { return ::isinf(x); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -684,7 +683,7 @@ constexpr vector uintBitsToFloat(const vector& x)
/// \param c the addend
template
constexpr genType fma(genType a, genType b, genType c)
- { return std::fma(a, b, c); }
+ { return ::fma(a, b, c); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -713,7 +712,7 @@ constexpr vector fma(const vector& a, const vector
/// \param exp The variable to store the exponent in
template requires(is_integral_v)
constexpr genType frexp(genType x, genIType& exp)
- { return std::frexp(x, &exp); }
+ { return ::frexp(x, &exp); }
// Vector Specializations ----------------------------------------------------------------------------------------------
@@ -744,7 +743,7 @@ constexpr vector frexp(const vector& x, vector requires(is_integral_v)
constexpr genType ldexp(genType x, genIType exp)
- { return std::ldexp(x, exp); }
+ { return ::ldexp(x, exp); }
// Vector Specializations ----------------------------------------------------------------------------------------------
diff --git a/include/fennec/math/detail/__fwd.h b/include/fennec/math/detail/__fwd.h
index 5b3e18f..694a300 100644
--- a/include/fennec/math/detail/__fwd.h
+++ b/include/fennec/math/detail/__fwd.h
@@ -31,7 +31,7 @@ template struct matrix; //
template using vec
= decltype(detail::__gen_vector(make_index_sequence{})); // Gets the type returned by this function
-template using mat
+template using mat
= decltype(detail::__gen_matrix(make_index_sequence{})); // Gets the type returned by this function
}
diff --git a/include/fennec/math/detail/__math.h b/include/fennec/math/detail/__math.h
new file mode 100644
index 0000000..88349e0
--- /dev/null
+++ b/include/fennec/math/detail/__math.h
@@ -0,0 +1,57 @@
+// =====================================================================================================================
+// fennec, a free and open source game engine
+// Copyright © 2025 Medusa Slockbower
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+// =====================================================================================================================
+
+#ifndef FENNEC_MATH_DETAIL_MATH_H
+#define FENNEC_MATH_DETAIL_MATH_H
+
+#pragma push_macro("__cplusplus")
+#undef __cplusplus
+#include
+#pragma pop_macro("__cplusplus")
+
+#undef div
+#undef acos
+#undef asin
+#undef atan
+#undef atan2
+#undef ceil
+#undef cos
+#undef cosh
+#undef exp
+#undef fabs
+#undef floor
+#undef fmod
+#undef frexp
+#undef ldexp
+#undef log
+#undef log10
+#undef modf
+#undef pow
+#undef sin
+#undef sinh
+#undef sqrt
+#undef tan
+#undef tanh
+#undef fpclassify
+#undef signbit
+#undef isfinite
+#undef isnormal
+#undef isnan
+#undef isinf
+
+#endif // FENNEC_MATH_DETAIL_MATH_H
diff --git a/include/fennec/math/detail/__matrix.h b/include/fennec/math/detail/__matrix.h
new file mode 100644
index 0000000..c41c80b
--- /dev/null
+++ b/include/fennec/math/detail/__matrix.h
@@ -0,0 +1,147 @@
+// =====================================================================================================================
+// fennec, a free and open source game engine
+// Copyright © 2025 Medusa Slockbower
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+// =====================================================================================================================
+
+#ifndef FENNEC_MATH_DETAIL_MATRIX_H
+#define FENNEC_MATH_DETAIL_MATRIX_H
+
+#include
+
+namespace fennec
+{
+
+// specialization for mat2
+template requires(rows == 2 && sizeof...(cols) == 2)
+constexpr scalar determinant(const matrix& m)
+{
+ return m[0][0] * m[1][1] - m[1][0] * m[0][1];
+}
+
+// specialization for mat3
+template requires(rows == 3 && sizeof...(cols) == 3)
+constexpr scalar determinant(const matrix& m)
+{
+ // Cofactor expansion over first column, better for cache locality than the first row
+ return m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
+ - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+ + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
+}
+
+// specialization for mat4
+template requires(rows == 4 && sizeof...(cols) == 4)
+constexpr scalar determinant(const matrix& m)
+{
+ // Cofactor expansion over the first column, better for cache locality than the first row
+ scalar d00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
+ scalar d01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
+ scalar d02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
+ scalar d03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
+ scalar d04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
+ scalar d05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
+
+ scalar f0 = +(m[1][1]*d00 - m[1][2]*d01 + m[1][3]*d02);
+ scalar f1 = -(m[1][0]*d00 - m[1][2]*d03 + m[1][3]*d04);
+ scalar f2 = +(m[1][0]*d01 - m[1][1]*d03 + m[1][3]*d05);
+ scalar f3 = -(m[1][0]*d02 - m[1][1]*d04 + m[1][2]*d05);
+
+ return m[0][0]*f0 + m[0][1]*f1 + m[0][2]*f2 + m[0][3]*f3;
+}
+
+
+// specialization for mat2
+template requires(rows == 2 && sizeof...(cols) == 2)
+constexpr matrix inverse(const matrix& m)
+{
+ scalar di = scalar(1) / fennec::determinant(m);
+ return matrix(
+ m[1][1] * di, -m[0][1] * di, -m[1][0] * di, m[0][0] * di
+ );
+}
+
+// specialization for mat3
+template requires(rows == 3 && sizeof...(cols) == 3)
+constexpr matrix inverse(const matrix& m)
+{
+ scalar di = scalar(1) / fennec::determinant(m);
+
+ matrix i(
+ (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * di
+ , -(m[0][1] * m[2][2] - m[2][1] * m[0][2]) * di
+ , (m[0][1] * m[1][2] - m[1][1] * m[0][2]) * di
+
+ , -(m[1][0] * m[2][2] - m[2][0] * m[1][2]) * di
+ , (m[0][0] * m[2][2] - m[2][0] * m[0][2]) * di
+ , -(m[0][0] * m[1][2] - m[1][0] * m[0][2]) * di
+
+ , (m[1][0] * m[2][1] - m[2][0] * m[1][1]) * di
+ , -(m[0][0] * m[2][1] - m[2][0] * m[0][1]) * di
+ , (m[0][0] * m[1][1] - m[1][0] * m[0][1]) * di
+ );
+
+ return i;
+}
+
+template requires(rows == 4 && sizeof...(cols) == 4)
+constexpr matrix inverse(const matrix& m)
+{
+ scalar s0 = m[0][0] * m[1][1] - m[1][0] * m[0][1];
+ scalar s1 = m[0][0] * m[1][2] - m[1][0] * m[0][2];
+ scalar s2 = m[0][0] * m[1][3] - m[1][0] * m[0][3];
+ scalar s3 = m[0][1] * m[1][2] - m[1][1] * m[0][2];
+ scalar s4 = m[0][1] * m[1][3] - m[1][1] * m[0][3];
+ scalar s5 = m[0][2] * m[1][3] - m[1][2] * m[0][3];
+
+ scalar c5 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
+ scalar c4 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
+ scalar c3 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
+ scalar c2 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
+ scalar c1 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
+ scalar c0 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
+
+ // Should check for 0 determinant
+ scalar invdet = (s0 * c5 - s1 * c4 + s2 * c3 + s3 * c2 - s4 * c1 + s5 * c0);
+ invdet = invdet ? 1.0 / invdet : 0;
+
+ matrix i(
+ ( m[1][1] * c5 - m[1][2] * c4 + m[1][3] * c3) * invdet
+ , (-m[0][1] * c5 + m[0][2] * c4 - m[0][3] * c3) * invdet
+ , ( m[3][1] * s5 - m[3][2] * s4 + m[3][3] * s3) * invdet
+ , (-m[2][1] * s5 + m[2][2] * s4 - m[2][3] * s3) * invdet
+
+ , (-m[1][0] * c5 + m[1][2] * c2 - m[1][3] * c1) * invdet
+ , ( m[0][0] * c5 - m[0][2] * c2 + m[0][3] * c1) * invdet
+ , (-m[3][0] * s5 + m[3][2] * s2 - m[3][3] * s1) * invdet
+ , ( m[2][0] * s5 - m[2][2] * s2 + m[2][3] * s1) * invdet
+
+ , ( m[1][0] * c4 - m[1][1] * c2 + m[1][3] * c0) * invdet
+ , (-m[0][0] * c4 + m[0][1] * c2 - m[0][3] * c0) * invdet
+ , ( m[3][0] * s4 - m[3][1] * s2 + m[3][3] * s0) * invdet
+ , (-m[2][0] * s4 + m[2][1] * s2 - m[2][3] * s0) * invdet
+
+ , (-m[1][0] * c3 + m[1][1] * c1 - m[1][2] * c0) * invdet
+ , ( m[0][0] * c3 - m[0][1] * c1 + m[0][2] * c0) * invdet
+ , (-m[3][0] * s3 + m[3][1] * s1 - m[3][2] * s0) * invdet
+ , ( m[2][0] * s3 - m[2][1] * s1 + m[2][2] * s0) * invdet
+ );
+
+ return i;
+}
+
+}
+
+
+#endif // FENNEC_MATH_DETAIL_MATRIX_H
diff --git a/include/fennec/math/exponential.h b/include/fennec/math/exponential.h
index 43f31f8..dc70083 100644
--- a/include/fennec/math/exponential.h
+++ b/include/fennec/math/exponential.h
@@ -32,11 +32,6 @@
#ifndef FENNEC_MATH_EXPONENTIAL_H
#define FENNEC_MATH_EXPONENTIAL_H
-#pragma push_macro("__cplusplus")
-#undef __cplusplus
-#include
-#pragma pop_macro("__cplusplus")
-
///
///
///
@@ -93,6 +88,8 @@
///
///
+#include
+
namespace fennec
{
@@ -206,7 +203,7 @@ template constexpr genType sqrt(const vector constexpr genType inversesqrt(genType x)
- { return 1.0f / std::sqrt(x); }
+ { return 1.0f / ::sqrt(x); }
template
constexpr vector inversesqrt(const vector& x)
diff --git a/include/fennec/math/geometric.h b/include/fennec/math/geometric.h
index a9b250c..7eaf13d 100644
--- a/include/fennec/math/geometric.h
+++ b/include/fennec/math/geometric.h
@@ -32,9 +32,6 @@
#ifndef FENNEC_MATH_GEOMETRIC_H
#define FENNEC_MATH_GEOMETRIC_H
-#include
-#include
-
///
///
@@ -111,6 +108,9 @@
///
///
+#include
+#include
+
namespace fennec
{
diff --git a/include/fennec/math/matrix.h b/include/fennec/math/matrix.h
index f2c9db1..f562db3 100644
--- a/include/fennec/math/matrix.h
+++ b/include/fennec/math/matrix.h
@@ -44,6 +44,7 @@
///
#include
+#include
#include
@@ -56,9 +57,6 @@ namespace fennec
///
/// \brief returns a **copy** of the column \f$i\f$ of matrix \f$m\f$
-/// \tparam scalar the base scalar type
-/// \tparam rows number of rows in the matrix
-/// \tparam cols indices of the columns in the matrix
/// \param m the matrix
/// \param i the index of the row
/// \returns a **copy** of the column at index \f$i\f$
@@ -69,9 +67,6 @@ constexpr vec column(const matrix& m, size_
///
/// \brief returns a **copy** of the row \f$i\f$ of matrix \f$m\f$
-/// \tparam scalar the base scalar type
-/// \tparam rows number of rows in the matrix
-/// \tparam cols indices of the columns in the matrix
/// \param m the matrix
/// \param i the index of the row
/// \returns a **copy** of the row at index \f$i\f$
@@ -80,7 +75,8 @@ constexpr vec row(const matrix&
{ return vec(m[cols][i]...); }
-template using tmat2x2 = mat; ///< helper for creating 2x2 matrices of the specified type.
+template
+using tmat2x2 = mat; ///< helper for creating 2x2 matrices of the specified type.
template using tmat2x3 = mat; ///< helper for creating 2x3 matrices of the specified type.
template using tmat2x4 = mat; ///< helper for creating 2x4 matrices of the specified type.
template using tmat3x2 = mat; ///< helper for creating 3x2 matrices of the specified type.
@@ -92,7 +88,7 @@ template using tmat4x4 = mat; ///< helper for c
using mat2 = tmat2x2; ///< Specification for glsl float matrices
using mat3 = tmat3x3; ///< Specification for glsl float matrices
-using mat4 = tmat3x3; ///< Specification for glsl float matrices
+using mat4 = tmat4x4; ///< Specification for glsl float matrices
using mat2x2 = tmat2x2; ///< Specification for sized glsl float matrices
using mat2x3 = tmat2x3; ///< Specification for sized glsl float matrices
@@ -120,6 +116,70 @@ using dmat4x4 = tmat4x4; ///< Specification for size glsl double matri
///
+/// \brief Multiply matrix \$x\f$ by matrix \f$y\f$ component-wise.
+/// \details Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j].
+/// Note: to get linear algebraic matrix multiplication, use
+/// the multiply operator (*)
+/// \param x the first matrix
+/// \param y the second matrix
+/// \returns the resulting product in a matrix of the same size and base type
+template
+constexpr matrix matrixCompMult(const matrix& x, const matrix& y) noexcept
+{ return matrix(x[cols] * y[cols] ...); }
+
+///
+/// \brief Performs a linear algebraic multiply, multiplying \f$c\f$ by the components of \f$r\f$, producing a matrix.
+///
+/// \details Treats the first parameter \f$c\f$ as a column vector (matrix
+/// with one column) and the second parameter \f$r\f$ as a row
+/// vector (matrix with one row) and does a linear algebraic
+/// matrix multiply \f$c \cross r\f$, yielding a matrix whose number of
+/// rows is the number of components in \f$c\f$ and whose
+/// number of columns is the number of components in \f$r\f$.
+/// \param c the column vector
+/// \param r the row vector
+/// \returns the resulting matrix produced by the linear algebraic product
+template
+constexpr matrix outerProduct(const vector& c, const vector& r) noexcept
+{
+ return matrix(
+ c * r[s1]...
+ );
+}
+
+///
+/// \brief get the transpose of \f$m\f$
+/// \param m the matrix to transpose
+/// \returns a matrix that is the transpose of \f$m\f$
+/// \details The input matrix m is not modified.
+template
+constexpr mat transpose(const matrix& m) noexcept
+{
+ return [m](index_sequence) -> mat {
+ return mat(fennec::row(m, i) ...);
+ }(make_index_sequence{});
+}
+
+///
+/// \brief Returns the determinant of m.
+/// \param m the matrix
+/// \returns the determinant of m.
+template
+constexpr scalar determinant(const matrix&) noexcept
+{
+ // ReSharper disable once CppStaticAssertFailure
+ static_assert(false, "implementation undefined");
+ return 0;
+}
+
+template
+constexpr matrix inverse(const matrix&) noexcept
+{
+ // ReSharper disable once CppStaticAssertFailure
+ static_assert(false, "implementation undefined");
+ return 1;
+}
+
///
/// \brief
/// \tparam ScalarT
@@ -196,7 +256,6 @@ struct matrix
constexpr matrix(const matrix_t& mat)
: data{ mat.data } {}
-
///
/// \brief move constructor
///
@@ -232,7 +291,7 @@ struct matrix
/// \param args
template requires(total_component_count_v == num_components)
constexpr matrix(ArgsT&&...args)
- { matrix::__construct(std::forward(args)...); }
+ { matrix::__construct(fennec::forward(args)...); }
/// @}
@@ -279,12 +338,12 @@ struct matrix
/// \param i the index
/// \returns the column at index \f$i\f$
constexpr const column_t& operator[](size_t i) const
- { assert(i < rows); return data[i]; }
+ { assert(i < columns); return data[i]; }
///
/// \copydetails matrix::operator()(size_t, size_t) const
constexpr scalar_t& operator()(size_t i, size_t j)
- { assert(i < rows && j < columns); return data[i][j]; }
+ { assert(i < columns && j < rows); return data[i][j]; }
///
/// \brief returns the cell in row \p j column \p i
@@ -292,7 +351,7 @@ struct matrix
/// \param j the row
/// \returns the cell at the specified index.
constexpr scalar_t operator()(size_t i, size_t j) const
- { assert(i < rows && j < columns); return data[i][j]; }
+ { assert(i < columns && j < rows); return data[i][j]; }
/// @}
@@ -589,8 +648,11 @@ struct matrix
/// \param lhs the rows to multiply with
/// \param rhs the columns to multiply with
constexpr friend matrix_t operator*(const matrix_t& lhs, const transpose_t& rhs)
- { return [lhs, rhs](index_sequence) -> matrix_t
- { return matrix_t(rhs * fennec::row(lhs, i)...); }(make_index_sequence{}); }
+ {
+ return [lhs, rhs](index_sequence) -> matrix_t {
+ return matrix_t(rhs * fennec::row(lhs, i)...);
+ }(make_index_sequence{});
+ }
/// @}
@@ -606,26 +668,33 @@ private:
template
constexpr void __construct(HeadT&& head, ArgsT&&...args)
{
- matrix::__insert(head);
+ matrix::__insert(head);
matrix::__construct>(std::forward(args)...);
}
template
constexpr void __insert(scalar_t s)
- { data[i0 / columns][i0 % columns] = s; }
+ { data[i0 / rows][i0 % rows] = s; }
template requires(is_arithmetic_v)
constexpr void __insert(OScalarT s)
- { data[i0 / columns][i0 % columns] = scalar_t(s); }
+ { data[i0 / rows][i0 % rows] = scalar_t(s); }
template
constexpr void __insert(const vector& v)
{ (matrix::__insert(v[i]), ...); }
+ template
+ constexpr void __insert(const vector& v)
+ { (matrix::__insert(v[i]), ...); }
+
};
+
+// Internal ============================================================================================================
+
}
diff --git a/include/fennec/math/relational.h b/include/fennec/math/relational.h
index c5700bb..b735319 100644
--- a/include/fennec/math/relational.h
+++ b/include/fennec/math/relational.h
@@ -31,8 +31,6 @@
#ifndef FENNEC_MATH_RELATIONAL_H
#define FENNEC_MATH_RELATIONAL_H
-#include
-
///
/// \page fennec_math_relational Relational
///
@@ -114,7 +112,7 @@
///
///
-// TODO: Document
+#include
namespace fennec
{
diff --git a/include/fennec/math/scalar.h b/include/fennec/math/scalar.h
index 29f8395..b4e2136 100644
--- a/include/fennec/math/scalar.h
+++ b/include/fennec/math/scalar.h
@@ -31,8 +31,6 @@
#ifndef FENNEC_MATH_SCALAR_H
#define FENNEC_MATH_SCALAR_H
-#include
-
///
///
///
@@ -59,6 +57,8 @@
///
///
+#include
+
#include
#include
diff --git a/include/fennec/math/swizzle.h b/include/fennec/math/swizzle.h
index 23c75c4..adf3745 100644
--- a/include/fennec/math/swizzle.h
+++ b/include/fennec/math/swizzle.h
@@ -42,6 +42,7 @@
///
#include
+
#include
namespace fennec
diff --git a/include/fennec/math/trigonometric.h b/include/fennec/math/trigonometric.h
index 6e1206a..0d4a9db 100644
--- a/include/fennec/math/trigonometric.h
+++ b/include/fennec/math/trigonometric.h
@@ -147,7 +147,7 @@
///
///
-#include
+#include
namespace fennec
{
@@ -209,7 +209,7 @@ constexpr vector degrees(const vector& radians)
/// \param x the angle \f$\theta\f$ in \f$radians\f$
template
constexpr genType sin(genType x)
- { return std::sin(x); }
+ { return ::sin(x); }
template
constexpr vector sin(const vector& x)
@@ -226,7 +226,7 @@ constexpr vector sin(const vector& x)
/// \param x the angle \f$\theta\f$ in \f$radians\f$
template
constexpr genType cos(genType x)
- { return std::cos(x); }
+ { return ::cos(x); }
template
constexpr vector cos(const vector& x)
@@ -243,7 +243,7 @@ constexpr vector cos(const vector& x)
/// \param x The Angle \f$\theta\f$ in \f$radians\f$
template
constexpr genType tan(genType x)
- { return std::tan(x); }
+ { return ::tan(x); }
template
constexpr vector tan(const vector& x)
@@ -267,7 +267,7 @@ constexpr vector tan(const vector& x)
/// \param x The Sine Value produced by \f$\theta\f$
template
constexpr genType asin(genType x)
- { return std::asin(x); }
+ { return ::asin(x); }
template
constexpr vector asin(const vector& x)
@@ -285,7 +285,7 @@ constexpr vector asin(const vector& x)
/// \param x The Cosine Value produced by \f$\theta\f$
template
constexpr genType acos(genType x)
- { return std::acos(x); }
+ { return ::acos(x); }
template
constexpr vector acos(const vector& x)
@@ -303,7 +303,7 @@ constexpr vector acos(const vector& x)
/// \param y_over_x The Cosine Value produced by \f$\theta\f$
template
constexpr genType atan(genType y_over_x)
- { return std::atan(y_over_x); }
+ { return ::atan(y_over_x); }
template
constexpr vector atan(const vector& y_over_x)
@@ -322,7 +322,7 @@ constexpr vector atan(const vector& y_over_x)
/// \param x The Cosine Value produced by \f$\theta\f$
template
constexpr genType atan(genType y, genType x)
- { return std::atan2(y, x); }
+ { return ::atan2(y, x); }
template
constexpr vector atan(const vector& y, const vector& x)
@@ -345,7 +345,7 @@ constexpr vector atan(const vector& y, const vecto
/// \param x The Hyperbolic Angle \f$\alpha\f$
template
constexpr genType sinh(genType x)
- { return std::sinh(x); }
+ { return ::sinh(x); }
template
constexpr vector sinh(const vector& x)
@@ -360,7 +360,7 @@ constexpr vector sinh(const vector& x)
/// \param x The Hyperbolic Angle \f$\alpha\f$
template
constexpr genType cosh(genType x)
- { return std::cosh(x); }
+ { return ::cosh(x); }
template
constexpr vector cosh(const vector& x)
@@ -375,7 +375,7 @@ constexpr vector cosh(const vector& x)
/// \param x The Hyperbolic Angle \f$\alpha\f$
template
constexpr genType tanh(genType x)
- { return std::tanh(x); }
+ { return ::tanh(x); }
template
constexpr vector tanh(const vector& x)
@@ -396,7 +396,7 @@ constexpr vector tanh(const vector