Большое переупорядочивание исходного кода
This commit is contained in:
parent
fffe2be43b
commit
43bf030295
26 changed files with 1225 additions and 1137 deletions
|
|
@ -27,10 +27,11 @@
|
||||||
<Option type="1" />
|
<Option type="1" />
|
||||||
<Option compiler="gcc" />
|
<Option compiler="gcc" />
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-O2" />
|
<Add option="-O3" />
|
||||||
<Add directory="../basic-geometry" />
|
<Add directory="../basic-geometry" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
|
<Add option="-O3" />
|
||||||
<Add option="-s" />
|
<Add option="-s" />
|
||||||
<Add library="basic-geometry" />
|
<Add library="basic-geometry" />
|
||||||
<Add library="m" />
|
<Add library="m" />
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
@ -12,8 +11,6 @@
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BgcVersorFP32 versor1, versor2, result;
|
BgcVersorFP32 versor1, versor2, result;
|
||||||
//BgcMatrix3x3FP32 matrix;
|
|
||||||
//BgcVector3FP32 vector1, vector2;
|
|
||||||
} structure_fp32_t;
|
} structure_fp32_t;
|
||||||
|
|
||||||
structure_fp32_t* allocate_structures(const unsigned int amount)
|
structure_fp32_t* allocate_structures(const unsigned int amount)
|
||||||
|
|
@ -49,18 +46,6 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
);
|
);
|
||||||
|
|
||||||
bgc_versor_reset_fp32(&list[i].result);
|
bgc_versor_reset_fp32(&list[i].result);
|
||||||
|
|
||||||
//bgc_matrix3x3_set_to_identity_fp32(&list[i].matrix);
|
|
||||||
/*
|
|
||||||
bgc_vector3_set_values_fp32(
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
rand() * multiplier - 1.0f,
|
|
||||||
&list[i].vector1
|
|
||||||
);
|
|
||||||
|
|
||||||
bgc_vector3_reset_fp32(&list[i].vector2);
|
|
||||||
*//*
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
@ -94,7 +79,7 @@ void list_work(const uint_fast32_t amount, structure_fp32_t* list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const unsigned int amount = 1000000;
|
const unsigned int amount = 1000000;
|
||||||
|
|
@ -136,18 +121,3 @@ int main()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <basic-geometry.h>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
BgcVector3FP32 my_vector;
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector);
|
|
||||||
|
|
||||||
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,13 @@ static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
|
||||||
1.0f - 2.25f * BGC_EPSYLON_FP32
|
1.0f - 2.25f * BGC_EPSYLON_FP32
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_is_sqare_value_unit_fp32()
|
int test_is_sqare_unit_fp32()
|
||||||
{
|
{
|
||||||
print_testing_name("bgc_is_sqare_value_unit_fp32");
|
print_testing_name("bgc_is_sqare_unit_fp32");
|
||||||
|
|
||||||
// Testing unit values:
|
// Testing unit values:
|
||||||
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
||||||
if (!bgc_is_sqare_value_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
|
if (!bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
@ -120,7 +120,7 @@ int test_is_sqare_value_unit_fp32()
|
||||||
|
|
||||||
// Testing non-unit values:
|
// Testing non-unit values:
|
||||||
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
||||||
if (bgc_is_sqare_value_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
|
if (bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
@ -149,13 +149,13 @@ static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
|
||||||
1.0 - 2.25 * BGC_EPSYLON_FP64
|
1.0 - 2.25 * BGC_EPSYLON_FP64
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_is_sqare_value_unit_fp64()
|
int test_is_sqare_unit_fp64()
|
||||||
{
|
{
|
||||||
print_testing_name("bgc_is_sqare_value_unit_fp64");
|
print_testing_name("bgc_is_sqare_unit_fp64");
|
||||||
|
|
||||||
// Testing unit values:
|
// Testing unit values:
|
||||||
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
||||||
if (!bgc_is_sqare_value_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
|
if (!bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +163,7 @@ int test_is_sqare_value_unit_fp64()
|
||||||
|
|
||||||
// Testing non-unit values:
|
// Testing non-unit values:
|
||||||
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
||||||
if (bgc_is_sqare_value_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
|
if (bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
@ -184,11 +184,11 @@ int test_is_unit()
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_sqare_value_unit_fp32() != TEST_SUCCES) {
|
if (test_is_sqare_unit_fp32() != TEST_SUCCES) {
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_sqare_value_unit_fp64() != TEST_SUCCES) {
|
if (test_is_sqare_unit_fp64() != TEST_SUCCES) {
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ int test_is_unit_fp32();
|
||||||
|
|
||||||
int test_is_unit_fp64();
|
int test_is_unit_fp64();
|
||||||
|
|
||||||
int test_is_sqare_value_unit_fp32();
|
int test_is_sqare_unit_fp32();
|
||||||
|
|
||||||
int test_is_sqare_value_unit_fp64();
|
int test_is_sqare_unit_fp64();
|
||||||
|
|
||||||
int test_is_unit();
|
int test_is_unit();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ int test_vector2_fp32_square_modulus()
|
||||||
return TEST_SUCCES;
|
return TEST_SUCCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =================== Module =================== //
|
// ================== Modulus =================== //
|
||||||
|
|
||||||
const float FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
const float FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||||
|
|
||||||
|
|
@ -180,4 +180,4 @@ int test_fp32_vector2()
|
||||||
|
|
||||||
return TEST_SUCCES;
|
return TEST_SUCCES;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,13 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="matrix2x2.h" />
|
<Unit filename="matrix2x2.h" />
|
||||||
|
<Unit filename="matrix2x3.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="matrix2x3.h" />
|
<Unit filename="matrix2x3.h" />
|
||||||
|
<Unit filename="matrix3x2.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
<Unit filename="matrix3x2.h" />
|
<Unit filename="matrix3x2.h" />
|
||||||
<Unit filename="matrix3x3.c">
|
<Unit filename="matrix3x3.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,14 @@ extern inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix);
|
||||||
extern inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix);
|
extern inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix);
|
||||||
extern inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix);
|
extern inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix);
|
extern inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix);
|
||||||
extern inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix);
|
extern inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
|
extern inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix);
|
||||||
|
extern inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
|
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix);
|
||||||
|
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||||
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||||
|
|
@ -21,23 +27,11 @@ extern inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2
|
||||||
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to);
|
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to);
|
||||||
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP64* to);
|
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP64* to);
|
||||||
|
|
||||||
extern inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix);
|
|
||||||
extern inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix);
|
|
||||||
|
|
||||||
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix);
|
|
||||||
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix);
|
|
||||||
extern inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix);
|
|
||||||
|
|
||||||
extern inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix);
|
extern inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix);
|
||||||
extern inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix);
|
extern inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_set_transposed_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
extern inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix);
|
||||||
extern inline void bgc_matrix2x2_set_transposed_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
extern inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
extern inline int bgc_matrix2x2_set_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
|
||||||
extern inline int bgc_matrix2x2_set_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix);
|
extern inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix);
|
||||||
extern inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix);
|
extern inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix);
|
||||||
|
|
@ -51,6 +45,12 @@ extern inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double
|
||||||
extern inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix);
|
extern inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix);
|
||||||
extern inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix);
|
extern inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
|
extern inline int bgc_matrix2x2_make_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||||
|
extern inline int bgc_matrix2x2_make_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix2x2_make_transposed_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||||
|
extern inline void bgc_matrix2x2_make_transposed_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum);
|
extern inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum);
|
||||||
extern inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum);
|
extern inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum);
|
||||||
|
|
||||||
|
|
@ -60,14 +60,18 @@ extern inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_m
|
||||||
extern inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference);
|
extern inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference);
|
||||||
extern inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference);
|
extern inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference);
|
||||||
|
extern inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product);
|
extern inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product);
|
||||||
extern inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product);
|
extern inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient);
|
extern inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient);
|
||||||
extern inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient);
|
extern inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* result);
|
extern inline void bgc_matrix2x2_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product);
|
||||||
extern inline void bgc_matrix2x2_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* result);
|
extern inline void bgc_matrix2x2_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix2x2_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product);
|
||||||
|
extern inline void bgc_matrix2x2_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* result);
|
|
||||||
extern inline void bgc_matrix2x2_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* result);
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2,
|
||||||
|
|
||||||
// ============== Rotation Matrix =============== //
|
// ============== Rotation Matrix =============== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix)
|
inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
const float radians = bgc_angle_to_radians_fp32(angle, unit);
|
||||||
const float cosine = cosf(radians);
|
const float cosine = cosf(radians);
|
||||||
|
|
@ -73,7 +73,7 @@ inline void bgc_matrix2x2_make_rotation_fp32(const float angle, const BgcAngleUn
|
||||||
matrix->r2c2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix)
|
inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
const double radians = bgc_angle_to_radians_fp64(angle, unit);
|
||||||
const double cosine = cos(radians);
|
const double cosine = cos(radians);
|
||||||
|
|
@ -85,6 +85,30 @@ inline void bgc_matrix2x2_make_rotation_fp64(const double angle, const BgcAngleU
|
||||||
matrix->r2c2 = cosine;
|
matrix->r2c2 = cosine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
|
inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix)
|
||||||
|
{
|
||||||
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix)
|
||||||
|
{
|
||||||
|
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Singular ================== //
|
||||||
|
|
||||||
|
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix)
|
||||||
|
{
|
||||||
|
return bgc_is_zero_fp32(bgc_matrix2x2_get_determinant_fp32(matrix));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
|
||||||
|
{
|
||||||
|
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix));
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
||||||
|
|
@ -149,7 +173,7 @@ inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64*
|
||||||
matrix1->r2c2 = r2c2;
|
matrix1->r2c2 = r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ================== Convert =================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to)
|
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to)
|
||||||
{
|
{
|
||||||
|
|
@ -169,47 +193,7 @@ inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, Bgc
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// =================== Invert =================== //
|
||||||
|
|
||||||
inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix)
|
|
||||||
{
|
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix)
|
|
||||||
{
|
|
||||||
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Singular ================== //
|
|
||||||
|
|
||||||
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix)
|
|
||||||
{
|
|
||||||
return bgc_is_zero_fp32(bgc_matrix2x2_get_determinant_fp32(matrix));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
|
|
||||||
{
|
|
||||||
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix));
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============== Transposition ================ //
|
|
||||||
|
|
||||||
inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix)
|
|
||||||
{
|
|
||||||
const float tmp = matrix->r1c2;
|
|
||||||
matrix->r1c2 = matrix->r2c1;
|
|
||||||
matrix->r2c1 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix)
|
|
||||||
{
|
|
||||||
const double tmp = matrix->r1c2;
|
|
||||||
matrix->r1c2 = matrix->r2c1;
|
|
||||||
matrix->r2c1 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================= Inversion ================== //
|
|
||||||
|
|
||||||
inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
|
|
@ -261,80 +245,20 @@ inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Set Transposed =============== //
|
// ================= Transpose ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_transposed_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix)
|
||||||
{
|
{
|
||||||
float tmp = from->r1c2;
|
const float tmp = matrix->r1c2;
|
||||||
|
matrix->r1c2 = matrix->r2c1;
|
||||||
to->r1c1 = from->r1c1;
|
matrix->r2c1 = tmp;
|
||||||
to->r1c2 = from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = tmp;
|
|
||||||
to->r2c2 = from->r2c2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_set_transposed_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix)
|
||||||
{
|
{
|
||||||
double tmp = from->r1c2;
|
const double tmp = matrix->r1c2;
|
||||||
|
matrix->r1c2 = matrix->r2c1;
|
||||||
to->r1c1 = from->r1c1;
|
matrix->r2c1 = tmp;
|
||||||
to->r1c2 = from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = tmp;
|
|
||||||
to->r2c2 = from->r2c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================ Set Inverted ================ //
|
|
||||||
|
|
||||||
inline int bgc_matrix2x2_set_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
|
||||||
{
|
|
||||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
|
||||||
|
|
||||||
if (bgc_is_zero_fp32(determinant)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float r1c1 = from->r2c2;
|
|
||||||
const float r1c2 = -from->r1c2;
|
|
||||||
|
|
||||||
const float r2c1 = -from->r2c1;
|
|
||||||
const float r2c2 = from->r1c1;
|
|
||||||
|
|
||||||
const float multiplier = 1.0f / determinant;
|
|
||||||
|
|
||||||
to->r1c1 = r1c1 * multiplier;
|
|
||||||
to->r1c2 = r1c2 * multiplier;
|
|
||||||
|
|
||||||
to->r2c1 = r2c1 * multiplier;
|
|
||||||
to->r2c2 = r2c2 * multiplier;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int bgc_matrix2x2_set_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
|
||||||
{
|
|
||||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
|
||||||
|
|
||||||
if (bgc_is_zero_fp64(determinant)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double r1c1 = from->r2c2;
|
|
||||||
const double r1c2 = -from->r1c2;
|
|
||||||
|
|
||||||
const double r2c1 = -from->r2c1;
|
|
||||||
const double r2c2 = from->r1c1;
|
|
||||||
|
|
||||||
const double multiplier = 1.0 / determinant;
|
|
||||||
|
|
||||||
to->r1c1 = r1c1 * multiplier;
|
|
||||||
to->r1c2 = r1c2 * multiplier;
|
|
||||||
|
|
||||||
to->r2c1 = r2c1 * multiplier;
|
|
||||||
to->r2c2 = r2c2 * multiplier;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
@ -393,7 +317,83 @@ inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, Bgc
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// =============== Make Inverted ================ //
|
||||||
|
|
||||||
|
inline int bgc_matrix2x2_make_inverted_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted)
|
||||||
|
{
|
||||||
|
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||||
|
|
||||||
|
if (bgc_is_zero_fp32(determinant)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float r1c1 = matrix->r2c2;
|
||||||
|
const float r1c2 = -matrix->r1c2;
|
||||||
|
|
||||||
|
const float r2c1 = -matrix->r2c1;
|
||||||
|
const float r2c2 = matrix->r1c1;
|
||||||
|
|
||||||
|
const float multiplier = 1.0f / determinant;
|
||||||
|
|
||||||
|
inverted->r1c1 = r1c1 * multiplier;
|
||||||
|
inverted->r1c2 = r1c2 * multiplier;
|
||||||
|
|
||||||
|
inverted->r2c1 = r2c1 * multiplier;
|
||||||
|
inverted->r2c2 = r2c2 * multiplier;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_matrix2x2_make_inverted_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted)
|
||||||
|
{
|
||||||
|
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||||
|
|
||||||
|
if (bgc_is_zero_fp64(determinant)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double r1c1 = matrix->r2c2;
|
||||||
|
const double r1c2 = -matrix->r1c2;
|
||||||
|
|
||||||
|
const double r2c1 = -matrix->r2c1;
|
||||||
|
const double r2c2 = matrix->r1c1;
|
||||||
|
|
||||||
|
const double multiplier = 1.0 / determinant;
|
||||||
|
|
||||||
|
inverted->r1c1 = r1c1 * multiplier;
|
||||||
|
inverted->r1c2 = r1c2 * multiplier;
|
||||||
|
|
||||||
|
inverted->r2c1 = r2c1 * multiplier;
|
||||||
|
inverted->r2c2 = r2c2 * multiplier;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============== Make Transposed =============== //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_make_transposed_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed)
|
||||||
|
{
|
||||||
|
float tmp = matrix->r1c2;
|
||||||
|
|
||||||
|
transposed->r1c1 = matrix->r1c1;
|
||||||
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
|
transposed->r2c1 = tmp;
|
||||||
|
transposed->r2c2 = matrix->r2c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_make_transposed_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed)
|
||||||
|
{
|
||||||
|
double tmp = matrix->r1c2;
|
||||||
|
|
||||||
|
transposed->r1c1 = matrix->r1c1;
|
||||||
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
|
transposed->r2c1 = tmp;
|
||||||
|
transposed->r2c2 = matrix->r2c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum)
|
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum)
|
||||||
{
|
{
|
||||||
|
|
@ -433,7 +433,7 @@ inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix,
|
||||||
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference)
|
inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference)
|
||||||
{
|
{
|
||||||
|
|
@ -453,7 +453,27 @@ inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const B
|
||||||
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// ============== Subtract scaled =============== //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
|
||||||
|
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
|
||||||
|
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
|
||||||
|
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
|
||||||
|
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product)
|
inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product)
|
||||||
{
|
{
|
||||||
|
|
@ -473,7 +493,7 @@ inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, co
|
||||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Division ================== //
|
// =================== Divide =================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient)
|
inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient)
|
||||||
{
|
{
|
||||||
|
|
@ -487,42 +507,42 @@ inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const do
|
||||||
|
|
||||||
// ============ Left Vector Product ============= //
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* result)
|
inline void bgc_matrix2x2_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product)
|
||||||
{
|
{
|
||||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
|
||||||
result->x1 = x1;
|
product->x1 = x1;
|
||||||
result->x2 = x2;
|
product->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* result)
|
inline void bgc_matrix2x2_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product)
|
||||||
{
|
{
|
||||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
|
||||||
result->x1 = x1;
|
product->x1 = x1;
|
||||||
result->x2 = x2;
|
product->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Right Vector Product ============ //
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* result)
|
inline void bgc_matrix2x2_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product)
|
||||||
{
|
{
|
||||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
||||||
result->x1 = x1;
|
product->x1 = x1;
|
||||||
result->x2 = x2;
|
product->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void bgc_matrix2x2_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* result)
|
inline void bgc_matrix2x2_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product)
|
||||||
{
|
{
|
||||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
|
||||||
result->x1 = x1;
|
product->x1 = x1;
|
||||||
result->x2 = x2;
|
product->x2 = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,6 @@ extern inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2
|
||||||
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to);
|
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to);
|
||||||
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP64* to);
|
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP64* to);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x3_set_transposed_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP32* to);
|
|
||||||
extern inline void bgc_matrix2x3_set_transposed_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP64* to);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix2x3_set_transposed_fp32_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP32* to);
|
|
||||||
extern inline void bgc_matrix2x3_set_transposed_fp64_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP64* to);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
|
extern inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
|
||||||
extern inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
|
extern inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
|
||||||
|
|
||||||
|
|
@ -33,6 +27,9 @@ extern inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double
|
||||||
extern inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix);
|
extern inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix);
|
||||||
extern inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix);
|
extern inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix2x3_make_transposed_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP32* to);
|
||||||
|
extern inline void bgc_matrix2x3_make_transposed_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP64* to);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum);
|
extern inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum);
|
||||||
extern inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum);
|
extern inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum);
|
||||||
|
|
||||||
|
|
@ -42,6 +39,9 @@ extern inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_m
|
||||||
extern inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference);
|
extern inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference);
|
||||||
extern inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference);
|
extern inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference);
|
||||||
|
extern inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product);
|
extern inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product);
|
||||||
extern inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product);
|
extern inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64*
|
||||||
matrix1->r3c2 = r3c2;
|
matrix1->r3c2 = r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ================== Convert =================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to)
|
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to)
|
||||||
{
|
{
|
||||||
|
|
@ -145,58 +145,6 @@ inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* from, Bgc
|
||||||
to->r3c2 = from->r3c2;
|
to->r3c2 = from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
|
||||||
|
|
||||||
inline void bgc_matrix2x3_set_transposed_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP32* to)
|
|
||||||
{
|
|
||||||
to->r1c1 = from->r1c1;
|
|
||||||
to->r1c2 = from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = from->r1c2;
|
|
||||||
to->r2c2 = from->r2c2;
|
|
||||||
|
|
||||||
to->r3c1 = from->r1c3;
|
|
||||||
to->r3c2 = from->r2c3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_matrix2x3_set_transposed_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP64* to)
|
|
||||||
{
|
|
||||||
to->r1c1 = from->r1c1;
|
|
||||||
to->r1c2 = from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = from->r1c2;
|
|
||||||
to->r2c2 = from->r2c2;
|
|
||||||
|
|
||||||
to->r3c1 = from->r1c3;
|
|
||||||
to->r3c2 = from->r2c3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============== Set transposed =============== //
|
|
||||||
|
|
||||||
inline void bgc_matrix2x3_set_transposed_fp32_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP32* to)
|
|
||||||
{
|
|
||||||
to->r1c1 = (float) from->r1c1;
|
|
||||||
to->r1c2 = (float) from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = (float) from->r1c2;
|
|
||||||
to->r2c2 = (float) from->r2c2;
|
|
||||||
|
|
||||||
to->r3c1 = (float) from->r1c3;
|
|
||||||
to->r3c2 = (float) from->r2c3;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void bgc_matrix2x3_set_transposed_fp64_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP64* to)
|
|
||||||
{
|
|
||||||
to->r1c1 = from->r1c1;
|
|
||||||
to->r1c2 = from->r2c1;
|
|
||||||
|
|
||||||
to->r2c1 = from->r1c2;
|
|
||||||
to->r2c2 = from->r2c2;
|
|
||||||
|
|
||||||
to->r3c1 = from->r1c3;
|
|
||||||
to->r3c2 = from->r2c3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix)
|
inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix)
|
||||||
|
|
@ -271,7 +219,34 @@ inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, con
|
||||||
matrix->r3c2 = r3;
|
matrix->r3c2 = r3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ============== Make transposed =============== //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_make_transposed_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed)
|
||||||
|
{
|
||||||
|
transposed->r1c1 = matrix->r1c1;
|
||||||
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
|
transposed->r2c1 = matrix->r1c2;
|
||||||
|
transposed->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
|
transposed->r3c1 = matrix->r1c3;
|
||||||
|
transposed->r3c2 = matrix->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_make_transposed_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed)
|
||||||
|
{
|
||||||
|
transposed->r1c1 = matrix->r1c1;
|
||||||
|
transposed->r1c2 = matrix->r2c1;
|
||||||
|
|
||||||
|
transposed->r2c1 = matrix->r1c2;
|
||||||
|
transposed->r2c2 = matrix->r2c2;
|
||||||
|
|
||||||
|
transposed->r3c1 = matrix->r1c3;
|
||||||
|
transposed->r3c2 = matrix->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== Add ===================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum)
|
inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum)
|
||||||
{
|
{
|
||||||
|
|
@ -323,7 +298,7 @@ inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix,
|
||||||
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Subtraction ================= //
|
// ================== Subtract ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference)
|
inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference)
|
||||||
{
|
{
|
||||||
|
|
@ -349,7 +324,33 @@ inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const B
|
||||||
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Multiplication =============== //
|
// ============== Subtract scaled =============== //
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
|
||||||
|
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
|
||||||
|
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
|
||||||
|
|
||||||
|
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
|
||||||
|
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
|
||||||
|
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
|
||||||
|
|
||||||
|
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
|
||||||
|
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
|
||||||
|
|
||||||
|
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
|
||||||
|
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Multiply ================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product)
|
inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product)
|
||||||
{
|
{
|
||||||
|
|
@ -375,7 +376,7 @@ inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, co
|
||||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================== Division ================== //
|
// =================== Divide =================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient)
|
inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,6 @@ extern inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3
|
||||||
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP32* to);
|
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP32* to);
|
||||||
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP64* to);
|
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP64* to);
|
||||||
|
|
||||||
extern inline void bgc_matrix3x2_set_transposed_fp32(const BgcMatrix2x3FP32* from, BgcMatrix3x2FP32* to);
|
|
||||||
extern inline void bgc_matrix3x2_set_transposed_fp64(const BgcMatrix2x3FP64* from, BgcMatrix3x2FP64* to);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix3x2_set_transposed_fp32_fp64(const BgcMatrix2x3FP64* from, BgcMatrix3x2FP32* to);
|
|
||||||
extern inline void bgc_matrix3x2_set_transposed_fp64_fp32(const BgcMatrix2x3FP32* from, BgcMatrix3x2FP64* to);
|
|
||||||
|
|
||||||
extern inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix);
|
extern inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix);
|
||||||
extern inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix);
|
extern inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix);
|
||||||
|
|
||||||
|
|
@ -33,6 +27,9 @@ extern inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double
|
||||||
extern inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
|
extern inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
|
||||||
extern inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
|
extern inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
|
||||||
|
|
||||||
|
extern inline void bgc_matrix3x2_make_transposed_fp32(const BgcMatrix2x3FP32* from, BgcMatrix3x2FP32* to);
|
||||||
|
extern inline void bgc_matrix3x2_make_transposed_fp64(const BgcMatrix2x3FP64* from, BgcMatrix3x2FP64* to);
|
||||||
|
|
||||||
extern inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum);
|
extern inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum);
|
||||||
extern inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum);
|
extern inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum);
|
||||||
|
|
||||||
|
|
@ -42,6 +39,9 @@ extern inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_m
|
||||||