Добавление функций среднего от 2 и от 3 для матриц, добавление функций альтернативного двойного векторного произведения векторов.

This commit is contained in:
Andrey Pokidov 2026-02-23 22:30:22 +07:00
parent 3b7aa5088b
commit bba8a65c1a
10 changed files with 258 additions and 1 deletions

View file

@ -84,5 +84,11 @@ extern inline void bgc_fp64_matrix2x2_multiply_by_matrix3x2(BGC_FP64_Matrix3x2*
extern inline int bgc_fp32_matrix2x2_divide_by_real(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor);
extern inline int bgc_fp64_matrix2x2_divide_by_real(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor);
extern inline void bgc_fp32_matrix2x2_get_mean2(BGC_FP32_Matrix2x2* mean, const BGC_FP32_Matrix2x2* term1, const BGC_FP32_Matrix2x2* term2);
extern inline void bgc_fp64_matrix2x2_get_mean2(BGC_FP64_Matrix2x2* mean, const BGC_FP64_Matrix2x2* term1, const BGC_FP64_Matrix2x2* term2);
extern inline void bgc_fp32_matrix2x2_get_mean3(BGC_FP32_Matrix2x2* mean, const BGC_FP32_Matrix2x2* term1, const BGC_FP32_Matrix2x2* term2, const BGC_FP32_Matrix2x2* term3);
extern inline void bgc_fp64_matrix2x2_get_mean3(BGC_FP64_Matrix2x2* mean, const BGC_FP64_Matrix2x2* term1, const BGC_FP64_Matrix2x2* term2, const BGC_FP64_Matrix2x2* term3);
extern inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase);
extern inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase);

View file

@ -691,6 +691,46 @@ inline int bgc_fp64_matrix2x2_divide_by_real(BGC_FP64_Matrix2x2* quotient, const
return BGC_SUCCESS;
}
// ================== Average2 ================== //
inline void bgc_fp32_matrix2x2_get_mean2(BGC_FP32_Matrix2x2* mean, const BGC_FP32_Matrix2x2* term1, const BGC_FP32_Matrix2x2* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5f;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5f;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5f;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5f;
}
inline void bgc_fp64_matrix2x2_get_mean2(BGC_FP64_Matrix2x2* mean, const BGC_FP64_Matrix2x2* term1, const BGC_FP64_Matrix2x2* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5;
}
// ================== Average3 ================== //
inline void bgc_fp32_matrix2x2_get_mean3(BGC_FP32_Matrix2x2* mean, const BGC_FP32_Matrix2x2* term1, const BGC_FP32_Matrix2x2* term2, const BGC_FP32_Matrix2x2* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP32_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP32_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP32_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_matrix2x2_get_mean3(BGC_FP64_Matrix2x2* mean, const BGC_FP64_Matrix2x2* term1, const BGC_FP64_Matrix2x2* term2, const BGC_FP64_Matrix2x2* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP64_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP64_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP64_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP64_ONE_THIRD;
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase)

View file

@ -54,5 +54,11 @@ extern inline void bgc_fp64_matrix2x3_multiply_by_matrix3x2(BGC_FP64_Matrix3x3*
extern inline int bgc_fp32_matrix2x3_divide_by_real(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor);
extern inline int bgc_fp64_matrix2x3_divide_by_real(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor);
extern inline void bgc_fp32_matrix2x3_get_mean2(BGC_FP32_Matrix2x3* mean, const BGC_FP32_Matrix2x3* term1, const BGC_FP32_Matrix2x3* term2);
extern inline void bgc_fp64_matrix2x3_get_mean2(BGC_FP64_Matrix2x3* mean, const BGC_FP64_Matrix2x3* term1, const BGC_FP64_Matrix2x3* term2);
extern inline void bgc_fp32_matrix2x3_get_mean3(BGC_FP32_Matrix2x3* mean, const BGC_FP32_Matrix2x3* term1, const BGC_FP32_Matrix2x3* term2, const BGC_FP32_Matrix2x3* term3);
extern inline void bgc_fp64_matrix2x3_get_mean3(BGC_FP64_Matrix2x3* mean, const BGC_FP64_Matrix2x3* term1, const BGC_FP64_Matrix2x3* term2, const BGC_FP64_Matrix2x3* term3);
extern inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase);
extern inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase);

View file

