#include "./complex.h" extern inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex); extern inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex); extern inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex); extern inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex); extern inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number); extern inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number); extern inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number); extern inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number); extern inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination); extern inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination); extern inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2); extern inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2); extern inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination); extern inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination); extern inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number); extern inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number); extern inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite); extern inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite); extern inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized); extern inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized); extern inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number); extern inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number); extern inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate); extern inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate); extern inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse); extern inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse); extern inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product); extern inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product); extern inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* quotient); extern inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient); extern inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* sum); extern inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum); extern 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); extern 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); extern inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* difference); extern inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference); extern inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product); extern inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product); extern inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient); extern inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient); extern inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* mean); extern inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean); extern 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); extern 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); extern inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* interpolation); extern inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation); extern inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2); extern inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2); // =============== Get Exponation =============== // void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* power) { const float square_modulus = bgc_fp32_complex_get_square_modulus(base); if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) { power->real = 0.0f; power->imaginary = 0.0f; return; } const float log_modulus = logf(square_modulus) * 0.5f; const float angle = atan2f(base->imaginary, base->real); const float power_modulus = expf(real_exponent * log_modulus - imaginary_exponent * angle); const float power_angle = real_exponent * angle + imaginary_exponent * log_modulus; power->real = power_modulus * cosf(power_angle); power->imaginary = power_modulus * sinf(power_angle); } void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power) { const double square_modulus = bgc_fp64_complex_get_square_modulus(base); if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) { power->real = 0.0; power->imaginary = 0.0; return; } const double log_modulus = log(square_modulus) * 0.5; const double angle = atan2(base->imaginary, base->real); const double power_modulus = exp(real_exponent * log_modulus - imaginary_exponent * angle); const double power_angle = real_exponent * angle + imaginary_exponent * log_modulus; power->real = power_modulus * cos(power_angle); power->imaginary = power_modulus * sin(power_angle); }