Развитие дуальный чисел, векторов и кватернионов, а также гомогенных векторов и матриц
This commit is contained in:
parent
3f96b661a9
commit
b87518cd3f
21 changed files with 1787 additions and 1511 deletions
|
|
@ -64,6 +64,22 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="cotes-number.h" />
|
<Unit filename="cotes-number.h" />
|
||||||
|
<Unit filename="dual-number.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="dual-number.h" />
|
||||||
|
<Unit filename="dual-quaternion.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="dual-quaternion.h" />
|
||||||
|
<Unit filename="dual-vector3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="dual-vector3.h" />
|
||||||
|
<Unit filename="hg-matrix3x3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="hg-matrix3x3.h" />
|
||||||
<Unit filename="hg-vector3.c">
|
<Unit filename="hg-vector3.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -250,36 +250,36 @@ inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, cons
|
||||||
|
|
||||||
inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = number->_cos;
|
matrix->r1c1 = number->_cos;
|
||||||
matrix->row1_col2 = -number->_sin;
|
matrix->r1c2 = -number->_sin;
|
||||||
matrix->row2_col1 = number->_sin;
|
matrix->r2c1 = number->_sin;
|
||||||
matrix->row2_col2 = number->_cos;
|
matrix->r2c2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = number->_cos;
|
matrix->r1c1 = number->_cos;
|
||||||
matrix->row1_col2 = -number->_sin;
|
matrix->r1c2 = -number->_sin;
|
||||||
matrix->row2_col1 = number->_sin;
|
matrix->r2c1 = number->_sin;
|
||||||
matrix->row2_col2 = number->_cos;
|
matrix->r2c2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Reverse Matrix ================ //
|
// ============== Reverse Matrix ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = number->_cos;
|
matrix->r1c1 = number->_cos;
|
||||||
matrix->row1_col2 = number->_sin;
|
matrix->r1c2 = number->_sin;
|
||||||
matrix->row2_col1 = -number->_sin;
|
matrix->r2c1 = -number->_sin;
|
||||||
matrix->row2_col2 = number->_cos;
|
matrix->r2c2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = number->_cos;
|
matrix->r1c1 = number->_cos;
|
||||||
matrix->row1_col2 = number->_sin;
|
matrix->r1c2 = number->_sin;
|
||||||
matrix->row2_col1 = -number->_sin;
|
matrix->r2c1 = -number->_sin;
|
||||||
matrix->row2_col2 = number->_cos;
|
matrix->r2c2 = number->_cos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Turn Vector ================= //
|
// ================ Turn Vector ================= //
|
||||||
|
|
|
||||||
|
|
@ -11,3 +11,24 @@ inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BG
|
||||||
|
|
||||||
inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second);
|
inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second);
|
||||||
inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second);
|
inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
|
||||||
|
inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale);
|
||||||
|
inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend);
|
||||||
|
inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier);
|
||||||
|
inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor);
|
||||||
|
inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
|
||||||
|
inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third);
|
||||||
|
inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _BGC_DUAL_NUMBER_H_
|
#ifndef _BGC_DUAL_NUMBER_H_
|
||||||
#define _BGC_DUAL_NUMBER_H_
|
#define _BGC_DUAL_NUMBER_H_
|
||||||
|
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
// =================== Types ==================== //
|
// =================== Types ==================== //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -67,4 +69,100 @@ inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualN
|
||||||
first->dual = second->dual;
|
first->dual = second->dual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
|
||||||
|
{
|
||||||
|
sum->real = first->real + second->real;
|
||||||
|
sum->dual = first->dual + second->dual;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
|
||||||
|
{
|
||||||
|
sum->real = first->real + second->real;
|
||||||
|
sum->dual = first->dual + second->dual;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Add Scaled ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_add_scaled(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* base_number, const BGC_FP32_DualNumber* scalable_number, const float scale)
|
||||||
|
{
|
||||||
|
sum->real = base_number->real + scalable_number->real * scale;
|
||||||
|
sum->dual = base_number->dual + scalable_number->dual * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_add_scaled(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* base_number, const BGC_FP64_DualNumber* scalable_number, const double scale)
|
||||||
|
{
|
||||||
|
sum->real = base_number->real + scalable_number->real * scale;
|
||||||
|
sum->dual = base_number->dual + scalable_number->dual * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_subtract(BGC_FP32_DualNumber* difference, const BGC_FP32_DualNumber* minuend, const BGC_FP32_DualNumber* subtrahend)
|
||||||
|
{
|
||||||
|
difference->real = minuend->real - subtrahend->real;
|
||||||
|
difference->dual = minuend->dual - subtrahend->dual;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_subtract(BGC_FP64_DualNumber* difference, const BGC_FP64_DualNumber* minuend, const BGC_FP64_DualNumber* subtrahend)
|
||||||
|
{
|
||||||
|
difference->real = minuend->real - subtrahend->real;
|
||||||
|
difference->dual = minuend->dual - subtrahend->dual;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_multiply(BGC_FP32_DualNumber* product, const BGC_FP32_DualNumber* multiplicand, const float multiplier)
|
||||||
|
{
|
||||||
|
product->real = multiplicand->real * multiplier;
|
||||||
|
product->dual = multiplicand->dual * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_multiply(BGC_FP64_DualNumber* product, const BGC_FP64_DualNumber* multiplicand, const double multiplier)
|
||||||
|
{
|
||||||
|
product->real = multiplicand->real * multiplier;
|
||||||
|
product->dual = multiplicand->dual * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Divide =================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_divide(BGC_FP32_DualNumber* quotient, const BGC_FP32_DualNumber* dividend, const float divisor)
|
||||||
|
{
|
||||||
|
bgc_fp32_dual_number_multiply(quotient, dividend, 1.0f / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_divide(BGC_FP64_DualNumber* quotient, const BGC_FP64_DualNumber* dividend, const double divisor)
|
||||||
|
{
|
||||||
|
bgc_fp64_dual_number_multiply(quotient, dividend, 1.0 / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Mean of Two ================= //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_get_mean2(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
|
||||||
|
{
|
||||||
|
mean->real = (first->real + second->real) * 0.5f;
|
||||||
|
mean->dual = (first->dual + second->dual) * 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_get_mean2(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second)
|
||||||
|
{
|
||||||
|
mean->real = (first->real + second->real) * 0.5;
|
||||||
|
mean->dual = (first->dual + second->dual) * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =============== Mean of Three ================ //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_number_get_mean3(BGC_FP32_DualNumber* mean, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const BGC_FP32_DualNumber* third)
|
||||||
|
{
|
||||||
|
mean->real = (first->real + second->real + third->real) * BGC_FP32_ONE_THIRD;
|
||||||
|
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP32_ONE_THIRD;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const BGC_FP64_DualNumber* third)
|
||||||
|
{
|
||||||
|
mean->real = (first->real + second->real + third->real) * BGC_FP64_ONE_THIRD;
|
||||||
|
mean->dual = (first->dual + second->dual + third->dual) * BGC_FP64_ONE_THIRD;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
10
basic-geometry/dual-quaternion.c
Normal file
10
basic-geometry/dual-quaternion.c
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "dual-quaternion.h"
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion);
|
||||||
|
extern inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source);
|
||||||
|
extern inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second);
|
||||||
|
extern inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second);
|
||||||
58
basic-geometry/dual-quaternion.h
Normal file
58
basic-geometry/dual-quaternion.h
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef _BGC_DUAL_QUATERNION_H_
|
||||||
|
#define _BGC_DUAL_QUATERNION_H_
|
||||||
|
|
||||||
|
#include "quaternion.h"
|
||||||
|
|
||||||
|
// =================== Types ==================== //
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BGC_FP32_Quaternion real, dual;
|
||||||
|
} BGC_FP32_DualQuaternion;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
BGC_FP64_Quaternion real, dual;
|
||||||
|
} BGC_FP64_DualQuaternion;
|
||||||
|
|
||||||
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_quaternion_reset(BGC_FP32_DualQuaternion* quaternion)
|
||||||
|
{
|
||||||
|
bgc_fp32_quaternion_reset(&quaternion->real);
|
||||||
|
bgc_fp32_quaternion_reset(&quaternion->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_quaternion_reset(BGC_FP64_DualQuaternion* quaternion)
|
||||||
|
{
|
||||||
|
bgc_fp64_quaternion_reset(&quaternion->real);
|
||||||
|
bgc_fp64_quaternion_reset(&quaternion->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_quaternion_copy(BGC_FP32_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source)
|
||||||
|
{
|
||||||
|
bgc_fp32_quaternion_copy(&destination->real, &source->real);
|
||||||
|
bgc_fp32_quaternion_copy(&destination->dual, &source->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source)
|
||||||
|
{
|
||||||
|
bgc_fp64_quaternion_copy(&destination->real, &source->real);
|
||||||
|
bgc_fp64_quaternion_copy(&destination->dual, &source->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second)
|
||||||
|
{
|
||||||
|
bgc_fp32_quaternion_swap(&first->real, &second->real);
|
||||||
|
bgc_fp32_quaternion_swap(&first->dual, &second->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second)
|
||||||
|
{
|
||||||
|
bgc_fp64_quaternion_swap(&first->real, &second->real);
|
||||||
|
bgc_fp64_quaternion_swap(&first->dual, &second->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,22 +1,34 @@
|
||||||
#include "./dual-vector3.h"
|
#include "./dual-vector3.h"
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector);
|
extern inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector);
|
||||||
inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector);
|
extern inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual);
|
extern inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual);
|
||||||
inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual);
|
extern inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
|
extern inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source);
|
||||||
inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
|
extern inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
|
extern inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second);
|
||||||
inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
|
extern inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second);
|
extern inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
|
||||||
inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second);
|
extern inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale);
|
extern inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3);
|
||||||
inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale);
|
extern inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3);
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend);
|
extern inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second);
|
||||||
inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend);
|
extern inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale);
|
||||||
|
extern inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend);
|
||||||
|
extern inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier);
|
||||||
|
extern inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier);
|
||||||
|
|
||||||
|
extern inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor);
|
||||||
|
extern inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,34 @@ inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_F
|
||||||
bgc_fp64_vector3_copy(&vector->dual, dual);
|
bgc_fp64_vector3_copy(&vector->dual, dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_vector3_copy(BGC_FP32_DualVector3* destination, const BGC_FP32_DualVector3* source)
|
||||||
|
{
|
||||||
|
bgc_fp32_vector3_copy(&destination->real, &source->real);
|
||||||
|
bgc_fp32_vector3_copy(&destination->dual, &source->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_vector3_copy(BGC_FP64_DualVector3* destination, const BGC_FP64_DualVector3* source)
|
||||||
|
{
|
||||||
|
bgc_fp64_vector3_copy(&destination->real, &source->real);
|
||||||
|
bgc_fp64_vector3_copy(&destination->dual, &source->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_vector3_swap(BGC_FP32_DualVector3* first, BGC_FP32_DualVector3* second)
|
||||||
|
{
|
||||||
|
bgc_fp32_vector3_swap(&first->real, &second->real);
|
||||||
|
bgc_fp32_vector3_swap(&first->dual, &second->dual);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_vector3_swap(BGC_FP64_DualVector3* first, BGC_FP64_DualVector3* second)
|
||||||
|
{
|
||||||
|
bgc_fp64_vector3_swap(&first->real, &second->real);
|
||||||
|
bgc_fp64_vector3_swap(&first->dual, &second->dual);
|
||||||
|
}
|
||||||
|
|
||||||
// ================== Set Real ================== //
|
// ================== Set Real ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3)
|
inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3)
|
||||||
|
|
@ -115,6 +143,32 @@ inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, con
|
||||||
bgc_fp64_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
|
bgc_fp64_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_vector3_multiply(BGC_FP32_DualVector3* product, const BGC_FP32_DualVector3* multiplicand, const float multiplier)
|
||||||
|
{
|
||||||
|
bgc_fp32_vector3_multiply(&product->real, &multiplicand->real, multiplier);
|
||||||
|
bgc_fp32_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_vector3_multiply(BGC_FP64_DualVector3* product, const BGC_FP64_DualVector3* multiplicand, const double multiplier)
|
||||||
|
{
|
||||||
|
bgc_fp64_vector3_multiply(&product->real, &multiplicand->real, multiplier);
|
||||||
|
bgc_fp64_vector3_multiply(&product->dual, &multiplicand->dual, multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================== Divide =================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_dual_vector3_divide(BGC_FP32_DualVector3* quotient, const BGC_FP32_DualVector3* dividend, const float divisor)
|
||||||
|
{
|
||||||
|
bgc_fp32_dual_vector3_multiply(quotient, dividend, 1.0f / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_dual_vector3_divide(BGC_FP64_DualVector3* quotient, const BGC_FP64_DualVector3* dividend, const double divisor)
|
||||||
|
{
|
||||||
|
bgc_fp64_dual_vector3_multiply(quotient, dividend, 1.0 / divisor);
|
||||||
|
}
|
||||||
|
|
||||||
// ================== Average2 ================== //
|
// ================== Average2 ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2)
|
inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2)
|
||||||
|
|
@ -133,14 +187,14 @@ inline void bgc_fp64_dual_vector3_get_mean2(BGC_FP64_DualVector3* mean, const BG
|
||||||
|
|
||||||
inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3)
|
inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3)
|
||||||
{
|
{
|
||||||
bgc_fp32_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real);
|
bgc_fp32_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
|
||||||
bgc_fp32_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
|
bgc_fp32_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3)
|
inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3)
|
||||||
{
|
{
|
||||||
bgc_fp64_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real);
|
bgc_fp64_vector3_get_mean3(&mean->real, &vector1->real, &vector2->real, &vector3->real);
|
||||||
bgc_fp64_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
|
bgc_fp64_vector3_get_mean3(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#include "dual-versor.h"
|
|
||||||
|
|
||||||
extern inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number);
|
|
||||||
extern inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number);
|
|
||||||
|
|
||||||
extern inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source);
|
|
||||||
extern inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source);
|
|
||||||
|
|
||||||
extern inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second);
|
|
||||||
extern inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second);
|
|
||||||
|
|
@ -1,147 +0,0 @@
|
||||||
#ifndef _BGC_DUAL_VERSOR_H_
|
|
||||||
#define _BGC_DUAL_VERSOR_H_
|
|
||||||
|
|
||||||
// =================== Types ==================== //
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct {
|
|
||||||
float s0, x1, x2, x3;
|
|
||||||
} _real, _dual;
|
|
||||||
} BGC_FP32_DualVersor;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct {
|
|
||||||
double s0, x1, x2, x3;
|
|
||||||
} _real, _dual;
|
|
||||||
} BGC_FP64_DualVersor;
|
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
|
||||||
|
|
||||||
inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number)
|
|
||||||
{
|
|
||||||
number->_real.s0 = 1.0f;
|
|
||||||
number->_real.x1 = 0.0f;
|
|
||||||
number->_real.x2 = 0.0f;
|
|
||||||
number->_real.x3 = 0.0f;
|
|
||||||
|
|
||||||
number->_dual.s0 = 0.0f;
|
|
||||||
number->_dual.x1 = 0.0f;
|
|
||||||
number->_dual.x2 = 0.0f;
|
|
||||||
number->_dual.x3 = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number)
|
|
||||||
{
|
|
||||||
number->_real.s0 = 1.0f;
|
|
||||||
number->_real.x1 = 0.0f;
|
|
||||||
number->_real.x2 = 0.0f;
|
|
||||||
number->_real.x3 = 0.0f;
|
|
||||||
|
|
||||||
number->_dual.s0 = 0.0f;
|
|
||||||
number->_dual.x1 = 0.0f;
|
|
||||||
number->_dual.x2 = 0.0f;
|
|
||||||
number->_dual.x3 = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
|
||||||
|
|
||||||
inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source)
|
|
||||||
{
|
|
||||||
destination->_real.s0 = source->_real.s0;
|
|
||||||
destination->_real.x1 = source->_real.x1;
|
|
||||||
destination->_real.x2 = source->_real.x2;
|
|
||||||
destination->_real.x3 = source->_real.x3;
|
|
||||||
|
|
||||||
destination->_dual.s0 = source->_dual.s0;
|
|
||||||
destination->_dual.x1 = source->_dual.x1;
|
|
||||||
destination->_dual.x2 = source->_dual.x2;
|
|
||||||
destination->_dual.x3 = source->_dual.x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source)
|
|
||||||
{
|
|
||||||
destination->_real.s0 = source->_real.s0;
|
|
||||||
destination->_real.x1 = source->_real.x1;
|
|
||||||
destination->_real.x2 = source->_real.x2;
|
|
||||||
destination->_real.x3 = source->_real.x3;
|
|
||||||
|
|
||||||
destination->_dual.s0 = source->_dual.s0;
|
|
||||||
destination->_dual.x1 = source->_dual.x1;
|
|
||||||
destination->_dual.x2 = source->_dual.x2;
|
|
||||||
destination->_dual.x3 = source->_dual.x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
|
||||||
|
|
||||||
inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second)
|
|
||||||
{
|
|
||||||
// Real
|
|
||||||
float s0 = second->_real.s0;
|
|
||||||
float x1 = second->_real.x1;
|
|
||||||
float x2 = second->_real.x2;
|
|
||||||
float x3 = second->_real.x3;
|
|
||||||
|
|
||||||
second->_real.s0 = first->_real.s0;
|
|
||||||
second->_real.x1 = first->_real.x1;
|
|
||||||
second->_real.x2 = first->_real.x2;
|
|
||||||
second->_real.x3 = first->_real.x3;
|
|
||||||
|
|
||||||
first->_real.s0 = s0;
|
|
||||||
first->_real.x1 = x1;
|
|
||||||
first->_real.x2 = x2;
|
|
||||||
first->_real.x3 = x3;
|
|
||||||
|
|
||||||
// Dual
|
|
||||||
s0 = second->_dual.s0;
|
|
||||||
x1 = second->_dual.x1;
|
|
||||||
x2 = second->_dual.x2;
|
|
||||||
x3 = second->_dual.x3;
|
|
||||||
|
|
||||||
second->_dual.s0 = first->_dual.s0;
|
|
||||||
second->_dual.x1 = first->_dual.x1;
|
|
||||||
second->_dual.x2 = first->_dual.x2;
|
|
||||||
second->_dual.x3 = first->_dual.x3;
|
|
||||||
|
|
||||||
first->_dual.s0 = s0;
|
|
||||||
first->_dual.x1 = x1;
|
|
||||||
first->_dual.x2 = x2;
|
|
||||||
first->_dual.x3 = x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second)
|
|
||||||
{
|
|
||||||
// Real
|
|
||||||
double s0 = second->_real.s0;
|
|
||||||
double x1 = second->_real.x1;
|
|
||||||
double x2 = second->_real.x2;
|
|
||||||
double x3 = second->_real.x3;
|
|
||||||
|
|
||||||
second->_real.s0 = first->_real.s0;
|
|
||||||
second->_real.x1 = first->_real.x1;
|
|
||||||
second->_real.x2 = first->_real.x2;
|
|
||||||
second->_real.x3 = first->_real.x3;
|
|
||||||
|
|
||||||
first->_real.s0 = s0;
|
|
||||||
first->_real.x1 = x1;
|
|
||||||
first->_real.x2 = x2;
|
|
||||||
first->_real.x3 = x3;
|
|
||||||
|
|
||||||
// Dual
|
|
||||||
s0 = second->_dual.s0;
|
|
||||||
x1 = second->_dual.x1;
|
|
||||||
x2 = second->_dual.x2;
|
|
||||||
x3 = second->_dual.x3;
|
|
||||||
|
|
||||||
second->_dual.s0 = first->_dual.s0;
|
|
||||||
second->_dual.x1 = first->_dual.x1;
|
|
||||||
second->_dual.x2 = first->_dual.x2;
|
|
||||||
second->_dual.x3 = first->_dual.x3;
|
|
||||||
|
|
||||||
first->_dual.s0 = s0;
|
|
||||||
first->_dual.x1 = x1;
|
|
||||||
first->_dual.x2 = x2;
|
|
||||||
first->_dual.x3 = x3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
7
basic-geometry/hg-matrix3x3.c
Normal file
7
basic-geometry/hg-matrix3x3.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "hg-matrix3x3.h"
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix);
|
||||||
|
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix);
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift);
|
||||||
|
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift);
|
||||||
123
basic-geometry/hg-matrix3x3.h
Normal file
123
basic-geometry/hg-matrix3x3.h
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
#ifndef _BGC_HG_MATRIX3X3_H_INCLUDED_
|
||||||
|
#define _BGC_HG_MATRIX3X3_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "vector3.h"
|
||||||
|
#include "matrices.h"
|
||||||
|
|
||||||
|
#include "hg-vector3.h"
|
||||||
|
|
||||||
|
// =================== Types ==================== //
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
float r1c1, r1c2, r1c3, r1d0;
|
||||||
|
float r2c1, r2c2, r2c3, r2d0;
|
||||||
|
float r3c1, r3c2, r3c3, r3d0;
|
||||||
|
float d0c1, d0c2, d0c3, d0d0;
|
||||||
|
} BGC_FP32_HgMatrix3x3;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
double r1c1, r1c2, r1c3, r1d0;
|
||||||
|
double r2c1, r2c2, r2c3, r2d0;
|
||||||
|
double r3c1, r3c2, r3c3, r3d0;
|
||||||
|
double d0c1, d0c2, d0c3, d0d0;
|
||||||
|
} BGC_FP64_HgMatrix3x3;
|
||||||
|
|
||||||
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_matrix3x3_reset(BGC_FP32_HgMatrix3x3* homogeneous_matrix)
|
||||||
|
{
|
||||||
|
homogeneous_matrix->r1c1 = 1.0f;
|
||||||
|
homogeneous_matrix->r1c2 = 0.0f;
|
||||||
|
homogeneous_matrix->r1c2 = 0.0f;
|
||||||
|
homogeneous_matrix->r1d0 = 0.0f;
|
||||||
|
|
||||||
|
homogeneous_matrix->r2c1 = 0.0f;
|
||||||
|
homogeneous_matrix->r2c2 = 1.0f;
|
||||||
|
homogeneous_matrix->r2c2 = 0.0f;
|
||||||
|
homogeneous_matrix->r2d0 = 0.0f;
|
||||||
|
|
||||||
|
homogeneous_matrix->r3c1 = 0.0f;
|
||||||
|
homogeneous_matrix->r3c2 = 0.0f;
|
||||||
|
homogeneous_matrix->r3c2 = 1.0f;
|
||||||
|
homogeneous_matrix->r3d0 = 0.0f;
|
||||||
|
|
||||||
|
homogeneous_matrix->d0c1 = 0.0f;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0f;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0f;
|
||||||
|
homogeneous_matrix->d0d0 = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_matrix3x3_reset(BGC_FP64_HgMatrix3x3* homogeneous_matrix)
|
||||||
|
{
|
||||||
|
homogeneous_matrix->r1c1 = 1.0;
|
||||||
|
homogeneous_matrix->r1c2 = 0.0;
|
||||||
|
homogeneous_matrix->r1c2 = 0.0;
|
||||||
|
homogeneous_matrix->r1d0 = 0.0;
|
||||||
|
|
||||||
|
homogeneous_matrix->r2c1 = 0.0;
|
||||||
|
homogeneous_matrix->r2c2 = 1.0;
|
||||||
|
homogeneous_matrix->r2c2 = 0.0;
|
||||||
|
homogeneous_matrix->r2d0 = 0.0;
|
||||||
|
|
||||||
|
homogeneous_matrix->r3c1 = 0.0;
|
||||||
|
homogeneous_matrix->r3c2 = 0.0;
|
||||||
|
homogeneous_matrix->r3c2 = 1.0;
|
||||||
|
homogeneous_matrix->r3d0 = 0.0;
|
||||||
|
|
||||||
|
homogeneous_matrix->d0c1 = 0.0;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0;
|
||||||
|
homogeneous_matrix->d0d0 = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Make ==================== //
|
||||||
|
|
||||||
|
inline void bgc_fp32_hg_matrix3x3_make(BGC_FP32_HgMatrix3x3* homogeneous_matrix, const BGC_FP32_Matrix3x3* linear_matrix, const BGC_FP32_Vector3* shift)
|
||||||
|
{
|
||||||
|
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
|
||||||
|
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
|
||||||
|
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
|
||||||
|
homogeneous_matrix->r1d0 = shift->x1;
|
||||||
|
|
||||||
|
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
|
||||||
|
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
|
||||||
|
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
|
||||||
|
homogeneous_matrix->r2d0 = shift->x2;
|
||||||
|
|
||||||
|
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
|
||||||
|
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
|
||||||
|
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
|
||||||
|
homogeneous_matrix->r3d0 = shift->x3;
|
||||||
|
|
||||||
|
homogeneous_matrix->d0c1 = 0.0f;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0f;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0f;
|
||||||
|
homogeneous_matrix->d0d0 = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_fp64_hg_matrix3x3_make(BGC_FP64_HgMatrix3x3* homogeneous_matrix, const BGC_FP64_Matrix3x3* linear_matrix, const BGC_FP64_Vector3* shift)
|
||||||
|
{
|
||||||
|
homogeneous_matrix->r1c1 = linear_matrix->r1c1;
|
||||||
|
homogeneous_matrix->r1c2 = linear_matrix->r1c2;
|
||||||
|
homogeneous_matrix->r1c2 = linear_matrix->r1c3;
|
||||||
|
homogeneous_matrix->r1d0 = shift->x1;
|
||||||
|
|
||||||
|
homogeneous_matrix->r2c1 = linear_matrix->r2c1;
|
||||||
|
homogeneous_matrix->r2c2 = linear_matrix->r2c2;
|
||||||
|
homogeneous_matrix->r2c2 = linear_matrix->r2c3;
|
||||||
|
homogeneous_matrix->r2d0 = shift->x2;
|
||||||
|
|
||||||
|
homogeneous_matrix->r3c1 = linear_matrix->r3c1;
|
||||||
|
homogeneous_matrix->r3c2 = linear_matrix->r3c2;
|
||||||
|
homogeneous_matrix->r3c2 = linear_matrix->r3c3;
|
||||||
|
homogeneous_matrix->r3d0 = shift->x3;
|
||||||
|
|
||||||
|
homogeneous_matrix->d0c1 = 0.0;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0;
|
||||||
|
homogeneous_matrix->d0c2 = 0.0;
|
||||||
|
homogeneous_matrix->d0d0 = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -8,13 +8,13 @@
|
||||||
// Homogeneous 3D Vector
|
// Homogeneous 3D Vector
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float x1, x2, x3, ratio;
|
float x1, x2, x3, d0;
|
||||||
} BGC_FP32_HgVector3;
|
} BGC_FP32_HgVector3;
|
||||||
|
|
||||||
// Homogeneous 3D Vector
|
// Homogeneous 3D Vector
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
double x1, x2, x3, ratio;
|
double x1, x2, x3, d0;
|
||||||
} BGC_FP64_HgVector3;
|
} BGC_FP64_HgVector3;
|
||||||
|
|
||||||
// ================ Reset Point ================= //
|
// ================ Reset Point ================= //
|
||||||
|
|
@ -24,7 +24,7 @@ inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vect
|
||||||
homogeneous_vector->x1 = 0.0f;
|
homogeneous_vector->x1 = 0.0f;
|
||||||
homogeneous_vector->x2 = 0.0f;
|
homogeneous_vector->x2 = 0.0f;
|
||||||
homogeneous_vector->x3 = 0.0f;
|
homogeneous_vector->x3 = 0.0f;
|
||||||
homogeneous_vector->ratio = 1.0f;
|
homogeneous_vector->d0 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector)
|
inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
|
@ -32,7 +32,7 @@ inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vect
|
||||||
homogeneous_vector->x1 = 0.0;
|
homogeneous_vector->x1 = 0.0;
|
||||||
homogeneous_vector->x2 = 0.0;
|
homogeneous_vector->x2 = 0.0;
|
||||||
homogeneous_vector->x3 = 0.0;
|
homogeneous_vector->x3 = 0.0;
|
||||||
homogeneous_vector->ratio = 1.0;
|
homogeneous_vector->d0 = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Reset Point ================= //
|
// ================ Reset Point ================= //
|
||||||
|
|
@ -42,7 +42,7 @@ inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vec
|
||||||
homogeneous_vector->x1 = 0.0f;
|
homogeneous_vector->x1 = 0.0f;
|
||||||
homogeneous_vector->x2 = 0.0f;
|
homogeneous_vector->x2 = 0.0f;
|
||||||
homogeneous_vector->x3 = 0.0f;
|
homogeneous_vector->x3 = 0.0f;
|
||||||
homogeneous_vector->ratio = 0.0f;
|
homogeneous_vector->d0 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector)
|
inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
|
|
@ -50,25 +50,25 @@ inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vec
|
||||||
homogeneous_vector->x1 = 0.0;
|
homogeneous_vector->x1 = 0.0;
|
||||||
homogeneous_vector->x2 = 0.0;
|
homogeneous_vector->x2 = 0.0;
|
||||||
homogeneous_vector->x3 = 0.0;
|
homogeneous_vector->x3 = 0.0;
|
||||||
homogeneous_vector->ratio = 0.0;
|
homogeneous_vector->d0 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Make ==================== //
|
// ==================== Make ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio)
|
inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float d0)
|
||||||
{
|
{
|
||||||
homogeneous_vector->x1 = x1;
|
homogeneous_vector->x1 = x1;
|
||||||
homogeneous_vector->x2 = x2;
|
homogeneous_vector->x2 = x2;
|
||||||
homogeneous_vector->x3 = x3;
|
homogeneous_vector->x3 = x3;
|
||||||
homogeneous_vector->ratio = ratio;
|
homogeneous_vector->d0 = d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio)
|
inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double d0)
|
||||||
{
|
{
|
||||||
homogeneous_vector->x1 = x1;
|
homogeneous_vector->x1 = x1;
|
||||||
homogeneous_vector->x2 = x2;
|
homogeneous_vector->x2 = x2;
|
||||||
homogeneous_vector->x3 = x3;
|
homogeneous_vector->x3 = x3;
|
||||||
homogeneous_vector->ratio = ratio;
|
homogeneous_vector->d0 = d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Make Point ================= //
|
// ================= Make Point ================= //
|
||||||
|
|
@ -78,7 +78,7 @@ inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vecto
|
||||||
homogeneous_vector->x1 = regular_vector->x1;
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
homogeneous_vector->x2 = regular_vector->x2;
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
homogeneous_vector->x3 = regular_vector->x3;
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
homogeneous_vector->ratio = 1.0f;
|
homogeneous_vector->d0 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
||||||
|
|
@ -86,7 +86,7 @@ inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vecto
|
||||||
homogeneous_vector->x1 = regular_vector->x1;
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
homogeneous_vector->x2 = regular_vector->x2;
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
homogeneous_vector->x3 = regular_vector->x3;
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
homogeneous_vector->ratio = 1.0;
|
homogeneous_vector->d0 = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Make Vector ================= //
|
// ================ Make Vector ================= //
|
||||||
|
|
@ -96,7 +96,7 @@ inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vect
|
||||||
homogeneous_vector->x1 = regular_vector->x1;
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
homogeneous_vector->x2 = regular_vector->x2;
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
homogeneous_vector->x3 = regular_vector->x3;
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
homogeneous_vector->ratio = 0.0f;
|
homogeneous_vector->d0 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector)
|
||||||
|
|
@ -104,31 +104,31 @@ inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vect
|
||||||
homogeneous_vector->x1 = regular_vector->x1;
|
homogeneous_vector->x1 = regular_vector->x1;
|
||||||
homogeneous_vector->x2 = regular_vector->x2;
|
homogeneous_vector->x2 = regular_vector->x2;
|
||||||
homogeneous_vector->x3 = regular_vector->x3;
|
homogeneous_vector->x3 = regular_vector->x3;
|
||||||
homogeneous_vector->ratio = 0.0;
|
homogeneous_vector->d0 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Is Point ================== //
|
// ================== Is Point ================== //
|
||||||
|
|
||||||
inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector)
|
inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
{
|
{
|
||||||
return !bgc_fp32_is_zero(homogeneous_vector->ratio);
|
return !bgc_fp32_is_zero(homogeneous_vector->d0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector)
|
inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
{
|
{
|
||||||
return !bgc_fp64_is_zero(homogeneous_vector->ratio);
|
return !bgc_fp64_is_zero(homogeneous_vector->d0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Is Vector ================== //
|
// ================= Is Vector ================== //
|
||||||
|
|
||||||
inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector)
|
inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector)
|
||||||
{
|
{
|
||||||
return bgc_fp32_is_zero(homogeneous_vector->ratio);
|
return bgc_fp32_is_zero(homogeneous_vector->d0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector)
|
inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector)
|
||||||
{
|
{
|
||||||
return bgc_fp64_is_zero(homogeneous_vector->ratio);
|
return bgc_fp64_is_zero(homogeneous_vector->d0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
@ -138,7 +138,7 @@ inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_
|
||||||
destination->x1 = source->x1;
|
destination->x1 = source->x1;
|
||||||
destination->x2 = source->x2;
|
destination->x2 = source->x2;
|
||||||
destination->x3 = source->x3;
|
destination->x3 = source->x3;
|
||||||
destination->ratio = source->ratio;
|
destination->d0 = source->d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source)
|
inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source)
|
||||||
|
|
@ -146,7 +146,7 @@ inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_
|
||||||
destination->x1 = source->x1;
|
destination->x1 = source->x1;
|
||||||
destination->x2 = source->x2;
|
destination->x2 = source->x2;
|
||||||
destination->x3 = source->x3;
|
destination->x3 = source->x3;
|
||||||
destination->ratio = source->ratio;
|
destination->d0 = source->d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
@ -156,17 +156,17 @@ inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVecto
|
||||||
const float x1 = first->x1;
|
const float x1 = first->x1;
|
||||||
const float x2 = first->x2;
|
const float x2 = first->x2;
|
||||||
const float x3 = first->x3;
|
const float x3 = first->x3;
|
||||||
const float ratio = first->ratio;
|
const float d0 = first->d0;
|
||||||
|
|
||||||
first->x1 = second->x1;
|
first->x1 = second->x1;
|
||||||
first->x2 = second->x2;
|
first->x2 = second->x2;
|
||||||
first->x3 = second->x3;
|
first->x3 = second->x3;
|
||||||
first->ratio = second->ratio;
|
first->d0 = second->d0;
|
||||||
|
|
||||||
second->x1 = x1;
|
second->x1 = x1;
|
||||||
second->x2 = x2;
|
second->x2 = x2;
|
||||||
second->x3 = x3;
|
second->x3 = x3;
|
||||||
second->ratio = ratio;
|
second->d0 = d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second)
|
inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second)
|
||||||
|
|
@ -174,17 +174,51 @@ inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVecto
|
||||||
const double x1 = first->x1;
|
const double x1 = first->x1;
|
||||||
const double x2 = first->x2;
|
const double x2 = first->x2;
|
||||||
const double x3 = first->x3;
|
const double x3 = first->x3;
|
||||||
const double ratio = first->ratio;
|
const double d0 = first->d0;
|
||||||
|
|
||||||
first->x1 = second->x1;
|
first->x1 = second->x1;
|
||||||
first->x2 = second->x2;
|
first->x2 = second->x2;
|
||||||
first->x3 = second->x3;
|
first->x3 = second->x3;
|
||||||
first->ratio = second->ratio;
|
first->d0 = second->d0;
|
||||||
|
|
||||||
second->x1 = x1;
|
second->x1 = x1;
|
||||||
second->x2 = x2;
|
second->x2 = x2;
|
||||||
second->x3 = x3;
|
second->x3 = x3;
|
||||||
second->ratio = ratio;
|
second->d0 = d0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Rescale =================== //
|
||||||
|
|
||||||
|
inline int bgc_fp32_hg_vector3_rescale(BGC_FP32_HgVector3* homogeneous_vector, const float new_ratio)
|
||||||
|
{
|
||||||
|
if (bgc_fp32_is_zero(homogeneous_vector->d0)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float multiplier = new_ratio / homogeneous_vector->d0;
|
||||||
|
|
||||||
|
homogeneous_vector->x1 *= multiplier;
|
||||||
|
homogeneous_vector->x2 *= multiplier;
|
||||||
|
homogeneous_vector->x3 *= multiplier;
|
||||||
|
homogeneous_vector->d0 = new_ratio;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_fp64_hg_vector3_rescale(BGC_FP64_HgVector3* homogeneous_vector, const double new_ratio)
|
||||||
|
{
|
||||||
|
if (bgc_fp64_is_zero(homogeneous_vector->d0)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double multiplier = new_ratio / homogeneous_vector->d0;
|
||||||
|
|
||||||
|
homogeneous_vector->x1 *= multiplier;
|
||||||
|
homogeneous_vector->x2 *= multiplier;
|
||||||
|
homogeneous_vector->x3 *= multiplier;
|
||||||
|
homogeneous_vector->d0 = new_ratio;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,361 +4,361 @@
|
||||||
// ================== Matrix2x2 ================= //
|
// ================== Matrix2x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float row1_col1, row1_col2;
|
float r1c1, r1c2;
|
||||||
float row2_col1, row2_col2;
|
float r2c1, r2c2;
|
||||||
} BGC_FP32_Matrix2x2;
|
} BGC_FP32_Matrix2x2;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double row1_col1, row1_col2;
|
double r1c1, r1c2;
|
||||||
double row2_col1, row2_col2;
|
double r2c1, r2c2;
|
||||||
} BGC_FP64_Matrix2x2;
|
} BGC_FP64_Matrix2x2;
|
||||||
|
|
||||||
// ================== Matrix2x3 ================= //
|
// ================== Matrix2x3 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float row1_col1, row1_col2;
|
float r1c1, r1c2;
|
||||||
float row2_col1, row2_col2;
|
float r2c1, r2c2;
|
||||||
float row3_col1, row3_col2;
|
float r3c1, r3c2;
|
||||||
} BGC_FP32_Matrix2x3;
|
} BGC_FP32_Matrix2x3;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double row1_col1, row1_col2;
|
double r1c1, r1c2;
|
||||||
double row2_col1, row2_col2;
|
double r2c1, r2c2;
|
||||||
double row3_col1, row3_col2;
|
double r3c1, r3c2;
|
||||||
} BGC_FP64_Matrix2x3;
|
} BGC_FP64_Matrix2x3;
|
||||||
|
|
||||||
// ================== Matrix3x2 ================= //
|
// ================== Matrix3x2 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float row1_col1, row1_col2, row1_col3;
|
float r1c1, r1c2, r1c3;
|
||||||
float row2_col1, row2_col2, row2_col3;
|
float r2c1, r2c2, r2c3;
|
||||||
} BGC_FP32_Matrix3x2;
|
} BGC_FP32_Matrix3x2;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double row1_col1, row1_col2, row1_col3;
|
double r1c1, r1c2, r1c3;
|
||||||
double row2_col1, row2_col2, row2_col3;
|
double r2c1, r2c2, r2c3;
|
||||||
} BGC_FP64_Matrix3x2;
|
} BGC_FP64_Matrix3x2;
|
||||||
|
|
||||||
// ================== Matrix3x3 ================= //
|
// ================== Matrix3x3 ================= //
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float row1_col1, row1_col2, row1_col3;
|
float r1c1, r1c2, r1c3;
|
||||||
float row2_col1, row2_col2, row2_col3;
|
float r2c1, r2c2, r2c3;
|
||||||
float row3_col1, row3_col2, row3_col3;
|
float r3c1, r3c2, r3c3;
|
||||||
} BGC_FP32_Matrix3x3;
|
} BGC_FP32_Matrix3x3;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double row1_col1, row1_col2, row1_col3;
|
double r1c1, r1c2, r1c3;
|
||||||
double row2_col1, row2_col2, row2_col3;
|
double r2c1, r2c2, r2c3;
|
||||||
double row3_col1, row3_col2, row3_col3;
|
double r3c1, r3c2, r3c3;
|
||||||
} BGC_FP64_Matrix3x3;
|
} BGC_FP64_Matrix3x3;
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 2x2 ========= //
|
// ========== Matrix Product 2x2 at 2x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x2 at 3x2 ========= //
|
// ========== Matrix Product 2x2 at 3x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 2x2 ========= //
|
// ========== Matrix Product 2x3 at 2x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
|
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||||
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
|
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
|
|
||||||
const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
|
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||||
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
|
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 2x3 at 3x2 ========= //
|
// ========== Matrix Product 2x3 at 3x2 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
|
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||||
product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
|
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||||
product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3;
|
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2)
|
||||||
{
|
{
|
||||||
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1;
|
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
|
||||||
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2;
|
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
|
||||||
product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3;
|
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1;
|
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
|
||||||
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2;
|
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
|
||||||
product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3;
|
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
|
||||||
|
|
||||||
product->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1;
|
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
|
||||||
product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2;
|
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
|
||||||
product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3;
|
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||||
{
|
{
|
||||||
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||||
{
|
{
|
||||||
product->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
|
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
|
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
|
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
|
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 2x3 ========= //
|
// ========== Matrix Product 3x3 at 2x3 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
|
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||||
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
|
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
|
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||||
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
|
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x3 at 3x3 ========= //
|
// ========== Matrix Product 3x3 at 3x3 ========= //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
|
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
|
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
|
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||||
const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
|
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||||
const float row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3;
|
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
product->row3_col3 = row3_col3;
|
product->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1;
|
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2;
|
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3;
|
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1;
|
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2;
|
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3;
|
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||||
|
|
||||||
const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1;
|
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||||
const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2;
|
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||||
const double row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3;
|
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||||
|
|
||||||
product->row1_col1 = row1_col1;
|
product->r1c1 = r1c1;
|
||||||
product->row1_col2 = row1_col2;
|
product->r1c2 = r1c2;
|
||||||
product->row1_col3 = row1_col3;
|
product->r1c3 = r1c3;
|
||||||
|
|
||||||
product->row2_col1 = row2_col1;
|
product->r2c1 = r2c1;
|
||||||
product->row2_col2 = row2_col2;
|
product->r2c2 = r2c2;
|
||||||
product->row2_col3 = row2_col3;
|
product->r2c3 = r2c3;
|
||||||
|
|
||||||
product->row3_col1 = row3_col1;
|
product->r3c1 = r3c1;
|
||||||
product->row3_col2 = row3_col2;
|
product->r3c2 = r3c2;
|
||||||
product->row3_col3 = row3_col3;
|
product->r3c3 = r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _BGC_MATRIX_TYPES_H_
|
#endif // _BGC_MATRIX_TYPES_H_
|
||||||
|
|
|
||||||
|
|
@ -9,54 +9,54 @@
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix)
|
inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->row1_col2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
matrix->row2_col1 = 0.0f;
|
matrix->r2c1 = 0.0f;
|
||||||
matrix->row2_col2 = 0.0f;
|
matrix->r2c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix)
|
inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->row1_col2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
matrix->row2_col1 = 0.0;
|
matrix->r2c1 = 0.0;
|
||||||
matrix->row2_col2 = 0.0;
|
matrix->r2c2 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Identity ================== //
|
// ================== Identity ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix)
|
inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 1.0f;
|
matrix->r1c1 = 1.0f;
|
||||||
matrix->row1_col2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
matrix->row2_col1 = 0.0f;
|
matrix->r2c1 = 0.0f;
|
||||||
matrix->row2_col2 = 1.0f;
|
matrix->r2c2 = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix)
|
inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 1.0;
|
matrix->r1c1 = 1.0;
|
||||||
matrix->row1_col2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
matrix->row2_col1 = 0.0;
|
matrix->r2c1 = 0.0;
|
||||||
matrix->row2_col2 = 1.0;
|
matrix->r2c2 = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Set Diagonal ================ //
|
// ================ Set Diagonal ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2)
|
inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->row1_col2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
matrix->row2_col1 = 0.0f;
|
matrix->r2c1 = 0.0f;
|
||||||
matrix->row2_col2 = d2;
|
matrix->r2c2 = d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2)
|
inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = d1;
|
matrix->r1c1 = d1;
|
||||||
matrix->row1_col2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
matrix->row2_col1 = 0.0;
|
matrix->r2c1 = 0.0;
|
||||||
matrix->row2_col2 = d2;
|
matrix->r2c2 = d2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============== Rotation Matrix =============== //
|
// ============== Rotation Matrix =============== //
|
||||||
|
|
@ -67,10 +67,10 @@ inline void bgc_fp32_matrix2x2_make_for_turn(BGC_FP32_Matrix2x2* matrix, const f
|
||||||
const float cosine = cosf(radians);
|
const float cosine = cosf(radians);
|
||||||
const float sine = sinf(radians);
|
const float sine = sinf(radians);
|
||||||
|
|
||||||
matrix->row1_col1 = cosine;
|
matrix->r1c1 = cosine;
|
||||||
matrix->row1_col2 = -sine;
|
matrix->r1c2 = -sine;
|
||||||
matrix->row2_col1 = sine;
|
matrix->r2c1 = sine;
|
||||||
matrix->row2_col2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit)
|
inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit)
|
||||||
|
|
@ -79,36 +79,36 @@ inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const d
|
||||||
const double cosine = cos(radians);
|
const double cosine = cos(radians);
|
||||||
const double sine = sin(radians);
|
const double sine = sin(radians);
|
||||||
|
|
||||||
matrix->row1_col1 = cosine;
|
matrix->r1c1 = cosine;
|
||||||
matrix->row1_col2 = -sine;
|
matrix->r1c2 = -sine;
|
||||||
matrix->row2_col1 = sine;
|
matrix->r2c1 = sine;
|
||||||
matrix->row2_col2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix)
|
inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix)
|
inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1;
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Is Identity ================= //
|
// ================ Is Identity ================= //
|
||||||
|
|
||||||
inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix)
|
inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
return bgc_fp32_is_unit(matrix->row1_col1) && bgc_fp32_is_zero(matrix->row1_col2)
|
return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2)
|
||||||
&& bgc_fp32_is_zero(matrix->row2_col1) && bgc_fp32_is_unit(matrix->row2_col2);
|
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix)
|
inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
return bgc_fp64_is_unit(matrix->row1_col1) && bgc_fp64_is_zero(matrix->row1_col2)
|
return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2)
|
||||||
&& bgc_fp64_is_zero(matrix->row2_col1) && bgc_fp64_is_unit(matrix->row2_col2);
|
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Is Singular ================= //
|
// ================ Is Singular ================= //
|
||||||
|
|
@ -129,11 +129,11 @@ inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
BGC_FP32_Matrix2x2 product;
|
BGC_FP32_Matrix2x2 product;
|
||||||
|
|
||||||
product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1;
|
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
|
||||||
product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2;
|
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
|
||||||
|
|
||||||
product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1;
|
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
|
||||||
product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2;
|
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
|
||||||
|
|
||||||
return bgc_fp32_matrix2x2_is_identity(&product);
|
return bgc_fp32_matrix2x2_is_identity(&product);
|
||||||
}
|
}
|
||||||
|
|
@ -142,11 +142,11 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
BGC_FP64_Matrix2x2 product;
|
BGC_FP64_Matrix2x2 product;
|
||||||
|
|
||||||
product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1;
|
product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
|
||||||
product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2;
|
product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
|
||||||
|
|
||||||
product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1;
|
product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
|
||||||
product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2;
|
product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
|
||||||
|
|
||||||
return bgc_fp64_matrix2x2_is_identity(&product);
|
return bgc_fp64_matrix2x2_is_identity(&product);
|
||||||
}
|
}
|
||||||
|
|
@ -155,84 +155,84 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
|
inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
|
||||||
{
|
{
|
||||||
destination->row1_col1 = source->row1_col1;
|
destination->r1c1 = source->r1c1;
|
||||||
destination->row1_col2 = source->row1_col2;
|
destination->r1c2 = source->r1c2;
|
||||||
|
|
||||||
destination->row2_col1 = source->row2_col1;
|
destination->r2c1 = source->r2c1;
|
||||||
destination->row2_col2 = source->row2_col2;
|
destination->r2c2 = source->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
|
inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
|
||||||
{
|
{
|
||||||
destination->row1_col1 = source->row1_col1;
|
destination->r1c1 = source->r1c1;
|
||||||
destination->row1_col2 = source->row1_col2;
|
destination->r1c2 = source->r1c2;
|
||||||
|
|
||||||
destination->row2_col1 = source->row2_col1;
|
destination->r2c1 = source->r2c1;
|
||||||
destination->row2_col2 = source->row2_col2;
|
destination->r2c2 = source->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Swap ==================== //
|
// ==================== Swap ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const float row1_col1 = matrix2->row1_col1;
|
const float r1c1 = matrix2->r1c1;
|
||||||
const float row1_col2 = matrix2->row1_col2;
|
const float r1c2 = matrix2->r1c2;
|
||||||
|
|
||||||
const float row2_col1 = matrix2->row2_col1;
|
const float r2c1 = matrix2->r2c1;
|
||||||
const float row2_col2 = matrix2->row2_col2;
|
const float r2c2 = matrix2->r2c2;
|
||||||
|
|
||||||
matrix2->row1_col1 = matrix1->row1_col1;
|
matrix2->r1c1 = matrix1->r1c1;
|
||||||
matrix2->row1_col2 = matrix1->row1_col2;
|
matrix2->r1c2 = matrix1->r1c2;
|
||||||
|
|
||||||
matrix2->row2_col1 = matrix1->row2_col1;
|
matrix2->r2c1 = matrix1->r2c1;
|
||||||
matrix2->row2_col2 = matrix1->row2_col2;
|
matrix2->r2c2 = matrix1->r2c2;
|
||||||
|
|
||||||
matrix1->row1_col1 = row1_col1;
|
matrix1->r1c1 = r1c1;
|
||||||
matrix1->row1_col2 = row1_col2;
|
matrix1->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->row2_col1 = row2_col1;
|
matrix1->r2c1 = r2c1;
|
||||||
matrix1->row2_col2 = row2_col2;
|
matrix1->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2)
|
inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
const double row1_col1 = matrix2->row1_col1;
|
const double r1c1 = matrix2->r1c1;
|
||||||
const double row1_col2 = matrix2->row1_col2;
|
const double r1c2 = matrix2->r1c2;
|
||||||
|
|
||||||
const double row2_col1 = matrix2->row2_col1;
|
const double r2c1 = matrix2->r2c1;
|
||||||
const double row2_col2 = matrix2->row2_col2;
|
const double r2c2 = matrix2->r2c2;
|
||||||
|
|
||||||
matrix2->row1_col1 = matrix1->row1_col1;
|
matrix2->r1c1 = matrix1->r1c1;
|
||||||
matrix2->row1_col2 = matrix1->row1_col2;
|
matrix2->r1c2 = matrix1->r1c2;
|
||||||
|
|
||||||
matrix2->row2_col1 = matrix1->row2_col1;
|
matrix2->r2c1 = matrix1->r2c1;
|
||||||
matrix2->row2_col2 = matrix1->row2_col2;
|
matrix2->r2c2 = matrix1->r2c2;
|
||||||
|
|
||||||
matrix1->row1_col1 = row1_col1;
|
matrix1->r1c1 = r1c1;
|
||||||
matrix1->row1_col2 = row1_col2;
|
matrix1->r1c2 = r1c2;
|
||||||
|
|
||||||
matrix1->row2_col1 = row2_col1;
|
matrix1->r2c1 = r2c1;
|
||||||
matrix1->row2_col2 = row2_col2;
|
matrix1->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Convert =================== //
|
// ================== Convert =================== //
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
|
inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source)
|
||||||
{
|
{
|
||||||
destination->row1_col1 = (float)source->row1_col1;
|
destination->r1c1 = (float)source->r1c1;
|
||||||
destination->row1_col2 = (float)source->row1_col2;
|
destination->r1c2 = (float)source->r1c2;
|
||||||
|
|
||||||
destination->row2_col1 = (float)source->row2_col1;
|
destination->r2c1 = (float)source->r2c1;
|
||||||
destination->row2_col2 = (float)source->row2_col2;
|
destination->r2c2 = (float)source->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
|
inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source)
|
||||||
{
|
{
|
||||||
destination->row1_col1 = source->row1_col1;
|
destination->r1c1 = source->r1c1;
|
||||||
destination->row1_col2 = source->row1_col2;
|
destination->r1c2 = source->r1c2;
|
||||||
|
|
||||||
destination->row2_col1 = source->row2_col1;
|
destination->r2c1 = source->r2c1;
|
||||||
destination->row2_col2 = source->row2_col2;
|
destination->r2c2 = source->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Get Inverse ================= //
|
// ================ Get Inverse ================= //
|
||||||
|
|
@ -245,19 +245,19 @@ inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float row1_col1 = matrix->row2_col2;
|
const float r1c1 = matrix->r2c2;
|
||||||
const float row1_col2 = -matrix->row1_col2;
|
const float r1c2 = -matrix->r1c2;
|
||||||
|
|
||||||
const float row2_col1 = -matrix->row2_col1;
|
const float r2c1 = -matrix->r2c1;
|
||||||
const float row2_col2 = matrix->row1_col1;
|
const float r2c2 = matrix->r1c1;
|
||||||
|
|
||||||
const float multiplier = 1.0f / determinant;
|
const float multiplier = 1.0f / determinant;
|
||||||
|
|
||||||
inverse->row1_col1 = row1_col1 * multiplier;
|
inverse->r1c1 = r1c1 * multiplier;
|
||||||
inverse->row1_col2 = row1_col2 * multiplier;
|
inverse->r1c2 = r1c2 * multiplier;
|
||||||
|
|
||||||
inverse->row2_col1 = row2_col1 * multiplier;
|
inverse->r2c1 = r2c1 * multiplier;
|
||||||
inverse->row2_col2 = row2_col2 * multiplier;
|
inverse->r2c2 = r2c2 * multiplier;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -270,19 +270,19 @@ inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double row1_col1 = matrix->row2_col2;
|
const double r1c1 = matrix->r2c2;
|
||||||
const double row1_col2 = -matrix->row1_col2;
|
const double r1c2 = -matrix->r1c2;
|
||||||
|
|
||||||
const double row2_col1 = -matrix->row2_col1;
|
const double r2c1 = -matrix->r2c1;
|
||||||
const double row2_col2 = matrix->row1_col1;
|
const double r2c2 = matrix->r1c1;
|
||||||
|
|
||||||
const double multiplier = 1.0 / determinant;
|
const double multiplier = 1.0 / determinant;
|
||||||
|
|
||||||
inverse->row1_col1 = row1_col1 * multiplier;
|
inverse->r1c1 = r1c1 * multiplier;
|
||||||
inverse->row1_col2 = row1_col2 * multiplier;
|
inverse->r1c2 = r1c2 * multiplier;
|
||||||
|
|
||||||
inverse->row2_col1 = row2_col1 * multiplier;
|
inverse->r2c1 = r2c1 * multiplier;
|
||||||
inverse->row2_col2 = row2_col2 * multiplier;
|
inverse->r2c2 = r2c2 * multiplier;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -303,40 +303,40 @@ inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix)
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix)
|
inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const float row1_col2 = matrix->row1_col2;
|
const float r1c2 = matrix->r1c2;
|
||||||
matrix->row1_col2 = matrix->row2_col1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
matrix->row2_col1 = row1_col2;
|
matrix->r2c1 = r1c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix)
|
inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const double row1_col2 = matrix->row1_col2;
|
const double r1c2 = matrix->r1c2;
|
||||||
matrix->row1_col2 = matrix->row2_col1;
|
matrix->r1c2 = matrix->r2c1;
|
||||||
matrix->row2_col1 = row1_col2;
|
matrix->r2c1 = r1c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Get Transpose ================ //
|
// =============== Get Transpose ================ //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix)
|
inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const float row1_col2 = matrix->row1_col2;
|
const float r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
transposed->row1_col1 = matrix->row1_col1;
|
transposed->r1c1 = matrix->r1c1;
|
||||||
transposed->row1_col2 = matrix->row2_col1;
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
transposed->row2_col1 = row1_col2;
|
transposed->r2c1 = r1c2;
|
||||||
transposed->row2_col2 = matrix->row2_col2;
|
transposed->r2c2 = matrix->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix)
|
inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const double row1_col2 = matrix->row1_col2;
|
const double r1c2 = matrix->r1c2;
|
||||||
|
|
||||||
transposed->row1_col1 = matrix->row1_col1;
|
transposed->r1c1 = matrix->r1c1;
|
||||||
transposed->row1_col2 = matrix->row2_col1;
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
transposed->row2_col1 = row1_col2;
|
transposed->r2c1 = r1c2;
|
||||||
transposed->row2_col2 = matrix->row2_col2;
|
transposed->r2c2 = matrix->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Get Row =================== //
|
// ================== Get Row =================== //
|
||||||
|
|
@ -344,14 +344,14 @@ inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, co
|
||||||
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number)
|
inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->row1_col1;
|
row->x1 = matrix->r1c1;
|
||||||
row->x2 = matrix->row1_col2;
|
row->x2 = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->row2_col1;
|
row->x1 = matrix->r2c1;
|
||||||
row->x2 = matrix->row2_col2;
|
row->x2 = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,14 +362,14 @@ inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Mat
|
||||||
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number)
|
inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
row->x1 = matrix->row1_col1;
|
row->x1 = matrix->r1c1;
|
||||||
row->x2 = matrix->row1_col2;
|
row->x2 = matrix->r1c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
row->x1 = matrix->row2_col1;
|
row->x1 = matrix->r2c1;
|
||||||
row->x2 = matrix->row2_col2;
|
row->x2 = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,28 +382,28 @@ inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Mat
|
||||||
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row)
|
inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->row1_col1 = row->x1;
|
matrix->r1c1 = row->x1;
|
||||||
matrix->row1_col2 = row->x2;
|
matrix->r1c2 = row->x2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->row2_col1 = row->x1;
|
matrix->r2c1 = row->x1;
|
||||||
matrix->row2_col2 = row->x2;
|
matrix->r2c2 = row->x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row)
|
inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row)
|
||||||
{
|
{
|
||||||
if (row_number == 1) {
|
if (row_number == 1) {
|
||||||
matrix->row1_col1 = row->x1;
|
matrix->r1c1 = row->x1;
|
||||||
matrix->row1_col2 = row->x2;
|
matrix->r1c2 = row->x2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_number == 2) {
|
if (row_number == 2) {
|
||||||
matrix->row2_col1 = row->x1;
|
matrix->r2c1 = row->x1;
|
||||||
matrix->row2_col2 = row->x2;
|
matrix->r2c2 = row->x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,14 +412,14 @@ inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row
|
||||||
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number)
|
inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->row1_col1;
|
column->x1 = matrix->r1c1;
|
||||||
column->x2 = matrix->row2_col1;
|
column->x2 = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->row1_col2;
|
column->x1 = matrix->r1c2;
|
||||||
column->x2 = matrix->row2_col2;
|
column->x2 = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -430,14 +430,14 @@ inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP
|
||||||
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number)
|
inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
column->x1 = matrix->row1_col1;
|
column->x1 = matrix->r1c1;
|
||||||
column->x2 = matrix->row2_col1;
|
column->x2 = matrix->r2c1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
column->x1 = matrix->row1_col2;
|
column->x1 = matrix->r1c2;
|
||||||
column->x2 = matrix->row2_col2;
|
column->x2 = matrix->r2c2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,28 +450,28 @@ inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP
|
||||||
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column)
|
inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->row1_col1 = column->x1;
|
matrix->r1c1 = column->x1;
|
||||||
matrix->row2_col1 = column->x2;
|
matrix->r2c1 = column->x2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->row1_col2 = column->x1;
|
matrix->r1c2 = column->x1;
|
||||||
matrix->row2_col2 = column->x2;
|
matrix->r2c2 = column->x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column)
|
inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column)
|
||||||
{
|
{
|
||||||
if (column_number == 1) {
|
if (column_number == 1) {
|
||||||
matrix->row1_col1 = column->x1;
|
matrix->r1c1 = column->x1;
|
||||||
matrix->row2_col1 = column->x2;
|
matrix->r2c1 = column->x2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_number == 2) {
|
if (column_number == 2) {
|
||||||
matrix->row1_col2 = column->x1;
|
matrix->r1c2 = column->x1;
|
||||||
matrix->row2_col2 = column->x2;
|
matrix->r2c2 = column->x2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,80 +479,80 @@ inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
||||||
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2)
|
||||||
{
|
{
|
||||||
sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1;
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2;
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
||||||
sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1;
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2;
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Add scaled ================= //
|
// ================= Add scaled ================= //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale)
|
inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale)
|
||||||
{
|
{
|
||||||
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale)
|
inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale)
|
||||||
{
|
{
|
||||||
sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale;
|
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
|
||||||
sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale;
|
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale;
|
sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale;
|
||||||
sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale;
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend)
|
inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend)
|
||||||
{
|
{
|
||||||
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
|
||||||
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend)
|
inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend)
|
||||||
{
|
{
|
||||||
difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1;
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2;
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
|
||||||
difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1;
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2;
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
|
inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier)
|
||||||
{
|
{
|
||||||
product->row1_col1 = multiplicand->row1_col1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->row1_col2 = multiplicand->row1_col2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
|
||||||
product->row2_col1 = multiplicand->row2_col1 * multiplier;
|
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||||
product->row2_col2 = multiplicand->row2_col2 * multiplier;
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
|
inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier)
|
||||||
{
|
{
|
||||||
product->row1_col1 = multiplicand->row1_col1 * multiplier;
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
product->row1_col2 = multiplicand->row1_col2 * multiplier;
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
|
||||||
product->row2_col1 = multiplicand->row2_col1 * multiplier;
|
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||||
product->row2_col2 = multiplicand->row2_col2 * multiplier;
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Divide =================== //
|
// =================== Divide =================== //
|
||||||
|
|
@ -573,30 +573,30 @@ inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, co
|
||||||
{
|
{
|
||||||
const float counter_phase = 1.0f - phase;
|
const float counter_phase = 1.0f - phase;
|
||||||
|
|
||||||
interpolation->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase;
|
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
|
||||||
interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase;
|
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
|
||||||
|
|
||||||
interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase;
|
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
|
||||||
interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase;
|
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase)
|
inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase)
|
||||||
{
|
{
|
||||||
const double counter_phase = 1.0 - phase;
|
const double counter_phase = 1.0 - phase;
|
||||||
|
|
||||||
interpolation->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase;
|
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
|
||||||
interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase;
|
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
|
||||||
|
|
||||||
interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase;
|
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
|
||||||
interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase;
|
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
|
inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
|
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const float x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
|
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x1 = x1;
|
||||||
product->x2 = x2;
|
product->x2 = x2;
|
||||||
|
|
@ -604,8 +604,8 @@ inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, co
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
|
inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2;
|
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const double x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2;
|
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x1 = x1;
|
||||||
product->x2 = x2;
|
product->x2 = x2;
|
||||||
|
|
@ -615,8 +615,8 @@ inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, co
|
||||||
|
|
||||||
inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
|
inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
|
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const float x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
|
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x1 = x1;
|
||||||
product->x2 = x2;
|
product->x2 = x2;
|
||||||
|
|
@ -624,8 +624,8 @@ inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, co
|
||||||
|
|
||||||
inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
|
inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1;
|
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const double x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2;
|
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
|
||||||
product->x1 = x1;
|
product->x1 = x1;
|
||||||
product->x2 = x2;
|
product->x2 = x2;
|
||||||
|
|
|
||||||
|
|
@ -9,166 +9,166 @@
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix)
|
inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 0.0f;
|
matrix->r1c1 = 0.0f;
|
||||||
matrix->row1_col2 = 0.0f;
|
matrix->r1c2 = 0.0f;
|
||||||
|
|
||||||
matrix->row2_col1 = 0.0f;
|
matrix->r2c1 = 0.0f;
|
||||||
matrix->row2_col2 = 0.0f;
|
matrix->r2c2 = 0.0f;
|
||||||
|
|
||||||
matrix->row3_col1 = 0.0f;
|
matrix->r3c1 = 0.0f;
|
||||||
matrix->row3_col2 = 0.0f;
|
matrix->r3c2 = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix)
|
inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix)
|
||||||
{
|
{
|
||||||
matrix->row1_col1 = 0.0;
|
matrix->r1c1 = 0.0;
|
||||||
matrix->row1_col2 = 0.0;
|
matrix->r1c2 = 0.0;
|
||||||
|
|
||||||
matrix->row2_col1 = 0.0;
|
matrix->r2c1 = 0.0;
|
||||||
matrix->row2_col2 = 0.0;
|
matrix->r2c2 = 0.0;
|
||||||
|
|
||||||
matrix->row3_col1 = 0.0;
|
matrix->r3c1 = 0.0;
|
||||||
matrix->row3_col2 = 0.0;
|
matrix->r3c2 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
|
inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source)
|
||||||
{
|
{
|
||||||
destination->row1_col1 = source->row1_col1;
|
destination->r1c1 = source->r1c1;
|
||||||
destination->row1_col2 = source->row1_col2;
|
destination->r1c2 = source->r1c2;
|
||||||
|
|
||||||
destination->row2_col1 = source->row2_col1;
|
destination->r2c1 = source->r2c1;
|
||||||