@ -577,6 +577,58 @@ inline int bgc_fp64_matrix2x3_divide_by_real(BGC_FP64_Matrix2x3* quotient, const
return BGC_SUCCESS;
}
// ================== Average2 ================== //
inline void bgc_fp32_matrix2x3_get_mean2(BGC_FP32_Matrix2x3* mean, const BGC_FP32_Matrix2x3* term1, const BGC_FP32_Matrix2x3* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5f;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5f;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5f;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5f;
mean->r3c1 = (term1->r3c1 + term2->r3c1) * 0.5f;
mean->r3c2 = (term1->r3c2 + term2->r3c2) * 0.5f;
}
inline void bgc_fp64_matrix2x3_get_mean2(BGC_FP64_Matrix2x3* mean, const BGC_FP64_Matrix2x3* term1, const BGC_FP64_Matrix2x3* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5;
mean->r3c1 = (term1->r3c1 + term2->r3c1) * 0.5;
mean->r3c2 = (term1->r3c2 + term2->r3c2) * 0.5;
}
// ================== Average3 ================== //
inline void bgc_fp32_matrix2x3_get_mean3(BGC_FP32_Matrix2x3* mean, const BGC_FP32_Matrix2x3* term1, const BGC_FP32_Matrix2x3* term2, const BGC_FP32_Matrix2x3* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP32_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP32_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP32_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP32_ONE_THIRD;
mean->r3c1 = (term1->r3c1 + term2->r3c1 + term3->r3c1) * BGC_FP32_ONE_THIRD;
mean->r3c2 = (term1->r3c2 + term2->r3c2 + term3->r3c2) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_matrix2x3_get_mean3(BGC_FP64_Matrix2x3* mean, const BGC_FP64_Matrix2x3* term1, const BGC_FP64_Matrix2x3* term2, const BGC_FP64_Matrix2x3* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP64_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP64_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP64_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP64_ONE_THIRD;
mean->r3c1 = (term1->r3c1 + term2->r3c1 + term3->r3c1) * BGC_FP64_ONE_THIRD;
mean->r3c2 = (term1->r3c2 + term2->r3c2 + term3->r3c2) * BGC_FP64_ONE_THIRD;
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase)

View file

@ -54,5 +54,11 @@ extern inline void bgc_fp64_matrix3x2_multiply_by_matrix3x3(BGC_FP64_Matrix3x2*
extern inline int bgc_fp32_matrix3x2_divide_by_real(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor);
extern inline int bgc_fp64_matrix3x2_divide_by_real(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor);
extern inline void bgc_fp32_matrix3x2_get_mean2(BGC_FP32_Matrix3x2* mean, const BGC_FP32_Matrix3x2* term1, const BGC_FP32_Matrix3x2* term2);
extern inline void bgc_fp64_matrix3x2_get_mean2(BGC_FP64_Matrix3x2* mean, const BGC_FP64_Matrix3x2* term1, const BGC_FP64_Matrix3x2* term2);
extern inline void bgc_fp32_matrix3x2_get_mean3(BGC_FP32_Matrix3x2* mean, const BGC_FP32_Matrix3x2* term1, const BGC_FP32_Matrix3x2* term2, const BGC_FP32_Matrix3x2* term3);
extern inline void bgc_fp64_matrix3x2_get_mean3(BGC_FP64_Matrix3x2* mean, const BGC_FP64_Matrix3x2* term1, const BGC_FP64_Matrix3x2* term2, const BGC_FP64_Matrix3x2* term3);
extern inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase);
extern inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase);

View file

