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

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

View file

@ -9,22 +9,22 @@
typedef struct
{
float real, imaginary;
} BgcComplexFP32;
} BGC_FP32_Complex;
typedef struct
{
double real, imaginary;
} BgcComplexFP64;
} BGC_FP64_Complex;
// =================== Reset ==================== //
inline void bgc_complex_reset_fp32(BgcComplexFP32* complex)
inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex)
{
complex->real = 0.0f;
complex->imaginary = 0.0f;
}
inline void bgc_complex_reset_fp64(BgcComplexFP64* complex)
inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex)
{
complex->real = 0.0;
complex->imaginary = 0.0;
@ -32,71 +32,71 @@ inline void bgc_complex_reset_fp64(BgcComplexFP64* complex)
// ==================== Set ===================== //
inline void bgc_complex_set_values_fp32(const float real, const float imaginary, BgcComplexFP32* destination)
inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex)
{
destination->real = real;
destination->imaginary = imaginary;
complex->real = real;
complex->imaginary = imaginary;
}
inline void bgc_complex_set_values_fp64(const double real, const double imaginary, BgcComplexFP64* destination)
inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex)
{
destination->real = real;
destination->imaginary = imaginary;
complex->real = real;
complex->imaginary = imaginary;
}
// ================== Modulus =================== //
inline float bgc_complex_get_square_modulus_fp32(const BgcComplexFP32* number)
inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number)
{
return number->real * number->real + number->imaginary * number->imaginary;
}
inline double bgc_complex_get_square_modulus_fp64(const BgcComplexFP64* number)
inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number)
{
return number->real * number->real + number->imaginary * number->imaginary;
}
inline float bgc_complex_get_modulus_fp32(const BgcComplexFP32* number)
inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number)
{
return sqrtf(bgc_complex_get_square_modulus_fp32(number));
return sqrtf(bgc_fp32_complex_get_square_modulus(number));
}
inline double bgc_complex_get_modulus_fp64(const BgcComplexFP64* number)
inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number)
{
return sqrt(bgc_complex_get_square_modulus_fp64(number));
return sqrt(bgc_fp64_complex_get_square_modulus(number));
}
// ================= Comparison ================= //
inline int bgc_complex_is_zero_fp32(const BgcComplexFP32* number)
inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number)
{
return bgc_complex_get_square_modulus_fp32(number) <= BGC_SQUARE_EPSYLON_FP32;
return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSYLON;
}
inline int bgc_complex_is_zero_fp64(const BgcComplexFP64* number)
inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number)
{
return bgc_complex_get_square_modulus_fp64(number) <= BGC_SQUARE_EPSYLON_FP64;
return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSYLON;
}
inline int bgc_complex_is_unit_fp32(const BgcComplexFP32* number)
inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number)
{
return bgc_is_sqare_unit_fp32(bgc_complex_get_square_modulus_fp32(number));
return bgc_fp32_is_square_unit(bgc_fp32_complex_get_square_modulus(number));
}
inline int bgc_complex_is_unit_fp64(const BgcComplexFP64* number)
inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number)
{
return bgc_is_sqare_unit_fp64(bgc_complex_get_square_modulus_fp64(number));
return bgc_fp64_is_square_unit(bgc_fp64_complex_get_square_modulus(number));
}
// ==================== Copy ==================== //
inline void bgc_complex_copy_fp32(const BgcComplexFP32* source, BgcComplexFP32* destination)
inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
}
inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64* destination)
inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
@ -104,7 +104,7 @@ inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64*
// ==================== Swap ==================== //
inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* number2)
inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2)
{
const float real = number2->real;
const float imaginary = number2->imaginary;
@ -116,7 +116,7 @@ inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* numbe
number1->imaginary = imaginary;
}
inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* number2)
inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2)
{
const double real = number2->real;
const double imaginary = number2->imaginary;
@ -130,13 +130,13 @@ inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* numbe
// ================== Convert =================== //
inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination)
inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination)
{
destination->real = (float)source->real;
destination->imaginary = (float)source->imaginary;
}
inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination)
inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination)
{
destination->real = source->real;
destination->imaginary = source->imaginary;
@ -144,25 +144,25 @@ inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcCo
// ================== Negative ================== //
inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number)
inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number)
{
number->real = -number->real;
number->imaginary = -number->imaginary;
}
inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number)
inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number)
{
number->real = -number->real;
number->imaginary = -number->imaginary;
}
inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite)
inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite)
{
opposite->real = -number->real;
opposite->imaginary = -number->imaginary;
}
inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite)
inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite)
{
opposite->real = -number->real;
opposite->imaginary = -number->imaginary;
@ -170,15 +170,15 @@ inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcCompl
// ================= Normalize ================== //
inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) {
if (bgc_fp32_is_square_unit(square_modulus)) {
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0;
}
@ -190,15 +190,15 @@ inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
return 1;
}
inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) {
if (bgc_fp64_is_square_unit(square_modulus)) {
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0;
}
@ -210,17 +210,17 @@ inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
return 1;
}
inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized)
inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) {
if (bgc_fp32_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
normalized->real = 0.0f;
normalized->imaginary = 0.0f;
return 0;
@ -234,17 +234,17 @@ inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComp
return 1;
}
inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized)
inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) {
if (bgc_fp64_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
normalized->real = 0.0;
normalized->imaginary = 0.0;
return 0;
@ -260,23 +260,23 @@ inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComp
// ================= Conjugate ================== //
inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number)
inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number)
{
number->imaginary = -number->imaginary;
}
inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number)
inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number)
{
number->imaginary = -number->imaginary;
}
inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate)
inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate)
{
conjugate->real = number->real;
conjugate->imaginary = -number->imaginary;
}
inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate)
inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate)
{
conjugate->real = number->real;
conjugate->imaginary = -number->imaginary;
@ -284,11 +284,11 @@ inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComp
// =================== Invert =================== //
inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse)
inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(number);
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0;
}
@ -300,11 +300,11 @@ inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplex
return 1;
}
inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse)
inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(number);
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0;
}
@ -316,31 +316,31 @@ inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplex
return 1;
}
inline int bgc_complex_invert_fp32(BgcComplexFP32* number)
inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number)
{
return bgc_complex_get_inverse_fp32(number, number);
return bgc_fp32_complex_get_inverse(number, number);
}
inline int bgc_complex_invert_fp64(BgcComplexFP64* number)
inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number)
{
return bgc_complex_get_inverse_fp64(number, number);
return bgc_fp64_complex_get_inverse(number, number);
}
// =============== Get Exponation =============== //
void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float real_exponent, const float imaginary_exponent, BgcComplexFP32* power);
void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* power);
void bgc_complex_get_exponation_fp64(const BgcComplexFP64* base, const double real_exponent, const double imaginary_exponent, BgcComplexFP64* power);
void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power);
// ==================== Add ===================== //
inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum)
inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* sum)
{
sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary;
}
inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum)
inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum)
{
sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary;
@ -348,13 +348,13 @@ inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplex
// ================= Add scaled ================= //
inline void bgc_complex_add_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* sum)
inline void bgc_fp32_complex_add_scaled(const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale, BGC_FP32_Complex* sum)
{
sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
}
inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* sum)
inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale, BGC_FP64_Complex* sum)
{
sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
@ -362,13 +362,13 @@ inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, cons
// ================== Subtract ================== //
inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference)
inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* difference)
{
difference->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
}
inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* difference)
inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference)
{
difference->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
@ -376,7 +376,7 @@ inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcCo
// ================== Multiply ================== //
inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* product)
inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product)
{
const float real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -385,7 +385,7 @@ inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcCo
product->imaginary = imaginary;
}
inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* product)
inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product)
{
const double real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -396,13 +396,13 @@ inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcCo
// ============= Multiply By Number ============= //
inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product)
inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
}
inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product)
inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
@ -410,11 +410,11 @@ inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplica
// =================== Divide =================== //
inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient)
inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* quotient)
{
const float square_modulus = bgc_complex_get_square_modulus_fp32(divisor);
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
return 0;
}
@ -429,11 +429,11 @@ inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComp
return 1;
}
inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient)
inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient)
{
const double square_modulus = bgc_complex_get_square_modulus_fp64(divisor);
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
return 0;
}
@ -450,25 +450,25 @@ inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComp
// ============== Divide By Number ============== //
inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient)
inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient)
{
bgc_complex_multiply_by_number_fp32(dividend, 1.0f / divisor, quotient);
bgc_fp32_complex_multiply(dividend, 1.0f / divisor, quotient);
}
inline void bgc_complex_divide_by_number_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient)
inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient)
{
bgc_complex_multiply_by_number_fp64(dividend, 1.0 / divisor, quotient);
bgc_fp64_complex_multiply(dividend, 1.0 / divisor, quotient);
}
// ================== Average2 ================== //
inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean)
inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* mean)
{
mean->real = (number1->real + number2->real) * 0.5f;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f;
}
inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* mean)
inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean)
{
mean->real = (number1->real + number2->real) * 0.5;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5;
@ -476,70 +476,70 @@ inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, cons
// ================== Average3 ================== //
inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean)
inline void bgc_fp32_complex_get_mean3(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3, BGC_FP32_Complex* mean)
{
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP32;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP32;
mean->real = (number1->real + number2->real + number3->real) * BGC_FP32_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD;
}
inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean)
inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3, BGC_FP64_Complex* mean)
{
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP64;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP64;
mean->real = (number1->real + number2->real + number3->real) * BGC_FP64_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD;
}
// =================== Linear =================== //
inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation)
inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* interpolation)
{
const float counterphase = 1.0f - phase;
const float counter_phase = 1.0f - phase;
interpolation->real = number1->real * counterphase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase;
interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
}
inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation)
inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation)
{
const double counterphase = 1.0 - phase;
const double counter_phase = 1.0 - phase;
interpolation->real = number1->real * counterphase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase;
interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
}
// ================== Are Close ================= //
inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2)
inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
const float square_modulus1 = bgc_complex_get_square_modulus_fp32(number1);
const float square_modulus2 = bgc_complex_get_square_modulus_fp32(number2);
const float square_modulus1 = bgc_fp32_complex_get_square_modulus(number1);
const float square_modulus2 = bgc_fp32_complex_get_square_modulus(number2);
const float d_real = number1->real - number2->real;
const float d_imaginary = number1->imaginary - number2->imaginary;
const float square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32;
if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP32_SQUARE_EPSYLON;
}
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2;
return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
}
inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2)
inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
const double square_modulus1 = bgc_complex_get_square_modulus_fp64(number1);
const double square_modulus2 = bgc_complex_get_square_modulus_fp64(number2);
const double square_modulus1 = bgc_fp64_complex_get_square_modulus(number1);
const double square_modulus2 = bgc_fp64_complex_get_square_modulus(number2);
const double d_real = number1->real - number2->real;
const double d_imaginary = number1->imaginary - number2->imaginary;
const double square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64;
if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_FP64_SQUARE_EPSYLON;
}
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2;
return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
}
#endif