Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций

This commit is contained in:
Andrey Pokidov 2026-01-30 19:37:49 +07:00
parent d33daf4e2d
commit f7e41645fe
87 changed files with 4580 additions and 4051 deletions

View file

@ -4,9 +4,9 @@
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp"> <Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" /> <Depends filename="basic-geometry/basic-geometry.cbp" />
</Project> </Project>
<Project filename="basic-geometry/basic-geometry.cbp" />
<Project filename="basic-geometry-test/basic-geometry-test.cbp"> <Project filename="basic-geometry-test/basic-geometry-test.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" /> <Depends filename="basic-geometry/basic-geometry.cbp" />
</Project> </Project>
<Project filename="basic-geometry/basic-geometry.cbp" />
</Workspace> </Workspace>
</CodeBlocks_workspace_file> </CodeBlocks_workspace_file>

View file

@ -8,7 +8,7 @@
Programming language: C (C99) Programming language: C (C99)
Version: 0.2.0-dev Version: 0.3.0-dev
License: Apache-2.0 License: Apache-2.0

View file

@ -10,7 +10,7 @@
Язык программирования: Си (C99) Язык программирования: Си (C99)
Версия: 0.2.0-dev Версия: 0.3.0-dev
Лицензия: Apache-2.0 Лицензия: Apache-2.0

View file