@ -502,7 +502,7 @@ inline void bgc_fp64_matrix3x2_multiply_by_matrix2x3(BGC_FP64_Matrix2x2* product
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
// ========== Matrix Product 3x2 at 3x3 ========= //
// ========== Matrix Product 3x2 at 3x2 ========= //
inline void bgc_fp32_matrix3x2_multiply_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
{
@ -564,6 +564,54 @@ inline int bgc_fp64_matrix3x2_divide_by_real(BGC_FP64_Matrix3x2* quotient, const
return BGC_SUCCESS;
}
// ================== Average2 ================== //
inline void bgc_fp32_matrix3x2_get_mean2(BGC_FP32_Matrix3x2* mean, const BGC_FP32_Matrix3x2* term1, const BGC_FP32_Matrix3x2* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5f;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5f;
mean->r1c3 = (term1->r1c3 + term2->r1c3) * 0.5f;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5f;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5f;
mean->r2c3 = (term1->r2c3 + term2->r2c3) * 0.5f;
}
inline void bgc_fp64_matrix3x2_get_mean2(BGC_FP64_Matrix3x2* mean, const BGC_FP64_Matrix3x2* term1, const BGC_FP64_Matrix3x2* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5;
mean->r1c3 = (term1->r1c3 + term2->r1c3) * 0.5;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5;
mean->r2c3 = (term1->r2c3 + term2->r2c3) * 0.5;
}
// ================== Average3 ================== //
inline void bgc_fp32_matrix3x2_get_mean3(BGC_FP32_Matrix3x2* mean, const BGC_FP32_Matrix3x2* term1, const BGC_FP32_Matrix3x2* term2, const BGC_FP32_Matrix3x2* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP32_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP32_ONE_THIRD;
mean->r1c3 = (term1->r1c3 + term2->r1c3 + term3->r1c3) * BGC_FP32_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP32_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP32_ONE_THIRD;
mean->r2c3 = (term1->r2c3 + term2->r2c3 + term3->r2c3) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_matrix3x2_get_mean3(BGC_FP64_Matrix3x2* mean, const BGC_FP64_Matrix3x2* term1, const BGC_FP64_Matrix3x2* term2, const BGC_FP64_Matrix3x2* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP64_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP64_ONE_THIRD;
mean->r1c3 = (term1->r1c3 + term2->r1c3 + term3->r1c3) * BGC_FP64_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP64_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP64_ONE_THIRD;
mean->r2c3 = (term1->r2c3 + term2->r2c3 + term3->r2c3) * BGC_FP64_ONE_THIRD;
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase)

View file

@ -78,6 +78,12 @@ extern inline void bgc_fp64_matrix3x3_multiply_by_matrix3x3(BGC_FP64_Matrix3x3*
extern inline int bgc_fp32_matrix3x3_divide_by_real(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
extern inline int bgc_fp64_matrix3x3_divide_by_real(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
extern inline void bgc_fp32_matrix3x3_get_mean2(BGC_FP32_Matrix3x3* mean, const BGC_FP32_Matrix3x3* term1, const BGC_FP32_Matrix3x3* term2);
extern inline void bgc_fp64_matrix3x3_get_mean2(BGC_FP64_Matrix3x3* mean, const BGC_FP64_Matrix3x3* term1, const BGC_FP64_Matrix3x3* term2);
extern inline void bgc_fp32_matrix3x3_get_mean3(BGC_FP32_Matrix3x3* mean, const BGC_FP32_Matrix3x3* term1, const BGC_FP32_Matrix3x3* term2, const BGC_FP32_Matrix3x3* term3);
extern inline void bgc_fp64_matrix3x3_get_mean3(BGC_FP64_Matrix3x3* mean, const BGC_FP64_Matrix3x3* term1, const BGC_FP64_Matrix3x3* term2, const BGC_FP64_Matrix3x3* term3);
extern inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase);
extern inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase);

View file

@ -963,6 +963,70 @@ inline int bgc_fp64_matrix3x3_divide_by_real(BGC_FP64_Matrix3x3* quotient, const
return BGC_SUCCESS;
}
// ================== Average2 ================== //
inline void bgc_fp32_matrix3x3_get_mean2(BGC_FP32_Matrix3x3* mean, const BGC_FP32_Matrix3x3* term1, const BGC_FP32_Matrix3x3* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5f;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5f;
mean->r1c3 = (term1->r1c3 + term2->r1c3) * 0.5f;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5f;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5f;
mean->r2c3 = (term1->r2c3 + term2->r2c3) * 0.5f;
mean->r3c1 = (term1->r3c1 + term2->r3c1) * 0.5f;
mean->r3c2 = (term1->r3c2 + term2->r3c2) * 0.5f;
mean->r3c3 = (term1->r3c3 + term2->r3c3) * 0.5f;
}
inline void bgc_fp64_matrix3x3_get_mean2(BGC_FP64_Matrix3x3* mean, const BGC_FP64_Matrix3x3* term1, const BGC_FP64_Matrix3x3* term2)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1) * 0.5;
mean->r1c2 = (term1->r1c2 + term2->r1c2) * 0.5;
mean->r1c3 = (term1->r1c3 + term2->r1c3) * 0.5;
mean->r2c1 = (term1->r2c1 + term2->r2c1) * 0.5;
mean->r2c2 = (term1->r2c2 + term2->r2c2) * 0.5;
mean->r2c3 = (term1->r2c3 + term2->r2c3) * 0.5;
mean->r3c1 = (term1->r3c1 + term2->r3c1) * 0.5;
mean->r3c2 = (term1->r3c2 + term2->r3c2) * 0.5;
mean->r3c3 = (term1->r3c3 + term2->r3c3) * 0.5;
}
// ================== Average3 ================== //
inline void bgc_fp32_matrix3x3_get_mean3(BGC_FP32_Matrix3x3* mean, const BGC_FP32_Matrix3x3* term1, const BGC_FP32_Matrix3x3* term2, const BGC_FP32_Matrix3x3* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP32_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP32_ONE_THIRD;
mean->r1c3 = (term1->r1c3 + term2->r1c3 + term3->r1c3) * BGC_FP32_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP32_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP32_ONE_THIRD;
mean->r2c3 = (term1->r2c3 + term2->r2c3 + term3->r2c3) * BGC_FP32_ONE_THIRD;
mean->r3c1 = (term1->r3c1 + term2->r3c1 + term3->r3c1) * BGC_FP32_ONE_THIRD;
mean->r3c2 = (term1->r3c2 + term2->r3c2 + term3->r3c2) * BGC_FP32_ONE_THIRD;
mean->r3c3 = (term1->r3c3 + term2->r3c3 + term3->r3c3) * BGC_FP32_ONE_THIRD;
}
inline void bgc_fp64_matrix3x3_get_mean3(BGC_FP64_Matrix3x3* mean, const BGC_FP64_Matrix3x3* term1, const BGC_FP64_Matrix3x3* term2, const BGC_FP64_Matrix3x3* term3)
{
mean->r1c1 = (term1->r1c1 + term2->r1c1 + term3->r1c1) * BGC_FP64_ONE_THIRD;
mean->r1c2 = (term1->r1c2 + term2->r1c2 + term3->r1c2) * BGC_FP64_ONE_THIRD;
mean->r1c3 = (term1->r1c3 + term2->r1c3 + term3->r1c3) * BGC_FP64_ONE_THIRD;
mean->r2c1 = (term1->r2c1 + term2->r2c1 + term3->r2c1) * BGC_FP64_ONE_THIRD;
mean->r2c2 = (term1->r2c2 + term2->r2c2 + term3->r2c2) * BGC_FP64_ONE_THIRD;
mean->r2c3 = (term1->r2c3 + term2->r2c3 + term3->r2c3) * BGC_FP64_ONE_THIRD;
mean->r3c1 = (term1->r3c1 + term2->r3c1 + term3->r3c1) * BGC_FP64_ONE_THIRD;
mean->r3c2 = (term1->r3c2 + term2->r3c2 + term3->r3c2) * BGC_FP64_ONE_THIRD;
mean->r3c3 = (term1->r3c3 + term2->r3c3 + term3->r3c3) * BGC_FP64_ONE_THIRD;
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase)

View file

@ -84,6 +84,9 @@ extern inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* product,
extern inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3);
extern inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3);
extern inline void bgc_fp32_vector3_get_alternative_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3);
extern inline void bgc_fp64_vector3_get_alternative_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3);
extern inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);

