-Removed lambda expansions due to gcc generating call instructions
This commit is contained in:
@@ -120,15 +120,16 @@ struct array
|
||||
///
|
||||
/// \brief
|
||||
friend constexpr bool_t operator==(const array& lhs, const array& rhs)
|
||||
{ return [lhs, rhs]<size_t...i>(index_sequence<i...>) -> bool_t // Lambda Declaration, Creates Indices at Compile Time
|
||||
{ return ((lhs[i] == rhs[i]) && ...); }(make_index_sequence<ElemV>{}); } // Lambda Implementation,
|
||||
{ return array::__compare(lhs, rhs, make_index_sequence<ElemV>{}); }
|
||||
|
||||
friend constexpr bool_t operator!=(const array& lhs, const array& rhs)
|
||||
{ return [lhs, rhs]<size_t...i>(index_sequence<i...>) -> bool_t
|
||||
{ return ((lhs[i] != rhs[i]) || ...); }(make_index_sequence<ElemV>{}); }
|
||||
{ return not array::__compare(lhs, rhs, make_index_sequence<ElemV>{}); }
|
||||
|
||||
/// @}
|
||||
|
||||
private:
|
||||
template<size_t...i>
|
||||
static bool __compare(const array& lhs, const array& rhs, index_sequence<i...>) { return ((lhs[i] == rhs[i]) && ...); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
using assert_handler = void (*)(const char *, const char *, int , const char *);
|
||||
|
||||
extern void __assert_impl(const char* expression, const char* file, int line, const char* function);
|
||||
|
||||
#define assert(expression) if(not(expression)) { __assert_impl(#expression, __FILE__, __LINE__, __PRETTY_FUNCTION__); }
|
||||
|
||||
#endif // FENNEC_LANG_ASSERT_H
|
||||
|
||||
@@ -561,7 +561,7 @@ constexpr vector<genType, i...> modf(const vector<genType, i...>& x, vector<genT
|
||||
/// \param x input value
|
||||
template<typename genType, typename genBType = bool_t> requires(is_bool_v<genBType>)
|
||||
constexpr genBType isnan(genType x)
|
||||
{ return ::isnan(x); }
|
||||
{ return ::isnanf(x); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
@@ -584,7 +584,7 @@ constexpr vector<genBType, i...> isnan(const vector<genType, i...>& x)
|
||||
/// \param x input value
|
||||
template<typename genType, typename genBType = bool_t> requires(is_bool_v<genBType>)
|
||||
constexpr genBType isinf(genType x)
|
||||
{ return ::isinf(x); }
|
||||
{ return ::isinff(x); }
|
||||
|
||||
|
||||
// Vector Specializations ----------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -141,6 +141,7 @@ constexpr matrix<scalar, rows, cols...> inverse(const matrix<scalar, rows, cols.
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
///
|
||||
|
||||
#include <fennec/math/vector.h>
|
||||
#include <fennec/math/common.h>
|
||||
#include <fennec/math/exponential.h>
|
||||
|
||||
namespace fennec
|
||||
|
||||
@@ -154,11 +154,7 @@ constexpr matrix<scalar, sizeof...(s0), s1...> outerProduct(const vector<scalar,
|
||||
/// \details The input matrix m is not modified.
|
||||
template<typename scalar, size_t rows, size_t...cols>
|
||||
constexpr mat<scalar, rows, sizeof...(cols)> transpose(const matrix<scalar, rows, cols...>& m) noexcept
|
||||
{
|
||||
return [m]<size_t...i>(index_sequence<i...>) -> mat<scalar, rows, sizeof...(cols)> {
|
||||
return mat<scalar, rows, sizeof...(cols)>(fennec::row(m, i) ...);
|
||||
}(make_index_sequence<rows>{});
|
||||
}
|
||||
{ return mat<scalar, rows, sizeof...(cols)>::transpose(m); }
|
||||
|
||||
///
|
||||
/// \brief Returns the determinant of m.
|
||||
@@ -225,7 +221,7 @@ struct matrix
|
||||
|
||||
///
|
||||
/// \brief alias for the transpose matrix type
|
||||
using transpose_t = mat<ScalarT, columns, rows>;
|
||||
using transpose_t = mat<ScalarT, rows, columns>;
|
||||
|
||||
|
||||
///
|
||||
@@ -244,8 +240,7 @@ struct matrix
|
||||
/// \brief default constructor, initializes elements with 0
|
||||
///
|
||||
/// \details
|
||||
constexpr matrix()
|
||||
: data{ scalar_t(0) }{}
|
||||
constexpr matrix() = default;
|
||||
|
||||
|
||||
///
|
||||
@@ -329,7 +324,7 @@ struct matrix
|
||||
///
|
||||
/// \copydetails matrix::operator[](size_t) const
|
||||
constexpr column_t& operator[](size_t i)
|
||||
{ assert(i < rows); return data[i]; }
|
||||
{ assert(i < columns); return data[i]; }
|
||||
|
||||
///
|
||||
/// \brief returns the column at index \f$i\f$
|
||||
@@ -367,9 +362,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been added by the scalar
|
||||
constexpr friend matrix_t operator+(const matrix_t& lhs, scalar_t rhs)
|
||||
{
|
||||
matrix_t retval = lhs;
|
||||
((retval[ColIndicesV] += rhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs[ColIndicesV] + rhs ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -379,9 +372,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been added by the scalar
|
||||
constexpr friend matrix_t operator+(scalar_t lhs, const matrix_t& rhs)
|
||||
{
|
||||
matrix_t retval = rhs;
|
||||
((retval[ColIndicesV] += lhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs + rhs[ColIndicesV] ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -391,9 +382,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been subtracted by the scalar
|
||||
constexpr friend matrix_t operator-(const matrix_t& lhs, scalar_t rhs)
|
||||
{
|
||||
matrix_t retval = lhs;
|
||||
((retval[ColIndicesV] -= rhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs[ColIndicesV] - rhs ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -403,9 +392,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been subtracted by the scalar
|
||||
constexpr friend matrix_t operator-(scalar_t lhs, const matrix_t& rhs)
|
||||
{
|
||||
matrix_t retval = rhs;
|
||||
((retval[ColIndicesV] -= lhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs - rhs[ColIndicesV] ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -415,9 +402,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been multiplied by the scalar
|
||||
constexpr friend matrix_t operator*(const matrix_t& lhs, scalar_t rhs)
|
||||
{
|
||||
matrix_t retval = lhs;
|
||||
((retval[ColIndicesV] *= rhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs[ColIndicesV] * rhs ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -427,9 +412,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been multiplied by the scalar
|
||||
constexpr friend matrix_t operator*(scalar_t lhs, const matrix_t& rhs)
|
||||
{
|
||||
matrix_t retval = rhs;
|
||||
((retval[ColIndicesV] *= lhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs * rhs[ColIndicesV] ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -439,9 +422,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been divided by the scalar
|
||||
constexpr friend matrix_t operator/(const matrix_t& lhs, scalar_t rhs)
|
||||
{
|
||||
matrix_t retval = lhs;
|
||||
((retval[ColIndicesV] /= rhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs[ColIndicesV] / rhs ...);
|
||||
}
|
||||
|
||||
///
|
||||
@@ -451,9 +432,7 @@ struct matrix
|
||||
/// \returns a copy of the matrix with each component having been divided by the scalar
|
||||
constexpr friend matrix_t operator/(scalar_t lhs, const matrix_t& rhs)
|
||||
{
|
||||
matrix_t retval = rhs;
|
||||
((retval[ColIndicesV] /= lhs), ...);
|
||||
return retval;
|
||||
return matrix_t(lhs / rhs[ColIndicesV] ...);
|
||||
}
|
||||
|
||||
|
||||
@@ -607,8 +586,9 @@ struct matrix
|
||||
/// \param rhs the vector
|
||||
/// \returns a vector containing the dot products of \f$rhs\f$ with each row of \f$lhs\f$
|
||||
constexpr friend column_t operator*(const matrix_t& lhs, const row_t& rhs)
|
||||
{ return [lhs, rhs]<size_t...i>(index_sequence<i...>) -> column_t
|
||||
{ return column_t(fennec::dot(fennec::row(lhs, i), rhs) ...); }(make_index_sequence<rows>{}); }
|
||||
{
|
||||
return __mul(lhs, rhs);
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief performs a linear algebraic multiply
|
||||
@@ -647,11 +627,12 @@ struct matrix
|
||||
/// \brief performs a linear algebraic matrix multiplication
|
||||
/// \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)
|
||||
template<size_t ORowsV, size_t...OColIndicesV> requires(columns == ORowsV)
|
||||
constexpr friend matrix<scalar_t, RowsV, OColIndicesV...> operator*(const matrix_t& lhs, const matrix<scalar_t, ORowsV, OColIndicesV...>& rhs)
|
||||
{
|
||||
return [lhs, rhs]<size_t...i>(index_sequence<i...>) -> matrix_t {
|
||||
return matrix_t(rhs * fennec::row(lhs, i)...);
|
||||
}(make_index_sequence<rows>{});
|
||||
return matrix<scalar_t, RowsV, OColIndicesV...>(
|
||||
matrix::__mul(lhs, rhs[OColIndicesV])...
|
||||
);
|
||||
}
|
||||
|
||||
/// @}
|
||||
@@ -660,36 +641,53 @@ struct matrix
|
||||
|
||||
// Helpers =============================================================================================================
|
||||
|
||||
public:
|
||||
|
||||
static constexpr matrix_t transpose(const transpose_t& mat)
|
||||
{ return matrix_t(fennec::row(mat, ColIndicesV)...); }
|
||||
|
||||
private:
|
||||
|
||||
// ReSharper disable once CppMemberFunctionMayBeStatic
|
||||
template<size_t i0 = 0>
|
||||
constexpr void __construct() { }
|
||||
constexpr void __construct() { } // base case, does nothing, this will get optimized away
|
||||
|
||||
template<size_t i0 = 0, typename HeadT, typename...ArgsT>
|
||||
constexpr void __construct(HeadT&& head, ArgsT&&...args)
|
||||
// helper for parsing parameter packs
|
||||
template<size_t i0 = 0, typename HeadT, typename...RestT>
|
||||
constexpr void __construct(HeadT&& head, RestT&&...rest)
|
||||
{
|
||||
matrix::__insert<i0>(head);
|
||||
matrix::__construct<i0 + component_count_v<HeadT>>(std::forward<ArgsT>(args)...);
|
||||
matrix::__insert<i0>(head); // insert the head element
|
||||
matrix::__construct<i0 + component_count_v<HeadT>>(std::forward<RestT>(rest)...); // propagate to the rest of the arguments
|
||||
}
|
||||
|
||||
// helper for inserting a scalar value
|
||||
template<size_t i0 = 0>
|
||||
constexpr void __insert(scalar_t s)
|
||||
{ data[i0 / rows][i0 % rows] = s; }
|
||||
|
||||
|
||||
// helper for inserting a scalar value of differing type
|
||||
template<size_t i0 = 0, typename OScalarT> requires(is_arithmetic_v<OScalarT>)
|
||||
constexpr void __insert(OScalarT s)
|
||||
{ data[i0 / rows][i0 % rows] = scalar_t(s); }
|
||||
|
||||
|
||||
// helper for inserting a vector
|
||||
template<size_t i0 = 0, size_t...i>
|
||||
constexpr void __insert(const vector<scalar_t, i...>& v)
|
||||
{ (matrix::__insert<i0 + i>(v[i]), ...); }
|
||||
|
||||
// helper for inserting a vector of differing type
|
||||
template<size_t i0 = 0, typename OScalarT, size_t...i>
|
||||
constexpr void __insert(const vector<OScalarT, i...>& v)
|
||||
{ (matrix::__insert<i0 + i>(v[i]), ...); }
|
||||
|
||||
// helper for a linear algebraic multiply
|
||||
static constexpr column_t __mul(const matrix_t& lhs, const row_t& rhs)
|
||||
{
|
||||
// the compiler will optimize this better than writing out a specific definition
|
||||
// when compared to glm or CxxSwizzle, this is faster by a significant margin
|
||||
// all implementations provide 7 decimal places of precision
|
||||
return ((lhs[ColIndicesV] * rhs[ColIndicesV]) + ...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -631,6 +631,15 @@ struct vector : detail::vector_base_type<ScalarT, sizeof...(IndicesV)>
|
||||
/// \name \ref fennec_math_vector "vector" - \ref fennec_math_vector "vector" Arithmetic operators
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// \brief negation operator
|
||||
///
|
||||
/// \details
|
||||
/// \param x the vector
|
||||
/// \returns A \ref fennec_math_vector "vector" \a v such that, \f$v_i=-x_i\f$
|
||||
constexpr friend vector_t operator-(const vector_t& x)
|
||||
{ return vector((-x[IndicesV]) ...); }
|
||||
|
||||
///
|
||||
/// \brief \ref fennec_math_vector "vector" - \ref fennec_math_vector "vector" addition operator
|
||||
///
|
||||
@@ -743,6 +752,15 @@ struct vector : detail::vector_base_type<ScalarT, sizeof...(IndicesV)>
|
||||
/// \name Boolean Operators
|
||||
/// @{
|
||||
|
||||
///
|
||||
/// \brief unary boolean not operator
|
||||
///
|
||||
/// \details
|
||||
/// \param v the vector
|
||||
/// \returns A \ref fennec_math_vector "vector" \a v such that, \f$v_i=!x_i\f$
|
||||
constexpr friend vector_t operator!(const vector_t& x)
|
||||
{ return vector_t(!x[IndicesV] ...); }
|
||||
|
||||
///
|
||||
/// \brief \ref fennec_math_vector "vector" - \ref fennec_math_scalar "scalar" logical and operator
|
||||
///
|
||||
|
||||
@@ -26,5 +26,7 @@ void __assert_impl(const char* expression, const char* file, int line, const cha
|
||||
{
|
||||
__assert_callback(expression, file, line, function);
|
||||
|
||||
#ifndef NDEBUG
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
@@ -34,6 +34,207 @@ namespace test
|
||||
|
||||
inline void fennec_test_math_matrix()
|
||||
{
|
||||
fennec_test_section("component_count");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<mat2x2> == 4), true);
|
||||
fennec_test_run((component_count_v<mat2x3> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x2> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x3> == 9), true);
|
||||
fennec_test_run((component_count_v<mat3x4> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x3> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x4> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<mat2x2&> == 4), true);
|
||||
fennec_test_run((component_count_v<mat2x3&> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x2&> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x3&> == 9), true);
|
||||
fennec_test_run((component_count_v<mat3x4&> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x3&> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x4&> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<mat2x2&&> == 4), true);
|
||||
fennec_test_run((component_count_v<mat2x3&&> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x2&&> == 6), true);
|
||||
fennec_test_run((component_count_v<mat3x3&&> == 9), true);
|
||||
fennec_test_run((component_count_v<mat3x4&&> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x3&&> == 12), true);
|
||||
fennec_test_run((component_count_v<mat4x4&&> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<const mat2x2&> == 4), true);
|
||||
fennec_test_run((component_count_v<const mat2x3&> == 6), true);
|
||||
fennec_test_run((component_count_v<const mat3x2&> == 6), true);
|
||||
fennec_test_run((component_count_v<const mat3x3&> == 9), true);
|
||||
fennec_test_run((component_count_v<const mat3x4&> == 12), true);
|
||||
fennec_test_run((component_count_v<const mat4x3&> == 12), true);
|
||||
fennec_test_run((component_count_v<const mat4x4&> == 16), true);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_run((component_count_v<dmat2x2> == 4), true);
|
||||
fennec_test_run((component_count_v<dmat2x3> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x2> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x3> == 9), true);
|
||||
fennec_test_run((component_count_v<dmat3x4> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x3> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x4> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<dmat2x2&> == 4), true);
|
||||
fennec_test_run((component_count_v<dmat2x3&> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x2&> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x3&> == 9), true);
|
||||
fennec_test_run((component_count_v<dmat3x4&> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x3&> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x4&> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<dmat2x2&&> == 4), true);
|
||||
fennec_test_run((component_count_v<dmat2x3&&> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x2&&> == 6), true);
|
||||
fennec_test_run((component_count_v<dmat3x3&&> == 9), true);
|
||||
fennec_test_run((component_count_v<dmat3x4&&> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x3&&> == 12), true);
|
||||
fennec_test_run((component_count_v<dmat4x4&&> == 16), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run((component_count_v<const dmat2x2&> == 4), true);
|
||||
fennec_test_run((component_count_v<const dmat2x3&> == 6), true);
|
||||
fennec_test_run((component_count_v<const dmat3x2&> == 6), true);
|
||||
fennec_test_run((component_count_v<const dmat3x3&> == 9), true);
|
||||
fennec_test_run((component_count_v<const dmat3x4&> == 12), true);
|
||||
fennec_test_run((component_count_v<const dmat4x3&> == 12), true);
|
||||
fennec_test_run((component_count_v<const dmat4x4&> == 16), true);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_header("matrix equality operators");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2() == mat2(), true);
|
||||
fennec_test_run(mat3() == mat3(), true);
|
||||
fennec_test_run(mat4() == mat4(), true);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2() != mat2(), false);
|
||||
fennec_test_run(mat3() != mat3(), false);
|
||||
fennec_test_run(mat4() != mat4(), false);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_header("matrix constructors");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2(), mat2(0));
|
||||
fennec_test_run(mat3(), mat3(0));
|
||||
fennec_test_run(mat4(), mat4(0));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2(1), mat2(1, 0, 0, 1));
|
||||
fennec_test_run(mat3(1), mat3(1, 0, 0, 0, 1, 0, 0, 0, 1));
|
||||
fennec_test_run(mat4(1), mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1));
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_header("matrix-scalar operators");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2x2(1, 2, 3, 4) * 2, mat2x2(2, 4, 6, 8));
|
||||
fennec_test_run(mat2x3(1, 2, 3, 4, 5, 6) * 2, mat2x3(2, 4, 6, 8, 10, 12));
|
||||
fennec_test_run(mat3x2(1, 2, 3, 4, 5, 6) * 2, mat3x2(2, 4, 6, 8, 10, 12));
|
||||
fennec_test_run(mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9) * 2, mat3x3(2, 4, 6, 8, 10, 12, 14, 16, 18));
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_header("matrix-vector operators");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(vec2(1, 2) * mat2x2(1, 2, 3, 4), vec2(5, 11));
|
||||
fennec_test_run(vec2(1, 2) * mat3x2(1, 2, 3, 4, 5, 6), vec3(5, 11, 17));
|
||||
fennec_test_run(vec2(1, 2) * mat4x2(1, 2, 3, 4, 5, 6, 7, 8), vec4(5, 11, 17, 23));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(vec3(1, 2, 3) * mat2x3(1, 2, 3, 4, 5, 6), vec2(14, 32));
|
||||
fennec_test_run(vec3(1, 2, 3) * mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9), vec3(14, 32, 50));
|
||||
fennec_test_run(vec3(1, 2, 3) * mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), vec4(14, 32, 50, 68));
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_header("matrix-matrix operators");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2x2(1, 2, 3, 4) * mat2x2(1, 2, 3, 4), mat2x2(7, 10, 15, 22));
|
||||
fennec_test_run(mat2x2(1, 2, 3, 4) * mat3x2(1, 2, 3, 4, 5, 6), mat3x2(7, 10, 15, 22, 23, 34));
|
||||
fennec_test_run(mat2x2(1, 2, 3, 4) * mat4x2(1, 2, 3, 4, 5, 6, 7, 8), mat4x2(7, 10, 15, 22, 23, 34, 31, 46));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat2x3(1, 2, 3, 4, 5, 6) * mat2x2(1, 2, 3, 4), mat2x3(9, 12, 15, 19, 26, 33));
|
||||
fennec_test_run(mat2x3(1, 2, 3, 4, 5, 6) * mat3x2(1, 2, 3, 4, 5, 6), mat3x3(9, 12, 15, 19, 26, 33, 29, 40, 51));
|
||||
fennec_test_run(mat2x3(1, 2, 3, 4, 5, 6) * mat4x2(1, 2, 3, 4, 5, 6, 7, 8), mat4x3(9, 12, 15, 19, 26, 33, 29, 40, 51, 39, 54, 69));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat3x2(1, 2, 3, 4, 5, 6) * mat2x3(1, 2, 3, 4, 5, 6), mat2x2(22, 28, 49, 64));
|
||||
fennec_test_run(mat3x2(1, 2, 3, 4, 5, 6) * mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9), mat3x2(22, 28, 49, 64, 76, 100));
|
||||
fennec_test_run(mat3x2(1, 2, 3, 4, 5, 6) * mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), mat4x2(22, 28, 49, 64, 76, 100, 103, 136));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9) * mat2x3(1, 2, 3, 4, 5, 6), mat2x3(30, 36, 42, 66, 81, 96));
|
||||
fennec_test_run(mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9) * mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9), mat3x3(30, 36, 42, 66, 81, 96, 102, 126, 150));
|
||||
fennec_test_run(mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9) * mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), mat4x3(30, 36, 42, 66, 81, 96, 102, 126, 150, 138, 171, 204));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat2x3(1, 2, 3, 4, 5, 6), mat2x4(38, 44, 50, 56, 83, 98, 113, 128));
|
||||
fennec_test_run(mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9), mat3x4(38, 44, 50, 56, 83, 98, 113, 128, 128, 152, 176, 200));
|
||||
fennec_test_run(mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), mat4x4(38, 44, 50, 56, 83, 98, 113, 128, 128, 152, 176, 200, 173, 206, 239, 272));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat2x4(1, 2, 3, 4, 5, 6, 7, 8), mat2x3(70, 80, 90, 158, 184, 210));
|
||||
fennec_test_run(mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), mat3x3(70, 80, 90, 158, 184, 210, 246, 288, 330));
|
||||
fennec_test_run(mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) * mat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), mat4x3(70, 80, 90, 158, 184, 210, 246, 288, 330, 334, 392, 450));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(mat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) * mat2x4(1, 2, 3, 4, 5, 6, 7, 8), mat2x4(90, 100, 110, 120, 202, 228, 254, 280));
|
||||
fennec_test_run(mat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) * mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), mat3x4(90, 100, 110, 120, 202, 228, 254, 280, 314,356,398,440));
|
||||
fennec_test_run(mat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) * mat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), mat4x4(90, 100, 110, 120, 202, 228, 254, 280, 314, 356, 398, 440, 426, 484, 542, 600));
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_section("matrixCompMult");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
@@ -42,7 +243,7 @@ inline void fennec_test_math_matrix()
|
||||
fennec_test_run(fennec::matrixCompMult(mat3(1, 4, 8, 6, 2, 5, 9, 7, 3), mat3(1)), mat3(1, 0, 0, 0, 2, 0, 0, 0, 3));
|
||||
fennec_test_run(fennec::matrixCompMult(mat4(2, 1, -3, 4, -1, 0, 2, 5, 3, 2, 1, 0, 4, -2, 3, 1), mat4(1)), mat4(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
@@ -69,7 +270,7 @@ inline void fennec_test_math_matrix()
|
||||
fennec_test_run(fennec::outerProduct(vec4(1, 2, 3, 4), vec3(5, 6, 7)), mat3x4(5, 10, 15, 20, 6, 12, 18, 24, 7, 14, 21, 28));
|
||||
fennec_test_run(fennec::outerProduct(vec3(1, 2, 3), vec4(4, 5, 6, 7)), mat4x3(4, 8, 12, 5, 10, 15, 6, 12, 18, 7, 14, 21));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +297,7 @@ inline void fennec_test_math_matrix()
|
||||
fennec_test_run(fennec::transpose(mat4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), mat3x4(1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12));
|
||||
fennec_test_run(fennec::transpose(mat3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)), mat4x3(1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
@@ -108,11 +309,13 @@ inline void fennec_test_math_matrix()
|
||||
fennec_test_run(fennec::determinant(mat3(1, 4, 8, 6, 2, 5, 9, 7, 3)), 271.0f);
|
||||
fennec_test_run(fennec::determinant(mat4(2, 1, -3, 4, -1, 0, 2, 5, 3, 2, 1, 0, 4, -2, 3, 1)), 414.0f);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
fennec_test_spacer(2);
|
||||
|
||||
|
||||
|
||||
fennec_test_section("inverse");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_run(fennec::inverse(mat2(1, 2, 3, 4)), mat2(-2, 1, 1.5, -0.5));
|
||||
fennec_test_run(fennec::inverse(mat3(1, 2, 3, 0, 1, 4, 5, 6, 0)), mat3(-24, 18, 5, 20, -15, -4, -5, 4, 1));
|
||||
|
||||
@@ -403,6 +403,12 @@ inline void fennec_test_math_vector()
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(not bvec2(false, false), bvec2(true, true));
|
||||
fennec_test_run(not bvec3(false, false, true), bvec3(true, true, false));
|
||||
fennec_test_run(not bvec4(false, false, true, true), bvec4(true, true, false, false));
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(bvec2(false, false) && true, bvec2(false, false));
|
||||
fennec_test_run(bvec3(false, false, true) && true, bvec3(false, false, true));
|
||||
fennec_test_run(bvec4(false, false, true, true) && true, bvec4(false, false, true, true));
|
||||
|
||||
Reference in New Issue
Block a user