@ -9,16 +9,16 @@
#include <time.h> #include <time.h>
#endif // _WINDOWS_ #endif // _WINDOWS_
BgcAffine3FP32* _create_bgc_affine3_list(int affine_amount) BGC_FP32_Affine3* _create_bgc_affine3_list(int affine_amount)
{ {
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32)); BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) { if (affines == 0) {
return 0; return 0;
} }
for (int i = 0; i < affine_amount; i++) { for (int i = 0; i < affine_amount; i++) {
bgc_affine3_reset_fp32(&affines[i]); bgc_fp32_affine3_reset(&affines[i]);
} }
return affines; return affines;
@ -29,18 +29,18 @@ float get_random_value_fp32()
return rand() * (2.0f / RAND_MAX) - 1.0f; return rand() * (2.0f / RAND_MAX) - 1.0f;
} }
BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount) BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
{ {
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32)); BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) { if (affines == 0) {
return 0; return 0;
} }
BgcPosition3FP32 position; BGC_FP32_Position3 position;
for (int i = 0; i < affine_amount; i++) { for (int i = 0; i < affine_amount; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
@ -52,20 +52,20 @@ BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount)
position.shift.x2 = get_random_value_fp32(); position.shift.x2 = get_random_value_fp32();
position.shift.x3 = get_random_value_fp32(); position.shift.x3 = get_random_value_fp32();
bgc_position3_get_outward_affine_fp32(&position, &affines[i]); bgc_fp32_position3_get_outward_affine(&position, &affines[i]);
} }
return affines; return affines;
} }
BgcVector3FP32* _create_bgc_vector3_list(int amount) BGC_FP32_Vector3* _create_bgc_vector3_list(int amount)
{ {
return malloc(amount * sizeof(BgcVector3FP32)); return malloc(amount * sizeof(BGC_FP32_Vector3));
} }
BgcVector3FP32* _create_bgc_vector3_random_list(int amount) BGC_FP32_Vector3* _create_bgc_vector3_random_list(int amount)
{ {
BgcVector3FP32* vectors = _create_bgc_vector3_list(amount); BGC_FP32_Vector3* vectors = _create_bgc_vector3_list(amount);
if (vectors == 0) { if (vectors == 0) {
return 0; return 0;
@ -82,9 +82,9 @@ BgcVector3FP32* _create_bgc_vector3_random_list(int amount)
float test_bgc_affine3_performance(int affine_amount, int vector_per_affine) float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
{ {
BgcAffine3FP32* affines; BGC_FP32_Affine3* affines;
BgcVector3FP32* source_vectors; BGC_FP32_Vector3* source_vectors;
BgcVector3FP32* result_vectors; BGC_FP32_Vector3* result_vectors;
int vector_index = 0; int vector_index = 0;
float time = -1.0f; float time = -1.0f;
@ -131,7 +131,7 @@ float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
for (int i = 0; i < affine_amount; i++) for (int i = 0; i < affine_amount; i++)
{ {
for (int j = 0; j < vector_per_affine; j++) { for (int j = 0; j < vector_per_affine; j++) {
bgc_affine3_transform_point_fp32(&affines[i], &source_vectors[vector_index], &result_vectors[vector_index]); bgc_fp32_affine3_transform_point(&affines[i], &source_vectors[vector_index], &result_vectors[vector_index]);
vector_index++; vector_index++;
} }
} }

View file

@ -10,7 +10,7 @@
#endif // _WINDOWS_ #endif // _WINDOWS_
typedef struct { typedef struct {
BgcVersorFP32 versor1, versor2, result; BGC_FP32_Versor versor1, versor2, result;
} structure_fp32_t; } structure_fp32_t;
structure_fp32_t* allocate_structures(const unsigned int amount) structure_fp32_t* allocate_structures(const unsigned int amount)
@ -29,7 +29,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
const float multiplier = 2.0f / RAND_MAX; const float multiplier = 2.0f / RAND_MAX;
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
@ -37,7 +37,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
&list[i].versor1 &list[i].versor1
); );
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
@ -45,37 +45,37 @@ structure_fp32_t* make_structures(const unsigned int amount)
&list[i].versor2 &list[i].versor2
); );
bgc_versor_reset_fp32(&list[i].result); bgc_fp32_versor_reset(&list[i].result);
} }
return list; return list;
} }
void print_versor_fp32(const BgcVersorFP32* versor) void print_versor_fp32(const BGC_FP32_Versor* versor)
{ {
printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
} }
void print_versor_fp64(const BgcVersorFP64* versor) void print_versor_fp64(const BGC_FP64_Versor* versor)
{ {
printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
} }
void print_vector_fp32(const BgcVector3FP32* vector) void print_vector_fp32(const BGC_FP32_Vector3* vector)
{ {
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector)); printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_fp32_vector3_get_modulus(vector));
} }
void print_vector_fp64(const BgcVector3FP64* vector) void print_vector_fp64(const BGC_FP64_Vector3* vector)
{ {
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(vector)); printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_fp64_vector3_get_modulus(vector));
} }
void list_work(const uint_fast32_t amount, structure_fp32_t* list) void list_work(const uint_fast32_t amount, structure_fp32_t* list)
{ {
for (uint_fast32_t j = 0; j < 1000; j++) { for (uint_fast32_t j = 0; j < 1000; j++) {
for (uint_fast32_t i = 0; i < amount; i++) { for (uint_fast32_t i = 0; i < amount; i++) {
bgc_versor_combine_fp32(&list[i].versor1, &list[i].versor1, &list[i].result); bgc_fp32_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result);
} }
} }
} }
@ -125,13 +125,13 @@ int main()
/* /*
int main() { int main() {
BgcComplexFP32 complex, exponent, result; BGC_FP32_Complex complex, exponent, result;
bgc_complex_set_values_fp32(0, 1, &complex); bgc_fp32_complex_make(0, 1, &complex);
bgc_complex_set_values_fp32(4, 0, &exponent); bgc_fp32_complex_make(4, 0, &exponent);
bgc_complex_get_exponation_fp32(&complex, exponent.real, exponent.imaginary, &result); bgc_fp32_complex_get_exponation(&complex, exponent.real, exponent.imaginary, &result);
printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary); printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary);
@ -140,10 +140,10 @@ int main() {
*/ */
/* /*
int main() { int main() {
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
BgcVersorFP32 result; BGC_FP32_Versor result;
bgc_versor_spherical_interpolation_fp32(&start, &end, 0.5f, &result); bgc_fp32_versor_spherical_interpolation(&start, &end, 0.5f, &result);
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3); printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
return 0; return 0;
} }
@ -152,79 +152,79 @@ int main() {
void test_basis_difference_fp32() void test_basis_difference_fp32()
{ {
BgcVector3FP32 initial_primary, initial_auxiliary; BGC_FP32_Vector3 initial_primary, initial_auxiliary;
BgcVector3FP32 final_primary, final_auxiliary; BGC_FP32_Vector3 final_primary, final_auxiliary;
BgcVersorFP32 turn; BGC_FP32_Versor turn;
// No turn // No turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 180 degree turn // 180 degree turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(-2.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(-2.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 5.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 5.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Zero vectors // Zero vectors
bgc_vector3_set_values_fp32(0.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(0.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
int code; int code;
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -235,12 +235,12 @@ void test_basis_difference_fp32()
} }
// Parallel vectors // Parallel vectors
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -251,60 +251,60 @@ void test_basis_difference_fp32()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-0.017452f, 0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-0.017452f, 0.999848f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(-0.999848f, -0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(-0.999848f, -0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.017452f, -0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.017452f, -0.999848f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 0.0f, -1.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 0.0f, -1.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 0.01 degree turn difference between initial_primary and initial_auxiliary directions // About 0.01 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(1.0f, 0.000001f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(1.0f, 0.000001f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, -1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, -1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
@ -313,77 +313,77 @@ void test_basis_difference_fp32()
void test_basis_difference_fp64() void test_basis_difference_fp64()
{ {
BgcVector3FP64 initial_primary, initial_auxiliary; BGC_FP64_Vector3 initial_primary, initial_auxiliary;
BgcVector3FP64 final_primary, final_auxiliary; BGC_FP64_Vector3 final_primary, final_auxiliary;
BgcVersorFP64 turn; BGC_FP64_Versor turn;
// No turn // No turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 180 degree turn // 180 degree turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 3.1, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(-2.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(-2.0, 3.1, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 5.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 5.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Zero vectors // Zero vectors
bgc_vector3_set_values_fp64(0.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(0.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
int code; int code;
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -394,12 +394,12 @@ void test_basis_difference_fp64()
} }
// Parallel vectors // Parallel vectors
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -410,60 +410,60 @@ void test_basis_difference_fp64()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-0.017452, 0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-0.017452, 0.999848, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(-0.999848, -0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(-0.999848, -0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.017452, -0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.017452, -0.999848, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 0.0, -1.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 0.0, -1.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 0.001 degree turn difference between initial_primary and initial_auxiliary directions // About 0.001 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(1.0, 0.000001, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(1.0, 0.000001, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, -1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, -1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
@ -473,15 +473,15 @@ void test_basis_difference_fp64()
int main() int main()
{ {
//BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; //BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
//BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; //BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
/* /*
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
BgcSlerpFP32 slerp; BGC_FP32_Slerp slerp;
BgcVersorFP32 result; BGC_FP32_Versor result;
bgc_slerp_make_full_fp32(&start, &end, &slerp); bgc_fp32_slerp_make_full(&start, &end, &slerp);
bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result); bgc_fp32_slerp_get_phase_versor(&slerp, 0.5f, &result);
print_versor_fp32(&result); print_versor_fp32(&result);
*/ */
@ -489,9 +489,9 @@ int main()
printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10)); printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
printf("sizeof(BgcAffine3FP32) = %zu\n", sizeof(BgcAffine3FP32)); printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3));
//printf("offsetof(shift) = %zu\n", offsetof(BgcAffine3FP32, shift)); //printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
printf("sizeof(BgcMatrix3x3FP32) = %zu\n", sizeof(BgcMatrix3x3FP32)); printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
return 0; return 0;
} }

View file

@ -25,19 +25,19 @@ typedef struct {
// =================== Versor =================== // // =================== Versor =================== //
typedef struct { typedef struct {
BgcVersorFP32 first, second; BGC_FP32_Versor first, second;
} TestVersorPairFP32; } TestVersorPairFP32;
typedef struct { typedef struct {
BgcVersorFP64 first, second; BGC_FP64_Versor first, second;
} TestVersorPairFP64; } TestVersorPairFP64;
typedef struct { typedef struct {
BgcVersorFP32 first, second, result; BGC_FP32_Versor first, second, result;
} TestVersorTripletFP32; } TestVersorTripletFP32;
typedef struct { typedef struct {
BgcVersorFP64 first, second, result; BGC_FP64_Versor first, second, result;
} TestVersorTripletFP64; } TestVersorTripletFP64;
// ================= Functions ================== // // ================= Functions ================== //

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 1.0f, 2.0f }, { 1.0f, 2.0f },
{ -4.0f, -3.0f }, { -4.0f, -3.0f },
{ -0.001f, 100.0f }, { -0.001f, 100.0f },
@ -16,13 +16,13 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
void test_complex_copy_fp32() void test_complex_copy_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_copy_fp32"); print_testing_name("bgc_fp32_complex_copy");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST[i], &vector); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real || if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) { vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) {
@ -37,7 +37,7 @@ void test_complex_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 1.0, 2.0 }, { 1.0, 2.0 },
{ -4.0, -3.0 }, { -4.0, -3.0 },
{ -0.001, 100.0 }, { -0.001, 100.0 },
@ -46,13 +46,13 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
void test_complex_copy_fp64() void test_complex_copy_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_copy_fp64"); print_testing_name("bgc_fp64_complex_copy");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST[i], &vector); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real || if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) { vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) {

View file

@ -7,35 +7,35 @@
static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10; static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6; static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP32 _TEST_FP32_UNIT_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_UNIT_COMPLEX_LIST[] = {
{ 1.0f, 0.0f }, { 1.0f, 0.0f },
{ -1.0f, 0.0f }, { -1.0f, 0.0f },
{ 0.6f, -0.8f }, { 0.6f, -0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.7071067812f, 0.7071067812f }, { 0.7071067812f, 0.7071067812f },
{ 0.7071067812f + 0.75f * BGC_EPSYLON_FP32, 0.7071067812f }, { 0.7071067812f + 0.75f * BGC_FP32_EPSYLON, 0.7071067812f },
{ 0.7071067812f, 0.7071067812f - 0.75f * BGC_EPSYLON_FP32 } { 0.7071067812f, 0.7071067812f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcComplexFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f + 1.25f * BGC_EPSYLON_FP32, 0.7071067812f + 1.25f * BGC_EPSYLON_FP32 }, { 0.7071067812f + 1.25f * BGC_FP32_EPSYLON, 0.7071067812f + 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f - 1.25f * BGC_EPSYLON_FP32, 0.7071067812f - 1.25f * BGC_EPSYLON_FP32 } { 0.7071067812f - 1.25f * BGC_FP32_EPSYLON, 0.7071067812f - 1.25f * BGC_FP32_EPSYLON }
}; };
void test_complex_is_unit_fp32() void test_complex_is_unit_fp32()
{ {
print_testing_name("bgc_complex_is_unit_fp32"); print_testing_name("bgc_fp32_complex_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp32(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) { if (!bgc_fp32_complex_is_unit(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized"); print_testing_error("A unit complex number was not recognized");
return; return;
} }
@ -43,7 +43,7 @@ void test_complex_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp32_complex_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number"); print_testing_error("A non-unit complex number was recognized a unit complex number");
return; return;
} }
@ -57,35 +57,35 @@ void test_complex_is_unit_fp32()
static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10; static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6; static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP64 _TEST_FP64_UNIT_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_UNIT_COMPLEX_LIST[] = {
{ 1.0, 0.0 }, { 1.0, 0.0 },
{ -1.0, 0.0 }, { -1.0, 0.0 },
{ -0.6, 0.8 }, { -0.6, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244, 0.7071067811865475244 }, { 0.7071067811865475244, 0.7071067811865475244 },
{ 0.7071067811865475244 + 0.75 * BGC_EPSYLON_FP64, 0.7071067811865475244 }, { 0.7071067811865475244 + 0.75 * BGC_FP64_EPSYLON, 0.7071067811865475244 },
{ 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_EPSYLON_FP64 } { 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcComplexFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64 }, { 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64 } { 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON }
}; };
void test_complex_is_unit_fp64() void test_complex_is_unit_fp64()
{ {
print_testing_name("bgc_complex_is_unit_fp64"); print_testing_name("bgc_fp64_complex_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp64(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) { if (!bgc_fp64_complex_is_unit(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized"); print_testing_error("A unit complex number was not recognized");
return; return;
} }
@ -93,7 +93,7 @@ void test_complex_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp64_complex_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number"); print_testing_error("A non-unit complex number was recognized a unit complex number");
return; return;
} }