View file

@ -505,6 +505,7 @@ inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* product, const
// ============ Double Cross Product ============ //
// [a x [b x c]] = b * (a, c) - c * (a, b)
inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
{
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
@ -515,6 +516,7 @@ inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const B
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
}
// [a x [b x c]] = b * (a, c) - c * (a, b)
inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
{
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
@ -525,6 +527,30 @@ inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const B
product->x3 = vector2->x3 * ac - vector3->x3 * ab;
}
// ====== Alternative Double Cross Product ====== //
// [[a x b] x c] = - [c x [a x b]] = -(a * (c, b) - b * (c, a)) = b * (a, c) - a * (b, c)
inline void bgc_fp32_vector3_get_alternative_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
{
const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
const float bc = bgc_fp32_vector3_get_dot_product(vector2, vector3);
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
}
// [[a x b] x c] = - [c x [a x b]] = -(a * (b, c) - b * (a, c)) = b * (a, c) - a * (b, c)
inline void bgc_fp64_vector3_get_alternative_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
{
const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
const double bc = bgc_fp64_vector3_get_dot_product(vector2, vector3);
product->x1 = vector2->x1 * ac - vector1->x1 * bc;
product->x2 = vector2->x2 * ac - vector1->x2 * bc;
product->x3 = vector2->x3 * ac - vector1->x3 * bc;
}
// =================== Angle ==================== //
float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const int angle_unit);