Compare commits
No commits in common. "2a4d5522d32ff88cf2c66a257022041d518638db" and "34ee460873d0972788e037806bb43d6e643c32fa" have entirely different histories.
2a4d5522d3
...
34ee460873
56 changed files with 723 additions and 4768 deletions
|
|
@ -53,12 +53,12 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
||||||
|
|
||||||
void print_versor_fp32(const BgcVersorFP32* versor)
|
void print_versor_fp32(const BgcVersorFP32* 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 (%f, %f, %f, %f)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_versor_fp64(const BgcVersorFP64* versor)
|
void print_versor_fp64(const BgcVersorFP64* 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 (%lf, %lf, %lf, %lf)\n", versor->s0, versor->x1, versor->x2, versor->x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_vector_fp32(const BgcVector3FP32* vector)
|
void print_vector_fp32(const BgcVector3FP32* vector)
|
||||||
|
|
@ -79,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;
|
||||||
|
|
@ -121,369 +121,3 @@ int main()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
int main() {
|
|
||||||
BgcComplexFP32 complex, exponent, result;
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(0, 1, &complex);
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(4, 0, &exponent);
|
|
||||||
|
|
||||||
bgc_complex_get_exponation_fp32(&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);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
int main() {
|
|
||||||
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|
||||||
BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f };
|
|
||||||
BgcVersorFP32 result;
|
|
||||||
bgc_versor_spherical_interpolation_fp32(&start, &end, 0.5f, &result);
|
|
||||||
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void test_basis_difference_fp32()
|
|
||||||
{
|
|
||||||
|
|
||||||
BgcVector3FP32 initial_primary, initial_auxiliary;
|
|
||||||
BgcVector3FP32 final_primary, final_auxiliary;
|
|
||||||
BgcVersorFP32 turn;
|
|
||||||
|
|
||||||
// No turn
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nNo turn:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// Turn around (1, 1, 0) axis on 180 degrees
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// 180 degree turn
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n180 degree turn around (0, 1, 0):\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// 90 degree turn around x3 axis
|
|
||||||
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 3.1f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n90 degree turn around (0, 0, 1):\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// Unorthogonal pairs turn at 90 degrees around x3 axis
|
|
||||||
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(-2.0f, 3.1f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(-1.0f, 5.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// Zero vectors
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
int code;
|
|
||||||
|
|
||||||
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
if (code >= 0) {
|
|
||||||
printf("\nZero vectors: this cannot be!\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("\nZero vector validation works fine\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parallel vectors
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
if (code >= 0) {
|
|
||||||
printf("\nParallel vectors: this cannot be!\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("\nParallelism validation works fine\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Small angle turn (about 1 degree):
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(-0.017452f, 0.999848f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nSmall angle turn (about 1 degree):\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// About 179 degrees turn
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-0.999848f, -0.017452f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.017452f, -0.999848f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 179 degrees turn:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// 120 degrees around (-1, -1, 1)
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 0.0f, -1.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n120 degees turn:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
|
|
||||||
// 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_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
|
|
||||||
// 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_vector3_set_values_fp32(1.0f, 0.000001f, 0.0f, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp32(0.0f, -1.0f, 0.0f, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
|
|
||||||
print_versor_fp32(&turn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_basis_difference_fp64()
|
|
||||||
{
|
|
||||||
|
|
||||||
BgcVector3FP64 initial_primary, initial_auxiliary;
|
|
||||||
BgcVector3FP64 final_primary, final_auxiliary;
|
|
||||||
BgcVersorFP64 turn;
|
|
||||||
|
|
||||||
// No turn
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nNo turn:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// Turn around (1, 1, 0) axis on 180 degrees
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// 180 degree turn
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n180 degree turn around (0, 1, 0):\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// 90 degree turn around x3 axis
|
|
||||||
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 3.1, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n90 degree turn around (0, 0, 1):\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// Unorthogonal pairs turn at 90 degrees around x3 axis
|
|
||||||
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(-2.0, 3.1, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(-1.0, 5.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// Zero vectors
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
int code;
|
|
||||||
|
|
||||||
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
if (code >= 0) {
|
|
||||||
printf("\nZero vectors: this cannot be!\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("\nZero vector validation works fine\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parallel vectors
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
if (code >= 0) {
|
|
||||||
printf("\nParallel vectors: this cannot be!\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("\nParallelism validation works fine\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Small angle turn (about 1 degree):
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(-0.017452, 0.999848, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nSmall angle turn (about 1 degree):\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// About 179 degrees turn
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(-0.999848, -0.017452, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.017452, -0.999848, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 179 degrees turn:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// 120 degrees around (-1, -1, 1)
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary);
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 0.0, -1.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\n120 degees turn:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
|
|
||||||
// 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_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
|
|
||||||
// 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_vector3_set_values_fp64(1.0, 0.000001, 0.0, &initial_auxiliary);
|
|
||||||
bgc_vector3_set_values_fp64(0.0, -1.0, 0.0, &final_primary);
|
|
||||||
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary);
|
|
||||||
|
|
||||||
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
|
|
||||||
|
|
||||||
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
|
|
||||||
print_versor_fp64(&turn);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
//BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|
||||||
//BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f };
|
|
||||||
/*
|
|
||||||
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|
||||||
BgcVersorFP32 end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
|
|
||||||
BgcSlerpFP32 slerp;
|
|
||||||
BgcVersorFP32 result;
|
|
||||||
bgc_slerp_make_fp32(&start, &end, &slerp);
|
|
||||||
bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result);
|
|
||||||
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
|
|
||||||
*/
|
|
||||||
|
|
||||||
test_basis_difference_fp64();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -49,38 +49,6 @@
|
||||||
<Unit filename="main.c">
|
<Unit filename="main.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="tests/complex.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex.h" />
|
|
||||||
<Unit filename="tests/complex/complex_copy.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_copy.h" />
|
|
||||||
<Unit filename="tests/complex/complex_is_unit.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_is_unit.h" />
|
|
||||||
<Unit filename="tests/complex/complex_is_zero.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_is_zero.h" />
|
|
||||||
<Unit filename="tests/complex/complex_modulus.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_modulus.h" />
|
|
||||||
<Unit filename="tests/complex/complex_reset.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_reset.h" />
|
|
||||||
<Unit filename="tests/complex/complex_set_values.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_set_values.h" />
|
|
||||||
<Unit filename="tests/complex/complex_swap.c">
|
|
||||||
<Option compilerVar="CC" />
|
|
||||||
</Unit>
|
|
||||||
<Unit filename="tests/complex/complex_swap.h" />
|
|
||||||
<Unit filename="tests/quaternion.c">
|
<Unit filename="tests/quaternion.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -150,15 +150,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="helpers.c" />
|
<ClCompile Include="helpers.c" />
|
||||||
<ClCompile Include="main.c" />
|
<ClCompile Include="main.c" />
|
||||||
<ClCompile Include="tests\complex.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_copy.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_is_unit.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_is_zero.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_modulus.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_reset.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_set_values.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_swap.c" />
|
|
||||||
<ClCompile Include="tests\complex\complex_arithmetics.c" />
|
|
||||||
<ClCompile Include="tests\quaternion.c" />
|
<ClCompile Include="tests\quaternion.c" />
|
||||||
<ClCompile Include="tests\quaternion\quaternion_copy.c" />
|
<ClCompile Include="tests\quaternion\quaternion_copy.c" />
|
||||||
<ClCompile Include="tests\quaternion\quaternion_is_unit.c" />
|
<ClCompile Include="tests\quaternion\quaternion_is_unit.c" />
|
||||||
|
|
@ -173,7 +164,6 @@
|
||||||
<ClCompile Include="tests\utilities\is_unit.c" />
|
<ClCompile Include="tests\utilities\is_unit.c" />
|
||||||
<ClCompile Include="tests\utilities\is_zero.c" />
|
<ClCompile Include="tests\utilities\is_zero.c" />
|
||||||
<ClCompile Include="tests\vector2.c" />
|
<ClCompile Include="tests\vector2.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_arithmetics.c" />
|
|
||||||
<ClCompile Include="tests\vector2\vector2_is_unit.c" />
|
<ClCompile Include="tests\vector2\vector2_is_unit.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_is_zero.c" />
|
<ClCompile Include="tests\vector2\vector2_is_zero.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_copy.c" />
|
<ClCompile Include="tests\vector2\vector2_copy.c" />
|
||||||
|
|
@ -182,7 +172,6 @@
|
||||||
<ClCompile Include="tests\vector2\vector2_set_values.c" />
|
<ClCompile Include="tests\vector2\vector2_set_values.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_swap.c" />
|
<ClCompile Include="tests\vector2\vector2_swap.c" />
|
||||||
<ClCompile Include="tests\vector3.c" />
|
<ClCompile Include="tests\vector3.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_arithmetics.c" />
|
|
||||||
<ClCompile Include="tests\vector3\vector3_is_unit.c" />
|
<ClCompile Include="tests\vector3\vector3_is_unit.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_is_zero.c" />
|
<ClCompile Include="tests\vector3\vector3_is_zero.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_copy.c" />
|
<ClCompile Include="tests\vector3\vector3_copy.c" />
|
||||||
|
|
@ -201,15 +190,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="helpers.h" />
|
<ClInclude Include="helpers.h" />
|
||||||
<ClInclude Include="tests\complex.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_copy.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_is_unit.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_is_zero.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_modulus.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_reset.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_set_values.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_swap.h" />
|
|
||||||
<ClInclude Include="tests\complex\complex_arithmetics.h" />
|
|
||||||
<ClInclude Include="tests\quaternion.h" />
|
<ClInclude Include="tests\quaternion.h" />
|
||||||
<ClInclude Include="tests\quaternion\quaternion_copy.h" />
|
<ClInclude Include="tests\quaternion\quaternion_copy.h" />
|
||||||
<ClInclude Include="tests\quaternion\quaternion_is_unit.h" />
|
<ClInclude Include="tests\quaternion\quaternion_is_unit.h" />
|
||||||
|
|
@ -224,7 +204,6 @@
|
||||||
<ClInclude Include="tests\utilities\is_unit.h" />
|
<ClInclude Include="tests\utilities\is_unit.h" />
|
||||||
<ClInclude Include="tests\utilities\is_zero.h" />
|
<ClInclude Include="tests\utilities\is_zero.h" />
|
||||||
<ClInclude Include="tests\vector2.h" />
|
<ClInclude Include="tests\vector2.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_arithmetics.h" />
|
|
||||||
<ClInclude Include="tests\vector2\vector2_is_unit.h" />
|
<ClInclude Include="tests\vector2\vector2_is_unit.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_is_zero.h" />
|
<ClInclude Include="tests\vector2\vector2_is_zero.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_copy.h" />
|
<ClInclude Include="tests\vector2\vector2_copy.h" />
|
||||||
|
|
@ -233,7 +212,6 @@
|
||||||
<ClInclude Include="tests\vector2\vector2_set_values.h" />
|
<ClInclude Include="tests\vector2\vector2_set_values.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_swap.h" />
|
<ClInclude Include="tests\vector2\vector2_swap.h" />
|
||||||
<ClInclude Include="tests\vector3.h" />
|
<ClInclude Include="tests\vector3.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_arithmetics.h" />
|
|
||||||
<ClInclude Include="tests\vector3\vector3_is_unit.h" />
|
<ClInclude Include="tests\vector3\vector3_is_unit.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_is_zero.h" />
|
<ClInclude Include="tests\vector3\vector3_is_zero.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_copy.h" />
|
<ClInclude Include="tests\vector3\vector3_copy.h" />
|
||||||
|
|
|
||||||
|
|
@ -114,39 +114,6 @@
|
||||||
<ClCompile Include="tests\quaternion\quaternion_modulus.c">
|
<ClCompile Include="tests\quaternion\quaternion_modulus.c">
|
||||||
<Filter>tests\quaternion</Filter>
|
<Filter>tests\quaternion</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="tests\complex\complex_copy.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_is_unit.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_is_zero.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_modulus.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_reset.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_set_values.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_swap.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex.c">
|
|
||||||
<Filter>tests</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\vector2\vector2_arithmetics.c">
|
|
||||||
<Filter>tests\vector2</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\vector3\vector3_arithmetics.c">
|
|
||||||
<Filter>tests\vector3</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="tests\complex\complex_arithmetics.c">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="helpers.h" />
|
<ClInclude Include="helpers.h" />
|
||||||
|
|
@ -261,39 +228,6 @@
|
||||||
<ClInclude Include="tests\quaternion\quaternion_modulus.h">
|
<ClInclude Include="tests\quaternion\quaternion_modulus.h">
|
||||||
<Filter>tests\quaternion</Filter>
|
<Filter>tests\quaternion</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="tests\complex\complex_copy.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_is_unit.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_is_zero.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_modulus.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_reset.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_set_values.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_swap.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex.h">
|
|
||||||
<Filter>tests</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\vector2\vector2_arithmetics.h">
|
|
||||||
<Filter>tests\vector2</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\vector3\vector3_arithmetics.h">
|
|
||||||
<Filter>tests\vector3</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="tests\complex\complex_arithmetics.h">
|
|
||||||
<Filter>tests\complex</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="tests">
|
<Filter Include="tests">
|
||||||
|
|
@ -314,8 +248,5 @@
|
||||||
<Filter Include="tests\quaternion">
|
<Filter Include="tests\quaternion">
|
||||||
<UniqueIdentifier>{e8bafdb8-66e5-4393-bc89-8bff83bcccd6}</UniqueIdentifier>
|
<UniqueIdentifier>{e8bafdb8-66e5-4393-bc89-8bff83bcccd6}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="tests\complex">
|
|
||||||
<UniqueIdentifier>{e025e123-45aa-44f9-aab4-f1705844b211}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "tests/utilities.h"
|
#include "tests/utilities.h"
|
||||||
#include "tests/vector2.h"
|
#include "tests/vector2.h"
|
||||||
#include "tests/vector3.h"
|
#include "tests/vector3.h"
|
||||||
#include "tests/complex.h"
|
|
||||||
#include "tests/quaternion.h"
|
#include "tests/quaternion.h"
|
||||||
#include "tests/versor.h"
|
#include "tests/versor.h"
|
||||||
|
|
||||||
|
|
@ -18,8 +17,6 @@ int main()
|
||||||
|
|
||||||
test_vector3();
|
test_vector3();
|
||||||
|
|
||||||
test_complex();
|
|
||||||
|
|
||||||
test_quaternion();
|
test_quaternion();
|
||||||
|
|
||||||
test_versor();
|
test_versor();
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
#include "./complex.h"
|
|
||||||
|
|
||||||
void test_complex()
|
|
||||||
{
|
|
||||||
print_testing_section("BGC Complex");
|
|
||||||
|
|
||||||
test_complex_reset();
|
|
||||||
test_complex_set_values();
|
|
||||||
test_complex_copy();
|
|
||||||
test_complex_swap();
|
|
||||||
test_complex_is_zero();
|
|
||||||
test_complex_is_unit();
|
|
||||||
test_complex_modulus();
|
|
||||||
|
|
||||||
test_complex_add();
|
|
||||||
test_complex_subtract();
|
|
||||||
test_complex_multiply();
|
|
||||||
test_complex_divide();
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_H_
|
|
||||||
#define _TEST_COMPLEX_H_
|
|
||||||
|
|
||||||
#include "./../helpers.h"
|
|
||||||
#include "./complex/complex_reset.h"
|
|
||||||
#include "./complex/complex_set_values.h"
|
|
||||||
#include "./complex/complex_copy.h"
|
|
||||||
#include "./complex/complex_swap.h"
|
|
||||||
#include "./complex/complex_is_zero.h"
|
|
||||||
#include "./complex/complex_is_unit.h"
|
|
||||||
#include "./complex/complex_modulus.h"
|
|
||||||
#include "./complex/complex_arithmetics.h"
|
|
||||||
|
|
||||||
void test_complex();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,380 +0,0 @@
|
||||||
#include "./complex_arithmetics.h"
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
|
||||||
|
|
||||||
void test_complex_add_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_add_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 14.0f) || !bgc_are_close_fp32(result.imaginary, -15.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(-0.28f, 100.1f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(1.78f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 1.5f) || !bgc_are_close_fp32(result.imaginary, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_add_scaled_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_add_scaled_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_scaled_fp32(&vector1, & vector2, -2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 2.0f) || !bgc_are_close_fp32(result.imaginary, -30.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(-0.27f, 100.3f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(1.59f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_scaled_fp32(&vector1, &vector2, 3.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 4.5f) || !bgc_are_close_fp32(result.imaginary, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_add_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_add_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(4.0, 8.0, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 14.0) || !bgc_are_close_fp64(result.imaginary, -12.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(1.29, -0.2, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 1.02) || !bgc_are_close_fp64(result.imaginary, 100.1)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_add_scaled_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_add_scaled_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(4.0, 5.0, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_scaled_fp64(&vector1, &vector2, -2.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 2.0) || !bgc_are_close_fp64(result.imaginary, -30.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(1.59, -0.1, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_add_scaled_fp64(&vector1, &vector2, 3.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 4.5) || !bgc_are_close_fp64(result.imaginary, 100.0)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_add()
|
|
||||||
{
|
|
||||||
test_complex_add_fp32();
|
|
||||||
test_complex_add_fp64();
|
|
||||||
|
|
||||||
test_complex_add_scaled_fp32();
|
|
||||||
test_complex_add_scaled_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
|
||||||
|
|
||||||
void test_complex_subtract_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_subtract_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 6.0f) || !bgc_are_close_fp32(result.imaginary, -25.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(-0.28f, 99.9f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(-1.78f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 1.5f) || !bgc_are_close_fp32(result.imaginary, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_subtract_scaled_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_subtract_scaled_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_scaled_fp32(&vector1, &vector2, 2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 2.0f) || !bgc_are_close_fp32(result.imaginary, -30.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(0.36f, 100.4f, &vector1);
|
|
||||||
bgc_complex_set_values_fp32(1.09f, 0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_scaled_fp32(&vector1, &vector2, 4.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, -4.0f) || !bgc_are_close_fp32(result.imaginary, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_subtract_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_subtract_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(4.0, 8.0, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 6.0) || !bgc_are_close_fp64(result.imaginary, -28.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(1.29, -0.2, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, -1.56) || !bgc_are_close_fp64(result.imaginary, 100.5)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_subtract_scaled_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_subtract_scaled_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(10.0, 20.0, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(4.0, 5.0, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_scaled_fp64(&vector1, &vector2, 2.5, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 0.0) || !bgc_are_close_fp64(result.imaginary, 7.5)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_complex_set_values_fp64(-1.29, -0.1, &vector2);
|
|
||||||
|
|
||||||
bgc_complex_subtract_scaled_fp64(&vector1, &vector2, 3.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 3.6) || !bgc_are_close_fp64(result.imaginary, 100.6)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_subtract()
|
|
||||||
{
|
|
||||||
test_complex_subtract_fp32();
|
|
||||||
test_complex_subtract_fp64();
|
|
||||||
|
|
||||||
test_complex_subtract_scaled_fp32();
|
|
||||||
test_complex_subtract_scaled_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
|
||||||
|
|
||||||
void test_complex_multiply_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_multiply_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector);
|
|
||||||
|
|
||||||
bgc_complex_multiply_fp32(&vector, 0.5f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 5.0f) || !bgc_are_close_fp32(result.imaginary, -10.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(1.78f, -0.1f, &vector);
|
|
||||||
|
|
||||||
bgc_complex_multiply_fp32(&vector, 2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 3.56f) || !bgc_are_close_fp32(result.imaginary, -0.2f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_multiply_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_multiply_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(30.0, -10.0, &vector);
|
|
||||||
|
|
||||||
bgc_complex_multiply_fp64(&vector, 0.3, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 9.0) || !bgc_are_close_fp64(result.imaginary, -3.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(1.18, -0.25, &vector);
|
|
||||||
|
|
||||||
bgc_complex_multiply_fp64(&vector, 4.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 4.72) || !bgc_are_close_fp64(result.imaginary, -1.0)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_multiply()
|
|
||||||
{
|
|
||||||
test_complex_multiply_fp32();
|
|
||||||
test_complex_multiply_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// =================== Divide =================== //
|
|
||||||
|
|
||||||
void test_complex_divide_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_divide_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector);
|
|
||||||
|
|
||||||
bgc_complex_divide_fp32(&vector, 10.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 1.0f) || !bgc_are_close_fp32(result.imaginary, -2.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(1.78f, -0.1f, &vector);
|
|
||||||
|
|
||||||
bgc_complex_divide_fp32(&vector, 0.2f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.real, 8.9f) || !bgc_are_close_fp32(result.imaginary, -0.5f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_divide_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_divide_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(30.0, -10.0, &vector);
|
|
||||||
|
|
||||||
bgc_complex_divide_fp64(&vector, 5.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 6.0) || !bgc_are_close_fp64(result.imaginary, -2.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(1.18, -0.25, &vector);
|
|
||||||
|
|
||||||
bgc_complex_divide_fp64(&vector, 0.5, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.real, 2.36) || !bgc_are_close_fp64(result.imaginary, -0.5)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_divide()
|
|
||||||
{
|
|
||||||
test_complex_divide_fp32();
|
|
||||||
test_complex_divide_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_ARITHMETICS_H_
|
|
||||||
#define _TEST_COMPLEX_ARITHMETICS_H_
|
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
|
||||||
|
|
||||||
void test_complex_add_fp32();
|
|
||||||
|
|
||||||
void test_complex_add_scaled_fp32();
|
|
||||||
|
|
||||||
void test_complex_add_fp64();
|
|
||||||
|
|
||||||
void test_complex_add_scaled_fp64();
|
|
||||||
|
|
||||||
void test_complex_add();
|
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
|
||||||
|
|
||||||
void test_complex_subtract_fp32();
|
|
||||||
|
|
||||||
void test_complex_subtract_scaled_fp32();
|
|
||||||
|
|
||||||
void test_complex_subtract_fp64();
|
|
||||||
|
|
||||||
void test_complex_subtract_scaled_fp64();
|
|
||||||
|
|
||||||
void test_complex_subtract();
|
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
|
||||||
|
|
||||||
void test_complex_multiply_fp32();
|
|
||||||
|
|
||||||
void test_complex_multiply_fp64();
|
|
||||||
|
|
||||||
void test_complex_multiply();
|
|
||||||
|
|
||||||
// =================== Divide =================== //
|
|
||||||
|
|
||||||
void test_complex_divide_fp32();
|
|
||||||
|
|
||||||
void test_complex_divide_fp64();
|
|
||||||
|
|
||||||
void test_complex_divide();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
#include "./complex_copy.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
|
|
||||||
{ 1.0f, 2.0f },
|
|
||||||
{ -4.0f, -3.0f },
|
|
||||||
{ -0.001f, 100.0f },
|
|
||||||
{ 0.001f, -100.0f }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_copy_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_copy_fp32");
|
|
||||||
|
|
||||||
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
|
|
||||||
|
|
||||||
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST[i], &vector);
|
|
||||||
|
|
||||||
if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real ||
|
|
||||||
vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
|
|
||||||
{ 1.0, 2.0 },
|
|
||||||
{ -4.0, -3.0 },
|
|
||||||
{ -0.001, 100.0 },
|
|
||||||
{ 0.001, -100.0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_copy_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_copy_fp64");
|
|
||||||
|
|
||||||
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
|
|
||||||
|
|
||||||
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST[i], &vector);
|
|
||||||
|
|
||||||
if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real ||
|
|
||||||
vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_copy()
|
|
||||||
{
|
|
||||||
test_complex_copy_fp32();
|
|
||||||
test_complex_copy_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_COPY_H_
|
|
||||||
#define _TEST_COMPLEX_COPY_H_
|
|
||||||
|
|
||||||
void test_complex_copy_fp32();
|
|
||||||
|
|
||||||
void test_complex_copy_fp64();
|
|
||||||
|
|
||||||
void test_complex_copy();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
#include "./complex_is_unit.h"
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10;
|
|
||||||
static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6;
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_UNIT_COMPLEX_LIST[] = {
|
|
||||||
{ 1.0f, 0.0f },
|
|
||||||
{ -1.0f, 0.0f },
|
|
||||||
{ 0.6f, -0.8f },
|
|
||||||
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.7071067812f, 0.7071067812f },
|
|
||||||
{ 0.7071067812f + 0.75f * BGC_EPSYLON_FP32, 0.7071067812f },
|
|
||||||
{ 0.7071067812f, 0.7071067812f - 0.75f * BGC_EPSYLON_FP32 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
|
|
||||||
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.7071067812f + 1.25f * BGC_EPSYLON_FP32, 0.7071067812f + 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.7071067812f - 1.25f * BGC_EPSYLON_FP32, 0.7071067812f - 1.25f * BGC_EPSYLON_FP32 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_is_unit_fp32()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_is_unit_fp32");
|
|
||||||
|
|
||||||
// Testing zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (!bgc_complex_is_unit_fp32(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) {
|
|
||||||
print_testing_error("A unit complex number was not recognized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testing non-zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (bgc_complex_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
|
|
||||||
print_testing_error("A non-unit complex number was recognized a unit complex number");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10;
|
|
||||||
static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6;
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_UNIT_COMPLEX_LIST[] = {
|
|
||||||
{ 1.0, 0.0 },
|
|
||||||
{ -1.0, 0.0 },
|
|
||||||
{ -0.6, 0.8 },
|
|
||||||
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.7071067811865475244, 0.7071067811865475244 },
|
|
||||||
{ 0.7071067811865475244 + 0.75 * BGC_EPSYLON_FP64, 0.7071067811865475244 },
|
|
||||||
{ 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_EPSYLON_FP64 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
|
|
||||||
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_is_unit_fp64()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_is_unit_fp64");
|
|
||||||
|
|
||||||
// Testing zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (!bgc_complex_is_unit_fp64(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) {
|
|
||||||
print_testing_error("A unit complex number was not recognized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testing non-zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (bgc_complex_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
|
|
||||||
print_testing_error("A non-unit complex number was recognized a unit complex number");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_is_unit()
|
|
||||||
{
|
|
||||||
test_complex_is_unit_fp32();
|
|
||||||
test_complex_is_unit_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_IS_UNIT_H_
|
|
||||||
#define _TEST_COMPLEX_IS_UNIT_H_
|
|
||||||
|
|
||||||
void test_complex_is_unit_fp32();
|
|
||||||
|
|
||||||
void test_complex_is_unit_fp64();
|
|
||||||
|
|
||||||
void test_complex_is_unit();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
#include "./complex_is_zero.h"
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4;
|
|
||||||
static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7;
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_ZERO_COMPLEX_LIST[] = {
|
|
||||||
{ 0.0f, 0.0f },
|
|
||||||
{ 0.75f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ -0.75f * BGC_EPSYLON_FP32, 0.0f },
|
|
||||||
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = {
|
|
||||||
{ 0.0f, 1.0f },
|
|
||||||
{ 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ -1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 },
|
|
||||||
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_is_zero_fp32()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_is_zero_fp32");
|
|
||||||
|
|
||||||
// Testing zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (!bgc_complex_is_zero_fp32(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) {
|
|
||||||
print_testing_error("A zero complex number was not recognized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testing non-zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (bgc_complex_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
|
|
||||||
print_testing_error("A non-zero complex number was recognized as a zero complex number");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4;
|
|
||||||
static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7;
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_ZERO_COMPLEX_LIST[] = {
|
|
||||||
{ 0.0, 0.0 },
|
|
||||||
{ 0.75 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ -0.75 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 0.0, 0.75 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.0, -0.75 * BGC_EPSYLON_FP64 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = {
|
|
||||||
{ 0.0, 1.0 },
|
|
||||||
{ 1.25 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ -1.25 * BGC_EPSYLON_FP64, 0.0 },
|
|
||||||
{ 0.0, 1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 0.0, -1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 },
|
|
||||||
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_is_zero_fp64()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_is_zero_fp64");
|
|
||||||
|
|
||||||
// Testing zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (!bgc_complex_is_zero_fp64(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) {
|
|
||||||
print_testing_error("A zero complex number was not recognized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testing non-zero values:
|
|
||||||
for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) {
|
|
||||||
if (bgc_complex_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
|
|
||||||
print_testing_error("A non-zero complex number was recognized as a zero complex number");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_is_zero()
|
|
||||||
{
|
|
||||||
test_complex_is_zero_fp32();
|
|
||||||
test_complex_is_zero_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_IS_ZERO_H_
|
|
||||||
#define _TEST_COMPLEX_IS_ZERO_H_
|
|
||||||
|
|
||||||
void test_complex_is_zero_fp32();
|
|
||||||
|
|
||||||
void test_complex_is_zero_fp64();
|
|
||||||
|
|
||||||
void test_complex_is_zero();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
#include "./complex_modulus.h"
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
|
|
||||||
{ 4.0f, 3.0f },
|
|
||||||
{ -1.0f, 1.0f },
|
|
||||||
{ 100.0f, -100.0f },
|
|
||||||
{ -0.86602540378f, 0.5f }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float _TEST_FP32_SQUARE_MODULUS_LIST[] = {
|
|
||||||
25.0f,
|
|
||||||
2.0f,
|
|
||||||
20000.0f,
|
|
||||||
1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
static const float _TEST_FP32_MODULUS_LIST[] = {
|
|
||||||
5.0f,
|
|
||||||
1.414213562373f,
|
|
||||||
141.4213562373f,
|
|
||||||
1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_square_modulus_fp32()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_get_square_modulus_fp32");
|
|
||||||
|
|
||||||
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])) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_modulus_fp32()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_get_modulus_fp32");
|
|
||||||
|
|
||||||
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])) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
|
|
||||||
{ 4.0, 3.0 },
|
|
||||||
{ -1.0, -1.0 },
|
|
||||||
{ -100.0, 100.0 },
|
|
||||||
{ -0.5, 0.866025403784438647 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const double _TEST_FP64_SQUARE_MODULUS_LIST[] = {
|
|
||||||
25.0,
|
|
||||||
2.0,
|
|
||||||
20000.0,
|
|
||||||
1.0
|
|
||||||
};
|
|
||||||
|
|
||||||
static const double _TEST_FP64_MODULUS_LIST[] = {
|
|
||||||
5.0,
|
|
||||||
1.4142135623730950488,
|
|
||||||
141.42135623730950488,
|
|
||||||
1.0
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_square_modulus_fp64()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_get_square_modulus_fp64");
|
|
||||||
|
|
||||||
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])) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_modulus_fp64()
|
|
||||||
{
|
|
||||||
print_testing_name("bgc_complex_get_modulus_fp64");
|
|
||||||
|
|
||||||
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])) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_modulus()
|
|
||||||
{
|
|
||||||
test_complex_square_modulus_fp32();
|
|
||||||
test_complex_square_modulus_fp64();
|
|
||||||
test_complex_modulus_fp32();
|
|
||||||
test_complex_modulus_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_MODULUS_H_
|
|
||||||
#define _TEST_COMPLEX_MODULUS_H_
|
|
||||||
|
|
||||||
void test_complex_square_modulus_fp32();
|
|
||||||
|
|
||||||
void test_complex_square_modulus_fp64();
|
|
||||||
|
|
||||||
void test_complex_modulus_fp32();
|
|
||||||
|
|
||||||
void test_complex_modulus_fp64();
|
|
||||||
|
|
||||||
void test_complex_modulus();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
#include "./complex_reset.h"
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
void test_complex_reset_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_reset_fp32");
|
|
||||||
|
|
||||||
bgc_complex_reset_fp32(&vector);
|
|
||||||
|
|
||||||
if (vector.real != 0.0f || vector.imaginary != 0.0f) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_reset_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_reset_fp64");
|
|
||||||
|
|
||||||
bgc_complex_reset_fp64(&vector);
|
|
||||||
|
|
||||||
if (vector.real != 0.0 || vector.imaginary != 0.0) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_reset()
|
|
||||||
{
|
|
||||||
test_complex_reset_fp32();
|
|
||||||
test_complex_reset_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_RESET_H_
|
|
||||||
#define _TEST_COMPLEX_RESET_H_
|
|
||||||
|
|
||||||
void test_complex_reset_fp32();
|
|
||||||
|
|
||||||
void test_complex_reset_fp64();
|
|
||||||
|
|
||||||
void test_complex_reset();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
#include "./complex_set_values.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
void test_complex_set_values_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_set_values_fp32");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(1.0f, 2.0f, &vector);
|
|
||||||
|
|
||||||
if (vector.real != 1.0f || vector.imaginary != 2.0f) {
|
|
||||||
print_testing_error("First step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(-1.0f, -3.0f, &vector);
|
|
||||||
|
|
||||||
if (vector.real != -1.0f || vector.imaginary != -3.0f) {
|
|
||||||
print_testing_error("Second step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp32(-8.0f, -2.0f, &vector);
|
|
||||||
|
|
||||||
if (vector.real != -8.0f || vector.imaginary != -2.0f) {
|
|
||||||
print_testing_error("Third step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
void test_complex_set_values_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 vector;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_set_values_fp64");
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(1.0, 2.0, &vector);
|
|
||||||
|
|
||||||
if (vector.real != 1.0 || vector.imaginary != 2.0) {
|
|
||||||
print_testing_error("First step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-1.0, -3.0, &vector);
|
|
||||||
|
|
||||||
if (vector.real != -1.0 || vector.imaginary != -3.0) {
|
|
||||||
print_testing_error("Second step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_complex_set_values_fp64(-8.0, -2.0, &vector);
|
|
||||||
|
|
||||||
if (vector.real != -8.0 || vector.imaginary != -2.0) {
|
|
||||||
print_testing_error("Third step failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_set_values()
|
|
||||||
{
|
|
||||||
test_complex_set_values_fp32();
|
|
||||||
test_complex_set_values_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_SET_VALUES_H_
|
|
||||||
#define _TEST_COMPLEX_SET_VALUES_H_
|
|
||||||
|
|
||||||
void test_complex_set_values_fp32();
|
|
||||||
|
|
||||||
void test_complex_set_values_fp64();
|
|
||||||
|
|
||||||
void test_complex_set_values();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
#include "./complex_swap.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== FP32 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST1[] = {
|
|
||||||
{ 3.0f, 4.0f },
|
|
||||||
{ -2.0f, -1.0f },
|
|
||||||
{ -244.8f, 100.0f },
|
|
||||||
{ 1000.32f, -100.1f }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = {
|
|
||||||
{ 5.3f, 1003.28f },
|
|
||||||
{ -0.0032f, 891.3f },
|
|
||||||
{ 5.322f, 0.9275f },
|
|
||||||
{ 1000.0f, -0.00025f }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_swap_fp32()
|
|
||||||
{
|
|
||||||
BgcComplexFP32 compleimaginary, complex2;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_swap_fp32");
|
|
||||||
|
|
||||||
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
|
|
||||||
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary);
|
|
||||||
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST2[i], &complex2);
|
|
||||||
|
|
||||||
bgc_complex_swap_fp32(&compleimaginary, &complex2);
|
|
||||||
|
|
||||||
if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real ||
|
|
||||||
compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary ||
|
|
||||||
complex2.real != _TEST_FP32_COMPLEX_LIST1[i].real ||
|
|
||||||
complex2.imaginary != _TEST_FP32_COMPLEX_LIST1[i].imaginary) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== FP64 ==================== //
|
|
||||||
|
|
||||||
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST1[] = {
|
|
||||||
{ 1.0, 4.0 },
|
|
||||||
{ -4.0, -3.0 },
|
|
||||||
{ -244.8, 344.7 },
|
|
||||||
{ 1000.32, -271.3 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = {
|
|
||||||
{ -0.123, 1003.28 },
|
|
||||||
{ 204.07, -781.89 },
|
|
||||||
{ 5.322, 0.9275 },
|
|
||||||
{ -0.419, 0.844 }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_complex_swap_fp64()
|
|
||||||
{
|
|
||||||
BgcComplexFP64 compleimaginary, complex2;
|
|
||||||
|
|
||||||
print_testing_name("bgc_complex_swap_fp64");
|
|
||||||
|
|
||||||
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
|
|
||||||
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary);
|
|
||||||
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST2[i], &complex2);
|
|
||||||
|
|
||||||
bgc_complex_swap_fp64(&compleimaginary, &complex2);
|
|
||||||
|
|
||||||
if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real ||
|
|
||||||
compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary ||
|
|
||||||
complex2.real != _TEST_FP64_COMPLEX_LIST1[i].real ||
|
|
||||||
complex2.imaginary != _TEST_FP64_COMPLEX_LIST1[i].imaginary) {
|
|
||||||
print_testing_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_complex_swap()
|
|
||||||
{
|
|
||||||
test_complex_swap_fp32();
|
|
||||||
test_complex_swap_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef _TEST_COMPLEX_SWAP_H_
|
|
||||||
#define _TEST_COMPLEX_SWAP_H_
|
|
||||||
|
|
||||||
void test_complex_swap_fp32();
|
|
||||||
|
|
||||||
void test_complex_swap_fp64();
|
|
||||||
|
|
||||||
void test_complex_swap();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -11,11 +11,6 @@ void test_vector2()
|
||||||
test_vector2_is_zero();
|
test_vector2_is_zero();
|
||||||
test_vector2_is_unit();
|
test_vector2_is_unit();
|
||||||
test_vector2_modulus();
|
test_vector2_modulus();
|
||||||
|
|
||||||
test_vector2_add();
|
|
||||||
test_vector2_subtract();
|
|
||||||
test_vector2_multiply();
|
|
||||||
test_vector2_divide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "./vector2/vector2_is_zero.h"
|
#include "./vector2/vector2_is_zero.h"
|
||||||
#include "./vector2/vector2_is_unit.h"
|
#include "./vector2/vector2_is_unit.h"
|
||||||
#include "./vector2/vector2_modulus.h"
|
#include "./vector2/vector2_modulus.h"
|
||||||
#include "./vector2/vector2_arithmetics.h"
|
|
||||||
|
|
||||||
void test_vector2();
|
void test_vector2();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,380 +0,0 @@
|
||||||
#include "./vector2_arithmetics.h"
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
|
||||||
|
|
||||||
void test_vector2_add_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_add_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 14.0f) || !bgc_are_close_fp32(result.x2, -15.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(-0.28f, 100.1f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(1.78f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 1.5f) || !bgc_are_close_fp32(result.x2, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_add_scaled_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_add_scaled_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_scaled_fp32(&vector1, & vector2, -2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 2.0f) || !bgc_are_close_fp32(result.x2, -30.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(-0.27f, 100.3f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(1.59f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_scaled_fp32(&vector1, &vector2, 3.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 4.5f) || !bgc_are_close_fp32(result.x2, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_add_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_add_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(4.0, 8.0, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 14.0) || !bgc_are_close_fp64(result.x2, -12.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(1.29, -0.2, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 1.02) || !bgc_are_close_fp64(result.x2, 100.1)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_add_scaled_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_add_scaled_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(4.0, 5.0, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_scaled_fp64(&vector1, &vector2, -2.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 2.0) || !bgc_are_close_fp64(result.x2, -30.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(1.59, -0.1, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_add_scaled_fp64(&vector1, &vector2, 3.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 4.5) || !bgc_are_close_fp64(result.x2, 100.0)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_add()
|
|
||||||
{
|
|
||||||
test_vector2_add_fp32();
|
|
||||||
test_vector2_add_fp64();
|
|
||||||
|
|
||||||
test_vector2_add_scaled_fp32();
|
|
||||||
test_vector2_add_scaled_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
|
||||||
|
|
||||||
void test_vector2_subtract_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_subtract_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 6.0f) || !bgc_are_close_fp32(result.x2, -25.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(-0.28f, 99.9f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(-1.78f, -0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 1.5f) || !bgc_are_close_fp32(result.x2, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_subtract_scaled_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_subtract_scaled_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(4.0f, 5.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_scaled_fp32(&vector1, &vector2, 2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 2.0f) || !bgc_are_close_fp32(result.x2, -30.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(0.36f, 100.4f, &vector1);
|
|
||||||
bgc_vector2_set_values_fp32(1.09f, 0.1f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_scaled_fp32(&vector1, &vector2, 4.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, -4.0f) || !bgc_are_close_fp32(result.x2, 100.0f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_subtract_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_subtract_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(10.0, -20.0, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(4.0, 8.0, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 6.0) || !bgc_are_close_fp64(result.x2, -28.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(1.29, -0.2, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_fp64(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, -1.56) || !bgc_are_close_fp64(result.x2, 100.5)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_subtract_scaled_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_subtract_scaled_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(10.0, 20.0, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(4.0, 5.0, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_scaled_fp64(&vector1, &vector2, 2.5, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 0.0) || !bgc_are_close_fp64(result.x2, 7.5)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(-0.27, 100.3, &vector1);
|
|
||||||
bgc_vector2_set_values_fp64(-1.29, -0.1, &vector2);
|
|
||||||
|
|
||||||
bgc_vector2_subtract_scaled_fp64(&vector1, &vector2, 3.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 3.6) || !bgc_are_close_fp64(result.x2, 100.6)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_subtract()
|
|
||||||
{
|
|
||||||
test_vector2_subtract_fp32();
|
|
||||||
test_vector2_subtract_fp64();
|
|
||||||
|
|
||||||
test_vector2_subtract_scaled_fp32();
|
|
||||||
test_vector2_subtract_scaled_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
|
||||||
|
|
||||||
void test_vector2_multiply_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_multiply_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_multiply_fp32(&vector, 0.5f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 5.0f) || !bgc_are_close_fp32(result.x2, -10.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(1.78f, -0.1f, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_multiply_fp32(&vector, 2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 3.56f) || !bgc_are_close_fp32(result.x2, -0.2f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_multiply_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_multiply_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(30.0, -10.0, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_multiply_fp64(&vector, 0.3, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 9.0) || !bgc_are_close_fp64(result.x2, -3.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(1.18, -0.25, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_multiply_fp64(&vector, 4.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 4.72) || !bgc_are_close_fp64(result.x2, -1.0)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_multiply()
|
|
||||||
{
|
|
||||||
test_vector2_multiply_fp32();
|
|
||||||
test_vector2_multiply_fp64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// =================== Divide =================== //
|
|
||||||
|
|
||||||
void test_vector2_divide_fp32()
|
|
||||||
{
|
|
||||||
BgcVector2FP32 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_divide_fp32");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(10.0f, -20.0f, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_divide_fp32(&vector, 10.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 1.0f) || !bgc_are_close_fp32(result.x2, -2.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp32(1.78f, -0.1f, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_divide_fp32(&vector, 0.2f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 8.9f) || !bgc_are_close_fp32(result.x2, -0.5f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_divide_fp64()
|
|
||||||
{
|
|
||||||
BgcVector2FP64 vector, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector2_divide_fp64");
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(30.0, -10.0, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_divide_fp64(&vector, 5.0, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 6.0) || !bgc_are_close_fp64(result.x2, -2.0)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector2_set_values_fp64(1.18, -0.25, &vector);
|
|
||||||
|
|
||||||
bgc_vector2_divide_fp64(&vector, 0.5, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp64(result.x1, 2.36) || !bgc_are_close_fp64(result.x2, -0.5)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector2_divide()
|
|
||||||
{
|
|
||||||
test_vector2_divide_fp32();
|
|
||||||
test_vector2_divide_fp64();
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
#ifndef _TEST_VECTOR2_ARITHMETICS_H_
|
|
||||||
#define _TEST_VECTOR2_ARITHMETICS_H_
|
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
|
||||||
|
|
||||||
void test_vector2_add_fp32();
|
|
||||||
|
|
||||||
void test_vector2_add_scaled_fp32();
|
|
||||||
|
|
||||||
void test_vector2_add_fp64();
|
|
||||||
|
|
||||||
void test_vector2_add_scaled_fp64();
|
|
||||||
|
|
||||||
void test_vector2_add();
|
|
||||||
|
|
||||||
// ================== Subtract ================== //
|
|
||||||
|
|
||||||
void test_vector2_subtract_fp32();
|
|
||||||
|
|
||||||
void test_vector2_subtract_scaled_fp32();
|
|
||||||
|
|
||||||
void test_vector2_subtract_fp64();
|
|
||||||
|
|
||||||
void test_vector2_subtract_scaled_fp64();
|
|
||||||
|
|
||||||
void test_vector2_subtract();
|
|
||||||
|
|
||||||
// ================== Multiply ================== //
|
|
||||||
|
|
||||||
void test_vector2_multiply_fp32();
|
|
||||||
|
|
||||||
void test_vector2_multiply_fp64();
|
|
||||||
|
|
||||||
void test_vector2_multiply();
|
|
||||||
|
|
||||||
// =================== Divide =================== //
|
|
||||||
|
|
||||||
void test_vector2_divide_fp32();
|
|
||||||
|
|
||||||
void test_vector2_divide_fp64();
|
|
||||||
|
|
||||||
void test_vector2_divide();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -11,9 +11,4 @@ void test_vector3()
|
||||||
test_vector3_is_zero();
|
test_vector3_is_zero();
|
||||||
test_vector3_is_unit();
|
test_vector3_is_unit();
|
||||||
test_vector3_modulus();
|
test_vector3_modulus();
|
||||||
|
|
||||||
test_vector3_add();
|
|
||||||
test_vector3_subtract();
|
|
||||||
test_vector3_multiply();
|
|
||||||
test_vector3_divide();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@
|
||||||
#include "./vector3/vector3_is_zero.h"
|
#include "./vector3/vector3_is_zero.h"
|
||||||
#include "./vector3/vector3_is_unit.h"
|
#include "./vector3/vector3_is_unit.h"
|
||||||
#include "./vector3/vector3_modulus.h"
|
#include "./vector3/vector3_modulus.h"
|
||||||
#include "./vector3/vector3_arithmetics.h"
|
|
||||||
|
|
||||||
void test_vector3();
|
void test_vector3();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,380 +0,0 @@
|
||||||
#include "./vector3_arithmetics.h"
|
|
||||||
#include "./../../helpers.h"
|
|
||||||
|
|
||||||
// ==================== Add ===================== //
|
|
||||||
|
|
||||||
void test_vector3_add_fp32()
|
|
||||||
{
|
|
||||||
BgcVector3FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector3_add_fp32");
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(10.0f, -20.0f, 30.0f, &vector1);
|
|
||||||
bgc_vector3_set_values_fp32(4.0f, 5.0f, -6.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector3_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 14.0f) || !bgc_are_close_fp32(result.x2, -15.0f) || !bgc_are_close_fp32(result.x3, 24.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-0.28f, 100.1f, -1.6f, &vector1);
|
|
||||||
bgc_vector3_set_values_fp32(1.78f, -0.1f, 0.4f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector3_add_fp32(&vector1, &vector2, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 1.5f) || !bgc_are_close_fp32(result.x2, 100.0f) || !bgc_are_close_fp32(result.x3, -1.2f)) {
|
|
||||||
print_testing_error("second test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print_testing_success();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_vector3_add_scaled_fp32()
|
|
||||||
{
|
|
||||||
BgcVector3FP32 vector1, vector2, result;
|
|
||||||
|
|
||||||
print_testing_name("bgc_vector3_add_scaled_fp32");
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(10.0f, -20.0f, 24.0f, &vector1);
|
|
||||||
bgc_vector3_set_values_fp32(4.0f, 5.0f, 6.0f, &vector2);
|
|
||||||
|
|
||||||
bgc_vector3_add_scaled_fp32(&vector1, & vector2, -2.0f, &result);
|
|
||||||
|
|
||||||
if (!bgc_are_close_fp32(result.x1, 2.0f) || !bgc_are_close_fp32(result.x2, -30.0f) || !bgc_are_close_fp32(result.x3, 12.0f)) {
|
|
||||||
print_testing_error("first test failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bgc_vector3_set_values_fp32(-0.27f, 100.3f, -1.2f, &vector1);
|
|
||||||
bgc_vector3_set_values_fp32(1.59f, -0.1f, 0.4f, &vector2);
|
|
||||||
|
|
||||||