View file

@ -7,31 +7,31 @@
static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7; static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP32 _TEST_FP32_ZERO_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_ZERO_COMPLEX_LIST[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcComplexFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f }, { 0.0f, 1.0f },
{ 1.25f * BGC_EPSYLON_FP32 }, { 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_EPSYLON_FP32 }, { -1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON }
}; };
void test_complex_is_zero_fp32() void test_complex_is_zero_fp32()
{ {
print_testing_name("bgc_complex_is_zero_fp32"); print_testing_name("bgc_fp32_complex_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp32(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) { if (!bgc_fp32_complex_is_zero(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized"); print_testing_error("A zero complex number was not recognized");
return; return;
} }
@ -39,7 +39,7 @@ void test_complex_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) { if (bgc_fp32_complex_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number"); print_testing_error("A non-zero complex number was recognized as a zero complex number");
return; return;
} }
@ -53,31 +53,31 @@ void test_complex_is_zero_fp32()
static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7; static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP64 _TEST_FP64_ZERO_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_ZERO_COMPLEX_LIST[] = {
{ 0.0, 0.0 }, { 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcComplexFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0 }, { 0.0, 1.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 } { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON }
}; };
void test_complex_is_zero_fp64() void test_complex_is_zero_fp64()
{ {
print_testing_name("bgc_complex_is_zero_fp64"); print_testing_name("bgc_fp64_complex_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp64(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) { if (!bgc_fp64_complex_is_zero(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized"); print_testing_error("A zero complex number was not recognized");
return; return;
} }
@ -85,7 +85,7 @@ void test_complex_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) { if (bgc_fp64_complex_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number"); print_testing_error("A non-zero complex number was recognized as a zero complex number");
return; return;
} }

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 4.0f, 3.0f }, { 4.0f, 3.0f },
{ -1.0f, 1.0f }, { -1.0f, 1.0f },
{ 100.0f, -100.0f }, { 100.0f, -100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_complex_square_modulus_fp32() void test_complex_square_modulus_fp32()
{ {
print_testing_name("bgc_complex_get_square_modulus_fp32"); print_testing_name("bgc_fp32_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_square_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_complex_get_square_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_complex_square_modulus_fp32()
void test_complex_modulus_fp32() void test_complex_modulus_fp32()
{ {
print_testing_name("bgc_complex_get_modulus_fp32"); print_testing_name("bgc_fp32_complex_get_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_complex_get_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_complex_modulus_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 4.0, 3.0 }, { 4.0, 3.0 },
{ -1.0, -1.0 }, { -1.0, -1.0 },
{ -100.0, 100.0 }, { -100.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_complex_square_modulus_fp64() void test_complex_square_modulus_fp64()
{ {
print_testing_name("bgc_complex_get_square_modulus_fp64"); print_testing_name("bgc_fp64_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_square_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_complex_get_square_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_complex_square_modulus_fp64()
void test_complex_modulus_fp64() void test_complex_modulus_fp64()
{ {
print_testing_name("bgc_complex_get_modulus_fp64"); print_testing_name("bgc_fp64_complex_get_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_complex_get_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_complex_reset_fp32() void test_complex_reset_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_reset_fp32"); print_testing_name("bgc_fp32_complex_reset");
bgc_complex_reset_fp32(&vector); bgc_fp32_complex_reset(&vector);
if (vector.real != 0.0f || vector.imaginary != 0.0f) { if (vector.real != 0.0f || vector.imaginary != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_complex_reset_fp32()
void test_complex_reset_fp64() void test_complex_reset_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_reset_fp64"); print_testing_name("bgc_fp64_complex_reset");
bgc_complex_reset_fp64(&vector); bgc_fp64_complex_reset(&vector);
if (vector.real != 0.0 || vector.imaginary != 0.0) { if (vector.real != 0.0 || vector.imaginary != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_complex_set_values_fp32() void test_complex_set_values_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_set_values_fp32"); print_testing_name("bgc_fp32_complex_make");
bgc_complex_set_values_fp32(1.0f, 2.0f, &vector); bgc_fp32_complex_make(1.0f, 2.0f, &vector);
if (vector.real != 1.0f || vector.imaginary != 2.0f) { if (vector.real != 1.0f || vector.imaginary != 2.0f) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_complex_set_values_fp32(-1.0f, -3.0f, &vector); bgc_fp32_complex_make(-1.0f, -3.0f, &vector);
if (vector.real != -1.0f || vector.imaginary != -3.0f) { if (vector.real != -1.0f || vector.imaginary != -3.0f) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_complex_set_values_fp32(-8.0f, -2.0f, &vector); bgc_fp32_complex_make(-8.0f, -2.0f, &vector);
if (vector.real != -8.0f || vector.imaginary != -2.0f) { if (vector.real != -8.0f || vector.imaginary != -2.0f) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");
@ -40,25 +40,25 @@ void test_complex_set_values_fp32()
void test_complex_set_values_fp64() void test_complex_set_values_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_set_values_fp64"); print_testing_name("bgc_fp64_complex_make");
bgc_complex_set_values_fp64(1.0, 2.0, &vector); bgc_fp64_complex_make(1.0, 2.0, &vector);
if (vector.real != 1.0 || vector.imaginary != 2.0) { if (vector.real != 1.0 || vector.imaginary != 2.0) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_complex_set_values_fp64(-1.0, -3.0, &vector); bgc_fp64_complex_make(-1.0, -3.0, &vector);
if (vector.real != -1.0 || vector.imaginary != -3.0) { if (vector.real != -1.0 || vector.imaginary != -3.0) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_complex_set_values_fp64(-8.0, -2.0, &vector); bgc_fp64_complex_make(-8.0, -2.0, &vector);
if (vector.real != -8.0 || vector.imaginary != -2.0) { if (vector.real != -8.0 || vector.imaginary != -2.0) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST1[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST1[] = {
{ 3.0f, 4.0f }, { 3.0f, 4.0f },
{ -2.0f, -1.0f }, { -2.0f, -1.0f },
{ -244.8f, 100.0f }, { -244.8f, 100.0f },
{ 1000.32f, -100.1f } { 1000.32f, -100.1f }
}; };
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST2[] = {
{ 5.3f, 1003.28f }, { 5.3f, 1003.28f },
{ -0.0032f, 891.3f }, { -0.0032f, 891.3f },
{ 5.322f, 0.9275f }, { 5.322f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = {
void test_complex_swap_fp32() void test_complex_swap_fp32()
{ {
BgcComplexFP32 compleimaginary, complex2; BGC_FP32_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp32"); print_testing_name("bgc_fp32_complex_swap");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST2[i], &complex2); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp32(&compleimaginary, &complex2); bgc_fp32_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real || if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary || compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary ||
@ -50,14 +50,14 @@ void test_complex_swap_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST1[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST1[] = {
{ 1.0, 4.0 }, { 1.0, 4.0 },
{ -4.0, -3.0 }, { -4.0, -3.0 },
{ -244.8, 344.7 }, { -244.8, 344.7 },
{ 1000.32, -271.3 } { 1000.32, -271.3 }
}; };
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST2[] = {
{ -0.123, 1003.28 }, { -0.123, 1003.28 },
{ 204.07, -781.89 }, { 204.07, -781.89 },
{ 5.322, 0.9275 }, { 5.322, 0.9275 },
@ -66,15 +66,15 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = {
void test_complex_swap_fp64() void test_complex_swap_fp64()
{ {
BgcComplexFP64 compleimaginary, complex2; BGC_FP64_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp64"); print_testing_name("bgc_fp64_complex_swap");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST2[i], &complex2); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp64(&compleimaginary, &complex2); bgc_fp64_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real || if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary || compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary ||

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_QUATERNION_AMOUNT = 4; static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f }, { -4.0f, -3.0f, -2.0f, -1.0f },
{ -0.001f, 100.0f, -100.0f, 0.001f }, { -0.001f, 100.0f, -100.0f, 0.001f },
@ -16,13 +16,13 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
void test_quaternion_copy_fp32() void test_quaternion_copy_fp32()
{ {
BgcQuaternionFP32 vector; BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp32"); print_testing_name("bgc_fp32_quaternion_copy");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST[i], &vector); bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 || if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 || vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 ||
@ -39,7 +39,7 @@ void test_quaternion_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_QUATERNION_AMOUNT = 4; static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 },
{ -4.0, -3.0, -2.0, -1.0 }, { -4.0, -3.0, -2.0, -1.0 },
{ -0.001, 100.0, -100.0, 0.001 }, { -0.001, 100.0, -100.0, 0.001 },
@ -48,13 +48,13 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
void test_quaternion_copy_fp64() void test_quaternion_copy_fp64()
{ {
BgcQuaternionFP64 vector; BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp64"); print_testing_name("bgc_fp64_quaternion_copy");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST[i], &vector); bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 || if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 || vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 ||

View file

@ -7,45 +7,45 @@
static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16; static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10; static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP32 _TEST_FP32_UNIT_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_UNIT_QUATERNION_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f }, { -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f, 0.0f }, { 0.0f, -0.8f, 0.6f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.5f, 0.5f, 0.5f, 0.5f }, { 0.5f, 0.5f, 0.5f, 0.5f },
{ 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f, 0.5f }, { 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f, 0.5f },
{ 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, { 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f, 0.5f, 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f }, { 0.5f, 0.5f, 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f },
{ 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32 } { 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcQuaternionFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, { 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.5f } { 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.5f }
}; };
void test_quaternion_is_unit_fp32() void test_quaternion_is_unit_fp32()
{ {
print_testing_name("bgc_quaternion_is_unit_fp32"); print_testing_name("bgc_fp32_quaternion_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp32(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) { if (!bgc_fp32_quaternion_is_unit(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized"); print_testing_error("A unit quaternion was not recognized");
return; return;
} }
@ -53,7 +53,7 @@ void test_quaternion_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp32_quaternion_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion"); print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return; return;
} }
@ -67,45 +67,45 @@ void test_quaternion_is_unit_fp32()
static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16; static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10; static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP64 _TEST_FP64_UNIT_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_UNIT_QUATERNION_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ -1.0, 0.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0, 0.0 },
{ 0.0, -0.6, 0.8, 0.0 }, { 0.0, -0.6, 0.8, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.5, 0.5, 0.5, 0.5 }, { 0.5, 0.5, 0.5, 0.5 },
{ 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5, 0.5 }, { 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5, 0.5 },
{ 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5 }, { 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5, 0.5, 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5 }, { 0.5, 0.5, 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5 },
{ 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64 } { 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcQuaternionFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5, 0.5 }, { 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.5 } { 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.5 }
}; };
void test_quaternion_is_unit_fp64() void test_quaternion_is_unit_fp64()
{ {
print_testing_name("bgc_quaternion_is_unit_fp64"); print_testing_name("bgc_fp64_quaternion_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp64(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) { if (!bgc_fp64_quaternion_is_unit(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized"); print_testing_error("A unit quaternion was not recognized");
return; return;
} }
@ -113,7 +113,7 @@ void test_quaternion_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp64_quaternion_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion"); print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return; return;
} }

View file

@ -7,39 +7,39 @@
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9; static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11; static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_ZERO_QUATERNION_LIST[] = {
{ 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}; };
void test_quaternion_is_zero_fp32() void test_quaternion_is_zero_fp32()
{ {
print_testing_name("bgc_quaternion_is_zero_fp32"); print_testing_name("bgc_fp32_quaternion_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp32(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) { if (!bgc_fp32_quaternion_is_zero(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized"); print_testing_error("A zero quaternion was not recognized");
return; return;
} }
@ -47,7 +47,7 @@ void test_quaternion_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) { if (bgc_fp32_quaternion_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion"); print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return; return;
} }
@ -61,39 +61,39 @@ void test_quaternion_is_zero_fp32()
static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9; static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11; static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 } { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}; };
void test_quaternion_is_zero_fp64() void test_quaternion_is_zero_fp64()
{ {
print_testing_name("bgc_quaternion_is_zero_fp64"); print_testing_name("bgc_fp64_quaternion_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) { if (!bgc_fp64_quaternion_is_zero(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized"); print_testing_error("A zero quaternion was not recognized");
return; return;
} }
@ -101,7 +101,7 @@ void test_quaternion_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) { if (bgc_fp64_quaternion_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion"); print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return; return;
} }

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -6,7 +6,7 @@
static const int _TEST_FP32_QUATERNION_AMOUNT = 4; static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 0.0f, 4.0f, 3.0f, 0.0f }, { 0.0f, 4.0f, 3.0f, 0.0f },
{ -1.0f, 1.0f, -1.0f, 1.0f }, { -1.0f, 1.0f, -1.0f, 1.0f },
{ 100.0f, -100.0f, 0.0f, 100.0f }, { 100.0f, -100.0f, 0.0f, 100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp32() void test_quaternion_square_modulus_fp32()
{ {
print_testing_name("bgc_quaternion_get_square_modulus_fp32"); print_testing_name("bgc_fp32_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_square_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_square_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_quaternion_square_modulus_fp32()
void test_quaternion_modulus_fp32() void test_quaternion_modulus_fp32()
{ {
print_testing_name("bgc_quaternion_get_modulus_fp32"); print_testing_name("bgc_fp32_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_quaternion_modulus_fp32()
static const int _TEST_FP64_QUATERNION_AMOUNT = 4; static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 0.0, 4.0, 3.0, 0.0 }, { 0.0, 4.0, 3.0, 0.0 },
{ -1.0, 1.0, -1.0, 1.0 }, { -1.0, 1.0, -1.0, 1.0 },
{ 100.0, -100.0, 0.0, 100.0 }, { 100.0, -100.0, 0.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp64() void test_quaternion_square_modulus_fp64()
{ {
print_testing_name("bgc_quaternion_get_square_modulus_fp64"); print_testing_name("bgc_fp64_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_quaternion_get_square_modulus_fp64(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_quaternion_get_square_modulus(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_quaternion_square_modulus_fp64()
void test_quaternion_modulus_fp64() void test_quaternion_modulus_fp64()
{ {
print_testing_name("bgc_quaternion_get_modulus_fp64"); print_testing_name("bgc_fp64_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {