Переименование функций для универсализации названий, добавление функций умножения вектора на дуальное число, а также исправление реализации функции умножения кватерниона на дуальное число на более безопасную реализацию
This commit is contained in:
parent
405af2f3a7
commit
078512c3d5
10 changed files with 234 additions and 98 deletions
|
|
@ -381,13 +381,13 @@ inline void bgc_fp64_complex_subtract_scaled(BGC_FP64_Complex* const difference,
|
|||
|
||||
// ========== Multiply By Real Number =========== //
|
||||
|
||||
inline void bgc_fp32_complex_multiply_by_real(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const float multiplier)
|
||||
inline void bgc_fp32_complex_multiply_by_real_number(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const float multiplier)
|
||||
{
|
||||
product->real = multiplicand->real * multiplier;
|
||||
product->imaginary = multiplicand->imaginary * multiplier;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_complex_multiply_by_real(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const double multiplier)
|
||||
inline void bgc_fp64_complex_multiply_by_real_number(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const double multiplier)
|
||||
{
|
||||
product->real = multiplicand->real * multiplier;
|
||||
product->imaginary = multiplicand->imaginary * multiplier;
|
||||
|
|
@ -395,7 +395,7 @@ inline void bgc_fp64_complex_multiply_by_real(BGC_FP64_Complex* const product, c
|
|||
|
||||
// ========= Multiply By Complex Number ========= //
|
||||
|
||||
inline void bgc_fp32_complex_multiply_by_complex(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const BGC_FP32_Complex* const multiplier)
|
||||
inline void bgc_fp32_complex_multiply_by_complex_number(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const BGC_FP32_Complex* const multiplier)
|
||||
{
|
||||
const float real = multiplicand->real * multiplier->real - multiplicand->imaginary * multiplier->imaginary;
|
||||
const float imaginary = multiplicand->real * multiplier->imaginary + multiplicand->imaginary * multiplier->real;
|
||||
|
|
@ -404,7 +404,7 @@ inline void bgc_fp32_complex_multiply_by_complex(BGC_FP32_Complex* const product
|
|||
product->imaginary = imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_complex_multiply_by_complex(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const BGC_FP64_Complex* const multiplier)
|
||||
inline void bgc_fp64_complex_multiply_by_complex_number(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const BGC_FP64_Complex* const multiplier)
|
||||
{
|
||||
const double real = multiplicand->real * multiplier->real - multiplicand->imaginary * multiplier->imaginary;
|
||||
const double imaginary = multiplicand->real * multiplier->imaginary + multiplicand->imaginary * multiplier->real;
|
||||
|
|
@ -415,7 +415,7 @@ inline void bgc_fp64_complex_multiply_by_complex(BGC_FP64_Complex* const product
|
|||
|
||||
// ======== Multiply By Conjugate Number ======== //
|
||||
|
||||
inline void bgc_fp32_complex_multiply_by_conjugate(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const BGC_FP32_Complex* const multiplier_to_conjugate)
|
||||
inline void bgc_fp32_complex_multiply_by_conjugate_complex_number(BGC_FP32_Complex* const product, const BGC_FP32_Complex* const multiplicand, const BGC_FP32_Complex* const multiplier_to_conjugate)
|
||||
{
|
||||
const float real = multiplicand->real * multiplier_to_conjugate->real + multiplicand->imaginary * multiplier_to_conjugate->imaginary;
|
||||
const float imaginary = multiplicand->imaginary * multiplier_to_conjugate->real - multiplicand->real * multiplier_to_conjugate->imaginary;
|
||||
|
|
@ -424,7 +424,7 @@ inline void bgc_fp32_complex_multiply_by_conjugate(BGC_FP32_Complex* const produ
|
|||
product->imaginary = imaginary;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_complex_multiply_by_conjugate(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const BGC_FP64_Complex* const multiplier_to_conjugate)
|
||||
inline void bgc_fp64_complex_multiply_by_conjugate_complex_number(BGC_FP64_Complex* const product, const BGC_FP64_Complex* const multiplicand, const BGC_FP64_Complex* const multiplier_to_conjugate)
|
||||
{
|
||||
const double real = multiplicand->real * multiplier_to_conjugate->real + multiplicand->imaginary * multiplier_to_conjugate->imaginary;
|
||||
const double imaginary = multiplicand->imaginary * multiplier_to_conjugate->real - multiplicand->real * multiplier_to_conjugate->imaginary;
|
||||
|
|
@ -435,31 +435,31 @@ inline void bgc_fp64_complex_multiply_by_conjugate(BGC_FP64_Complex* const produ
|
|||
|
||||
// =========== Divide by Real Number ============ //
|
||||
|
||||
inline int bgc_fp32_complex_divide_by_real(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const dividend, const float divisor)
|
||||
inline int bgc_fp32_complex_divide_by_real_number(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_complex_multiply_by_real(quotient, dividend, 1.0f / divisor);
|
||||
bgc_fp32_complex_multiply_by_real_number(quotient, dividend, 1.0f / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_complex_divide_by_real(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const dividend, const double divisor)
|
||||
inline int bgc_fp64_complex_divide_by_real_number(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_complex_multiply_by_real(quotient, dividend, 1.0 / divisor);
|
||||
bgc_fp64_complex_multiply_by_real_number(quotient, dividend, 1.0 / divisor);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
// ========== Divide by Complex Number ========== //
|
||||
|
||||
inline int bgc_fp32_complex_divide_by_complex(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const divident, const BGC_FP32_Complex* const divisor)
|
||||
inline int bgc_fp32_complex_divide_by_complex_number(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const divident, const BGC_FP32_Complex* const divisor)
|
||||
{
|
||||
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
|
||||
|
||||
|
|
@ -467,13 +467,13 @@ inline int bgc_fp32_complex_divide_by_complex(BGC_FP32_Complex* const quotient,
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_complex_multiply_by_conjugate(quotient, divident, divisor);
|
||||
bgc_fp32_complex_multiply_by_real(quotient, quotient, 1.0f / square_modulus);
|
||||
bgc_fp32_complex_multiply_by_conjugate_complex_number(quotient, divident, divisor);
|
||||
bgc_fp32_complex_multiply_by_real_number(quotient, quotient, 1.0f / square_modulus);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_complex_divide_by_complex(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const divident, const BGC_FP64_Complex* const divisor)
|
||||
inline int bgc_fp64_complex_divide_by_complex_number(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const divident, const BGC_FP64_Complex* const divisor)
|
||||
{
|
||||
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
|
||||
|
||||
|
|
@ -481,15 +481,15 @@ inline int bgc_fp64_complex_divide_by_complex(BGC_FP64_Complex* const quotient,
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_complex_multiply_by_conjugate(quotient, divident, divisor);
|
||||
bgc_fp64_complex_multiply_by_real(quotient, quotient, 1.0 / square_modulus);
|
||||
bgc_fp64_complex_multiply_by_conjugate_complex_number(quotient, divident, divisor);
|
||||
bgc_fp64_complex_multiply_by_real_number(quotient, quotient, 1.0 / square_modulus);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
// ========= Divide By Conjugate Number ========= //
|
||||
|
||||
inline int bgc_fp32_complex_divide_by_conjugate(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const divident, const BGC_FP32_Complex* const divisor_to_conjugate)
|
||||
inline int bgc_fp32_complex_divide_by_conjugate_complex_number(BGC_FP32_Complex* const quotient, const BGC_FP32_Complex* const divident, const BGC_FP32_Complex* const divisor_to_conjugate)
|
||||
{
|
||||
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor_to_conjugate);
|
||||
|
||||
|
|
@ -497,13 +497,13 @@ inline int bgc_fp32_complex_divide_by_conjugate(BGC_FP32_Complex* const quotient
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_complex_multiply_by_complex(quotient, divident, divisor_to_conjugate);
|
||||
bgc_fp32_complex_multiply_by_real(quotient, quotient, 1.0f / square_modulus);
|
||||
bgc_fp32_complex_multiply_by_complex_number(quotient, divident, divisor_to_conjugate);
|
||||
bgc_fp32_complex_multiply_by_real_number(quotient, quotient, 1.0f / square_modulus);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_complex_divide_by_conjugate(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const divident, const BGC_FP64_Complex* const divisor_to_conjugate)
|
||||
inline int bgc_fp64_complex_divide_by_conjugate_complex_number(BGC_FP64_Complex* const quotient, const BGC_FP64_Complex* const divident, const BGC_FP64_Complex* const divisor_to_conjugate)
|
||||
{
|
||||
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor_to_conjugate);
|
||||
|
||||
|
|
@ -511,8 +511,8 @@ inline int bgc_fp64_complex_divide_by_conjugate(BGC_FP64_Complex* const quotient
|
|||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_complex_multiply_by_complex(quotient, divident, divisor_to_conjugate);
|
||||
bgc_fp64_complex_multiply_by_real(quotient, quotient, 1.0 / square_modulus);
|
||||
bgc_fp64_complex_multiply_by_complex_number(quotient, divident, divisor_to_conjugate);
|
||||
bgc_fp64_complex_multiply_by_real_number(quotient, quotient, 1.0 / square_modulus);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue