Упорядочивание проекта
This commit is contained in:
parent
0dcd9c0d4d
commit
89dfd7644b
32 changed files with 1730 additions and 1719 deletions
|
|
@ -53,12 +53,12 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
|||
|
||||
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 (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)
|
||||
{
|
||||
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)
|
||||
|
|
@ -469,11 +469,16 @@ void test_basis_difference_fp64()
|
|||
print_versor_fp64(&turn);
|
||||
}
|
||||
|
||||
typedef union {
|
||||
int si32;
|
||||
float fp32;
|
||||
} uni_number;
|
||||
|
||||
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;
|
||||
|
|
@ -482,8 +487,14 @@ int main()
|
|||
bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result);
|
||||
|
||||
print_versor_fp32(&result);
|
||||
|
||||
*/
|
||||
//test_basis_difference_fp64();
|
||||
|
||||
uni_number number;
|
||||
|
||||
number.fp32 = 2.0f;
|
||||
|
||||
printf("%x\n", number.si32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,35 +159,6 @@ void test_complex_subtract_fp32()
|
|||
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;
|
||||
|
|
@ -217,42 +188,10 @@ void test_complex_subtract_fp64()
|
|||
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 ================== //
|
||||
|
|
@ -265,7 +204,7 @@ void test_complex_multiply_fp32()
|
|||
|
||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector);
|
||||
|
||||
bgc_complex_multiply_fp32(&vector, 0.5f, &result);
|
||||
bgc_complex_multiply_by_number_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");
|
||||
|
|
@ -274,7 +213,7 @@ void test_complex_multiply_fp32()
|
|||
|
||||
bgc_complex_set_values_fp32(1.78f, -0.1f, &vector);
|
||||
|
||||
bgc_complex_multiply_fp32(&vector, 2.0f, &result);
|
||||
bgc_complex_multiply_by_number_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");
|
||||
|
|
@ -292,7 +231,7 @@ void test_complex_multiply_fp64()
|
|||
|
||||
bgc_complex_set_values_fp64(30.0, -10.0, &vector);
|
||||
|
||||
bgc_complex_multiply_fp64(&vector, 0.3, &result);
|
||||
bgc_complex_multiply_by_number_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");
|
||||
|
|
@ -301,7 +240,7 @@ void test_complex_multiply_fp64()
|
|||
|
||||
bgc_complex_set_values_fp64(1.18, -0.25, &vector);
|
||||
|
||||
bgc_complex_multiply_fp64(&vector, 4.0, &result);
|
||||
bgc_complex_multiply_by_number_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");
|
||||
|
|
@ -327,7 +266,7 @@ void test_complex_divide_fp32()
|
|||
|
||||
bgc_complex_set_values_fp32(10.0f, -20.0f, &vector);
|
||||
|
||||
bgc_complex_divide_fp32(&vector, 10.0f, &result);
|
||||
bgc_complex_divide_by_number_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");
|
||||
|
|
@ -336,7 +275,7 @@ void test_complex_divide_fp32()
|
|||
|
||||
bgc_complex_set_values_fp32(1.78f, -0.1f, &vector);
|
||||
|
||||
bgc_complex_divide_fp32(&vector, 0.2f, &result);
|
||||
bgc_complex_divide_by_number_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");
|
||||
|
|
@ -354,7 +293,7 @@ void test_complex_divide_fp64()
|
|||
|
||||
bgc_complex_set_values_fp64(30.0, -10.0, &vector);
|
||||
|
||||
bgc_complex_divide_fp64(&vector, 5.0, &result);
|
||||
bgc_complex_divide_by_number_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");
|
||||
|
|
@ -363,7 +302,7 @@ void test_complex_divide_fp64()
|
|||
|
||||
bgc_complex_set_values_fp64(1.18, -0.25, &vector);
|
||||
|
||||
bgc_complex_divide_fp64(&vector, 0.5, &result);
|
||||
bgc_complex_divide_by_number_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");
|
||||
|
|
|
|||
|
|
@ -17,12 +17,8 @@ void test_complex_add();
|
|||
|
||||
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 ================== //
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ void test_quaternion_set_to_identity_fp32()
|
|||
|
||||
print_testing_name("bgc_quaternion_set_to_identity_fp32");
|
||||
|
||||
bgc_quaternion_set_to_identity_fp32(&vector);
|
||||
bgc_quaternion_make_unit_fp32(&vector);
|
||||
|
||||
if (vector.s0 != 1.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
|
||||
print_testing_failed();
|
||||
|
|
@ -24,7 +24,7 @@ void test_quaternion_set_to_identity_fp64()
|
|||
|
||||
print_testing_name("bgc_quaternion_set_to_identity_fp64");
|
||||
|
||||
bgc_quaternion_set_to_identity_fp64(&vector);
|
||||
bgc_quaternion_make_unit_fp64(&vector);
|
||||
|
||||
if (vector.s0 != 1.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
|
||||
print_testing_failed();
|
||||
|
|
|
|||
|
|
@ -159,35 +159,6 @@ void test_vector2_subtract_fp32()
|
|||
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;
|
||||
|
|
@ -217,42 +188,10 @@ void test_vector2_subtract_fp64()
|
|||
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 ================== //
|
||||
|
|
|
|||
|
|
@ -17,12 +17,8 @@ void test_vector2_add();
|
|||
|
||||
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 ================== //
|
||||
|
|
|
|||
|
|
@ -159,35 +159,6 @@ void test_vector3_subtract_fp32()
|
|||
print_testing_success();
|
||||
}
|
||||
|
||||
void test_vector3_subtract_scaled_fp32()
|
||||
{
|
||||
BgcVector3FP32 vector1, vector2, result;
|
||||
|
||||
print_testing_name("bgc_vector3_subtract_scaled_fp32");
|
||||
|
||||
bgc_vector3_set_values_fp32(10.0f, -20.0f, 1.25f, &vector1);
|
||||
bgc_vector3_set_values_fp32(4.0f, 5.0f, -0.4f, &vector2);
|
||||
|
||||
bgc_vector3_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) || !bgc_are_close_fp32(result.x3, 2.05f)) {
|
||||
print_testing_error("first test failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp32(0.36f, 100.4f, 10, &vector1);
|
||||
bgc_vector3_set_values_fp32(1.09f, 0.1f, 2.5f, &vector2);
|
||||
|
||||
bgc_vector3_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) || !bgc_are_close_fp32(result.x3, 0.0f)) {
|
||||
print_testing_error("second test failed");
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
}
|
||||
|
||||
void test_vector3_subtract_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector1, vector2, result;
|
||||
|
|
@ -217,42 +188,10 @@ void test_vector3_subtract_fp64()
|
|||
print_testing_success();
|
||||
}
|
||||
|
||||
void test_vector3_subtract_scaled_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector1, vector2, result;
|
||||
|
||||
print_testing_name("bgc_vector3_subtract_scaled_fp64");
|
||||
|
||||
bgc_vector3_set_values_fp64(10.0, 20.0, 0.1, &vector1);
|
||||
bgc_vector3_set_values_fp64(4.0, 5.0, -4.0, &vector2);
|
||||
|
||||
bgc_vector3_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) || !bgc_are_close_fp64(result.x3, 10.1)) {
|
||||
print_testing_error("first test failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp64(-0.27, 100.3, -0.01, &vector1);
|
||||
bgc_vector3_set_values_fp64(-1.29, -0.1, 0.33, &vector2);
|
||||
|
||||
bgc_vector3_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) || !bgc_are_close_fp64(result.x3, -1.0)) {
|
||||
print_testing_error("second test failed");
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
}
|
||||
|
||||
void test_vector3_subtract()
|
||||
{
|
||||
test_vector3_subtract_fp32();
|
||||
test_vector3_subtract_fp64();
|
||||
|
||||
test_vector3_subtract_scaled_fp32();
|
||||
test_vector3_subtract_scaled_fp64();
|
||||
}
|
||||
|
||||
// ================== Multiply ================== //
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ void test_versor_copy_fp32()
|
|||
|
||||
bgc_versor_copy_fp32(&_TEST_FP32_VERSOR_LIST[i], &versor);
|
||||
|
||||
if (versor.s0 != _TEST_FP32_VERSOR_LIST[i].s0 ||
|
||||
versor.x1 != _TEST_FP32_VERSOR_LIST[i].x1 ||
|
||||
versor.x2 != _TEST_FP32_VERSOR_LIST[i].x2 ||
|
||||
versor.x3 != _TEST_FP32_VERSOR_LIST[i].x3) {
|
||||
if (versor._s0 != _TEST_FP32_VERSOR_LIST[i]._s0 ||
|
||||
versor._x1 != _TEST_FP32_VERSOR_LIST[i]._x1 ||
|
||||
versor._x2 != _TEST_FP32_VERSOR_LIST[i]._x2 ||
|
||||
versor._x3 != _TEST_FP32_VERSOR_LIST[i]._x3) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
@ -64,10 +64,10 @@ void test_versor_copy_fp64()
|
|||
|
||||
bgc_versor_copy_fp64(&_TEST_FP64_VERSOR_LIST[i], &versor);
|
||||
|
||||
if (versor.s0 != _TEST_FP64_VERSOR_LIST[i].s0 ||
|
||||
versor.x1 != _TEST_FP64_VERSOR_LIST[i].x1 ||
|
||||
versor.x2 != _TEST_FP64_VERSOR_LIST[i].x2 ||
|
||||
versor.x3 != _TEST_FP64_VERSOR_LIST[i].x3) {
|
||||
if (versor._s0 != _TEST_FP64_VERSOR_LIST[i]._s0 ||
|
||||
versor._x1 != _TEST_FP64_VERSOR_LIST[i]._x1 ||
|
||||
versor._x2 != _TEST_FP64_VERSOR_LIST[i]._x2 ||
|
||||
versor._x3 != _TEST_FP64_VERSOR_LIST[i]._x3) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ void test_versor_reset_fp32()
|
|||
|
||||
bgc_versor_reset_fp32(&versor);
|
||||
|
||||
if (versor.s0 != 1.0f || versor.x1 != 0.0f || versor.x2 != 0.0f || versor.x3 != 0.0f) {
|
||||
if (versor._s0 != 1.0f || versor._x1 != 0.0f || versor._x2 != 0.0f || versor._x3 != 0.0f) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ void test_versor_reset_fp64()
|
|||
|
||||
bgc_versor_reset_fp64(&versor);
|
||||
|
||||
if (versor.s0 != 1.0 || versor.x1 != 0.0 || versor.x2 != 0.0 || versor.x3 != 0.0) {
|
||||
if (versor._s0 != 1.0 || versor._x1 != 0.0 || versor._x2 != 0.0 || versor._x3 != 0.0) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void test_versor_set_values_fp32()
|
|||
&versor
|
||||
);
|
||||
|
||||
versor_module = sqrtf(versor.s0 * versor.s0 + versor.x1 * versor.x1 + versor.x2 * versor.x2 + versor.x3 * versor.x3);
|
||||
versor_module = sqrtf(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
|
||||
|
||||
if (!bgc_is_unit_fp32(versor_module)) {
|
||||
print_testing_error("Versor module is not equal to one.");
|
||||
|
|
@ -41,19 +41,19 @@ void test_versor_set_values_fp32()
|
|||
continue;
|
||||
}
|
||||
|
||||
ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor.s0;
|
||||
ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor._s0;
|
||||
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor.x1)) {
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x1).");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor.x2)) {
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x2).");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor.x3)) {
|
||||
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x3).");
|
||||
return;
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ void test_versor_set_values_fp64()
|
|||
&versor
|
||||
);
|
||||
|
||||
versor_module = sqrt(versor.s0 * versor.s0 + versor.x1 * versor.x1 + versor.x2 * versor.x2 + versor.x3 * versor.x3);
|
||||
versor_module = sqrt(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
|
||||
|
||||
if (!bgc_is_unit_fp64(versor_module)) {
|
||||
print_testing_error("Versor module is not equal to one.");
|
||||
|
|
@ -99,19 +99,19 @@ void test_versor_set_values_fp64()
|
|||
continue;
|
||||
}
|
||||
|
||||
ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor.s0;
|
||||
ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor._s0;
|
||||
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor.x1)) {
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x1).");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor.x2)) {
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x2).");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor.x3)) {
|
||||
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
|
||||
print_testing_error("Versor was not normalized proportionally (x3).");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ void test_versor_swap_fp32()
|
|||
|
||||
bgc_versor_swap_fp32(&versor1b, &versor2b);
|
||||
|
||||
if (versor1a.s0 != versor2b.s0 || versor1a.x1 != versor2b.x1 || versor1a.x2 != versor2b.x2 || versor1a.x3 != versor2b.x3 ||
|
||||
versor2a.s0 != versor1b.s0 || versor2a.x1 != versor1b.x1 || versor2a.x2 != versor1b.x2 || versor2a.x3 != versor1b.x3) {
|
||||
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
|
||||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
@ -88,8 +88,8 @@ void test_versor_swap_fp64()
|
|||
|
||||
bgc_versor_swap_fp64(&versor1b, &versor2b);
|
||||
|
||||
if (versor1a.s0 != versor2b.s0 || versor1a.x1 != versor2b.x1 || versor1a.x2 != versor2b.x2 || versor1a.x3 != versor2b.x3 ||
|
||||
versor2a.s0 != versor1b.s0 || versor2a.x1 != versor1b.x1 || versor2a.x2 != versor1b.x2 || versor2a.x3 != versor1b.x3) {
|
||||
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
|
||||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {
|
||||
print_testing_failed();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
<ClInclude Include="matrixes.h" />
|
||||
<ClInclude Include="quaternion.h" />
|
||||
<ClInclude Include="rotation3.h" />
|
||||
<ClInclude Include="types.h" />
|
||||
<ClInclude Include="utilities.h" />
|
||||
<ClInclude Include="slerp.h" />
|
||||
<ClInclude Include="versor.h" />
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@
|
|||
<ClInclude Include="slerp.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="types.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="angle.c">
|
||||
|
|
|
|||
|
|
@ -27,23 +27,35 @@ extern inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64
|
|||
extern inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination);
|
||||
extern inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination);
|
||||
|
||||
extern inline void bgc_complex_reverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* reverse);
|
||||
extern inline void bgc_complex_reverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* reverse);
|
||||
extern inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number);
|
||||
extern inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number);
|
||||
|
||||
extern inline int bgc_complex_normalize_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized);
|
||||
extern inline int bgc_complex_normalize_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized);
|
||||
extern inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite);
|
||||
extern inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite);
|
||||
|
||||
extern inline void bgc_complex_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate);
|
||||
extern inline void bgc_complex_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate);
|
||||
extern inline int bgc_complex_normalize_fp32(BgcComplexFP32* number);
|
||||
extern inline int bgc_complex_normalize_fp64(BgcComplexFP64* number);
|
||||
|
||||
extern inline int bgc_complex_invert_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverted);
|
||||
extern inline int bgc_complex_invert_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverted);
|
||||
extern inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized);
|
||||
extern inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized);
|
||||
|
||||
extern inline void bgc_complex_get_product_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* result);
|
||||
extern inline void bgc_complex_get_product_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* result);
|
||||
extern inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number);
|
||||
extern inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number);
|
||||
|
||||
extern inline int bgc_complex_get_ratio_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient);
|
||||
extern inline int bgc_complex_get_ratio_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient);
|
||||
extern inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate);
|
||||
extern inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate);
|
||||
|
||||
extern inline int bgc_complex_invert_fp32(BgcComplexFP32* number);
|
||||
extern inline int bgc_complex_invert_fp64(BgcComplexFP64* number);
|
||||
|
||||
extern inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse);
|
||||
extern inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse);
|
||||
|
||||
extern inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* result);
|
||||
extern inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* result);
|
||||
|
||||
extern inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient);
|
||||
extern inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient);
|
||||
|
||||
extern inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum);
|
||||
extern inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum);
|
||||
|
|
@ -54,13 +66,10 @@ extern inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_numbe
|
|||
extern inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference);
|
||||
extern inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* difference);
|
||||
|
||||
extern inline void bgc_complex_subtract_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* difference);
|
||||
extern inline void bgc_complex_subtract_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* difference);
|
||||
|
||||
extern inline void bgc_complex_multiply_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product);
|
||||
extern inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product);
|
||||
extern inline void bgc_complex_multiply_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product);
|
||||
|
||||
extern inline void bgc_complex_divide_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient);
|
||||
extern inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient);
|
||||
extern inline void bgc_complex_divide_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient);
|
||||
|
||||
extern inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean);
|
||||
|
|
@ -69,14 +78,8 @@ extern inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number
|
|||
extern inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean);
|
||||
extern inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean);
|
||||
|
||||
extern inline void bgc_complex_interpolate_linearly_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation);
|
||||
extern inline void bgc_complex_interpolate_linearly_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation);
|
||||
|
||||
extern inline void bgc_complex_minimize_fp32(const BgcComplexFP32* number, BgcComplexFP32* minimal);
|
||||
extern inline void bgc_complex_minimize_fp64(const BgcComplexFP64* number, BgcComplexFP64* minimal);
|
||||
|
||||
extern inline void bgc_complex_maximize_fp32(const BgcComplexFP32* number, BgcComplexFP32* maximal);
|
||||
extern inline void bgc_complex_maximize_fp64(const BgcComplexFP64* number, BgcComplexFP64* maximal);
|
||||
extern inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation);
|
||||
extern inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation);
|
||||
|
||||
extern inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2);
|
||||
extern inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2);
|
||||
|
|
|
|||
|
|
@ -142,23 +142,75 @@ inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcCo
|
|||
destination->imaginary = source->imaginary;
|
||||
}
|
||||
|
||||
// ================== Reverse =================== //
|
||||
// ================== Negative ================== //
|
||||
|
||||
inline void bgc_complex_reverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* reverse)
|
||||
inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number)
|
||||
{
|
||||
reverse->real = -number->real;
|
||||
reverse->imaginary = -number->imaginary;
|
||||
number->real = -number->real;
|
||||
number->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_reverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* reverse)
|
||||
inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number)
|
||||
{
|
||||
reverse->real = -number->real;
|
||||
reverse->imaginary = -number->imaginary;
|
||||
number->real = -number->real;
|
||||
number->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite)
|
||||
{
|
||||
opposite->real = -number->real;
|
||||
opposite->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite)
|
||||
{
|
||||
opposite->real = -number->real;
|
||||
opposite->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
// ================= Normalize ================== //
|
||||
|
||||
inline int bgc_complex_normalize_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized)
|
||||
inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
|
||||
{
|
||||
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
|
||||
|
||||
if (bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float multiplicand = sqrtf(1.0f / square_modulus);
|
||||
|
||||
number->real *= multiplicand;
|
||||
number->imaginary *= multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
|
||||
{
|
||||
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
|
||||
|
||||
if (bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double multiplicand = sqrt(1.0 / square_modulus);
|
||||
|
||||
number->real *= multiplicand;
|
||||
number->imaginary *= multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized)
|
||||
{
|
||||
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
|
||||
|
||||
|
|
@ -169,6 +221,8 @@ inline int bgc_complex_normalize_fp32(const BgcComplexFP32* number, BgcComplexFP
|
|||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
normalized->real = 0.0f;
|
||||
normalized->imaginary = 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +234,7 @@ inline int bgc_complex_normalize_fp32(const BgcComplexFP32* number, BgcComplexFP
|
|||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_complex_normalize_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized)
|
||||
inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized)
|
||||
{
|
||||
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
|
||||
|
||||
|
|
@ -191,6 +245,8 @@ inline int bgc_complex_normalize_fp64(const BgcComplexFP64* number, BgcComplexFP
|
|||
}
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
normalized->real = 0.0;
|
||||
normalized->imaginary = 0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -204,13 +260,23 @@ inline int bgc_complex_normalize_fp64(const BgcComplexFP64* number, BgcComplexFP
|
|||
|
||||
// ================= Conjugate ================== //
|
||||
|
||||
inline void bgc_complex_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate)
|
||||
inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number)
|
||||
{
|
||||
number->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number)
|
||||
{
|
||||
number->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate)
|
||||
{
|
||||
conjugate->real = number->real;
|
||||
conjugate->imaginary = -number->imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_complex_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate)
|
||||
inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate)
|
||||
{
|
||||
conjugate->real = number->real;
|
||||
conjugate->imaginary = -number->imaginary;
|
||||
|
|
@ -218,7 +284,7 @@ inline void bgc_complex_conjugate_fp64(const BgcComplexFP64* number, BgcComplexF
|
|||
|
||||
// =================== Invert =================== //
|
||||
|
||||
inline int bgc_complex_invert_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverted)
|
||||
inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse)
|
||||
{
|
||||
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
|
||||
|
||||
|
|
@ -228,13 +294,13 @@ inline int bgc_complex_invert_fp32(const BgcComplexFP32* number, BgcComplexFP32*
|
|||
|
||||
const float multiplicand = 1.0f / square_modulus;
|
||||
|
||||
inverted->real = number->real * multiplicand;
|
||||
inverted->imaginary = -number->imaginary * multiplicand;
|
||||
inverse->real = number->real * multiplicand;
|
||||
inverse->imaginary = -number->imaginary * multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_complex_invert_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverted)
|
||||
inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse)
|
||||
{
|
||||
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
|
||||
|
||||
|
|
@ -244,70 +310,20 @@ inline int bgc_complex_invert_fp64(const BgcComplexFP64* number, BgcComplexFP64*
|
|||
|
||||
const double multiplicand = 1.0 / square_modulus;
|
||||
|
||||
inverted->real = number->real * multiplicand;
|
||||
inverted->imaginary = -number->imaginary * multiplicand;
|
||||
inverse->real = number->real * multiplicand;
|
||||
inverse->imaginary = -number->imaginary * multiplicand;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ================ Get Product ================= //
|
||||
|
||||
inline void bgc_complex_get_product_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* result)
|
||||
inline int bgc_complex_invert_fp32(BgcComplexFP32* number)
|
||||
{
|
||||
const float real = number1->real * number2->real - number1->imaginary * number2->imaginary;
|
||||
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
|
||||
|
||||
result->real = real;
|
||||
result->imaginary = imaginary;
|
||||
return bgc_complex_get_inverse_fp32(number, number);
|
||||
}
|
||||
|
||||
inline void bgc_complex_get_product_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* result)
|
||||
inline int bgc_complex_invert_fp64(BgcComplexFP64* number)
|
||||
{
|
||||
const double real = number1->real * number2->real - number1->imaginary * number2->imaginary;
|
||||
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
|
||||
|
||||
result->real = real;
|
||||
result->imaginary = imaginary;
|
||||
}
|
||||
|
||||
// ================= Get Ratio ================== //
|
||||
|
||||
inline int bgc_complex_get_ratio_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient)
|
||||
{
|
||||
const float square_modulus = bgc_complex_get_square_modulus_fp32(divisor);
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float real = divident->real * divisor->real + divident->imaginary * divisor->imaginary;
|
||||
const float imaginary = divident->imaginary * divisor->real - divident->real * divisor->imaginary;
|
||||
|
||||
const float multiplier = 1.0f / square_modulus;
|
||||
|
||||
quotient->real = real * multiplier;
|
||||
quotient->imaginary = imaginary * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_complex_get_ratio_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient)
|
||||
{
|
||||
const double square_modulus = bgc_complex_get_square_modulus_fp64(divisor);
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double real = divident->real * divisor->real + divident->imaginary * divisor->imaginary;
|
||||
const double imaginary = divident->imaginary * divisor->real - divident->real * divisor->imaginary;
|
||||
|
||||
const double multiplier = 1.0 / square_modulus;
|
||||
|
||||
quotient->real = real * multiplier;
|
||||
quotient->imaginary = imaginary * multiplier;
|
||||
|
||||
return 1;
|
||||
return bgc_complex_get_inverse_fp64(number, number);
|
||||
}
|
||||
|
||||
// =============== Get Exponation =============== //
|
||||
|
|
@ -358,29 +374,35 @@ inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcCo
|
|||
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
|
||||
}
|
||||
|
||||
// ============== Subtract scaled =============== //
|
||||
|
||||
inline void bgc_complex_subtract_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* difference)
|
||||
{
|
||||
difference->real = basic_number->real - scalable_number->real * scale;
|
||||
difference->imaginary = basic_number->imaginary - scalable_number->imaginary * scale;
|
||||
}
|
||||
|
||||