Добавление проверки при делении, стандартизация возвращаемого значения (BGC_SUCCESS, BGC_FAILURE)

This commit is contained in:
Andrey Pokidov 2026-02-11 20:55:54 +07:00
parent a4b9f8b2b9
commit e9558ff977
27 changed files with 589 additions and 370 deletions

View file

@ -92,52 +92,52 @@ inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, cons
inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
{
if (!bgc_fp32_matrix2x2_invert(&affine->distortion)) {
return 0;
if (bgc_fp32_matrix2x2_invert(&affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp32_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector2_revert(&affine->shift);
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
{
if (!bgc_fp64_matrix2x2_invert(&affine->distortion)) {
return 0;
if (bgc_fp64_matrix2x2_invert(&affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp64_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector2_revert(&affine->shift);
return 1;
return BGC_SUCCESS;
}
// ================= Get Inverse ================= //
inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2 * affine)
{
if (!bgc_fp32_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0;
if (bgc_fp32_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp32_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp32_vector2_revert(&inverse->shift);
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2 * affine)
{
if (!bgc_fp64_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) {
return 0;
if (bgc_fp64_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp64_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift);
bgc_fp64_vector2_revert(&inverse->shift);
return 1;
return BGC_SUCCESS;
}
// =================== Combine =================== //

View file

@ -91,52 +91,52 @@ inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, cons
inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
{
if (!bgc_fp32_matrix3x3_invert(&affine->distortion)) {
return 0;
if (bgc_fp32_matrix3x3_invert(&affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp32_vector3_revert(&affine->shift);
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
{
if (!bgc_fp64_matrix3x3_invert(&affine->distortion)) {
return 0;
if (bgc_fp64_matrix3x3_invert(&affine->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift);
bgc_fp64_vector3_revert(&affine->shift);
return 1;
return BGC_SUCCESS;
}
// ================= Get Inverse ================= //
inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source)
{
if (!bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0;
if (bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp32_vector3_revert(&destination->shift);
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source)
{
if (!bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) {
return 0;
if (bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion) != BGC_SUCCESS) {
return BGC_FAILURE;
}
bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift);
bgc_fp64_vector3_revert(&destination->shift);
return 1;
return BGC_SUCCESS;
}
// =================== Combine =================== //

View file

@ -51,12 +51,6 @@ extern inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number);
extern inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number);
extern inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number);
extern inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
extern inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor);
extern inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor);
extern inline void bgc_fp32_complex_add(BGC_FP32_Complex* sum, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_add(BGC_FP64_Complex* sum, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
@ -66,11 +60,23 @@ extern inline void bgc_fp64_complex_add_scaled(BGC_FP64_Complex* sum, const BGC_
extern inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend);
extern inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend);
extern inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier);
extern inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier);
extern inline void bgc_fp32_complex_multiply_by_real(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier);
extern inline void bgc_fp64_complex_multiply_by_real(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier);
extern inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor);
extern inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor);
extern inline void bgc_fp32_complex_multiply_by_complex(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const BGC_FP32_Complex* multiplier);
extern inline void bgc_fp64_complex_multiply_by_complex(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const BGC_FP64_Complex* multiplier);
extern inline void bgc_fp32_complex_multiply_by_conjugate(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const BGC_FP32_Complex* multiplier_to_conjugate);
extern inline void bgc_fp64_complex_multiply_by_conjugate(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const BGC_FP64_Complex* multiplier_to_conjugate);
extern inline void bgc_fp32_complex_divide_by_real(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor);
extern inline void bgc_fp64_complex_divide_by_real(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor);
extern inline int bgc_fp32_complex_divide_by_complex(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor);
extern inline int bgc_fp64_complex_divide_by_complex(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor);
extern inline int bgc_fp32_complex_divide_by_conjugate(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor_to_conjugate);
extern inline int bgc_fp64_complex_divide_by_conjugate(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor_to_conjugate);
extern inline void bgc_fp32_complex_get_mean2(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline void bgc_fp64_complex_get_mean2(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);

View file

@ -174,12 +174,12 @@ inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
{
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_fp32_is_square_unit(square_modulus)) {
return 1;
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return BGC_FAILURE;
}
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
if (bgc_fp32_is_square_unit(square_modulus)) {
return BGC_SUCCESS;
}
const float multiplicand = sqrtf(1.0f / square_modulus);
@ -187,19 +187,19 @@ inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
number->real *= multiplicand;
number->imaginary *= multiplicand;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
{
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_fp64_is_square_unit(square_modulus)) {
return 1;
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return BGC_FAILURE;
}
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
if (bgc_fp64_is_square_unit(square_modulus)) {
return BGC_SUCCESS;
}
const double multiplicand = sqrt(1.0 / square_modulus);
@ -207,23 +207,23 @@ inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
number->real *= multiplicand;
number->imaginary *= multiplicand;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number)
{
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_fp32_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
normalized->real = 0.0f;
normalized->imaginary = 0.0f;
return 0;
return BGC_FAILURE;
}
if (bgc_fp32_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return BGC_SUCCESS;
}
const float multiplicand = sqrtf(1.0f / square_modulus);
@ -231,23 +231,23 @@ inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const B
normalized->real = number->real * multiplicand;
normalized->imaginary = number->imaginary * multiplicand;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number)
{
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_fp64_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return 1;
}
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
normalized->real = 0.0;
normalized->imaginary = 0.0;
return 0;
return BGC_FAILURE;
}
if (bgc_fp64_is_square_unit(square_modulus)) {
normalized->real = number->real;
normalized->imaginary = number->imaginary;
return BGC_SUCCESS;
}
const double multiplicand = sqrt(1.0 / square_modulus);
@ -255,7 +255,7 @@ inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const B
normalized->real = number->real * multiplicand;
normalized->imaginary = number->imaginary * multiplicand;
return 1;
return BGC_SUCCESS;
}
// ================= Conjugate ================== //
@ -289,7 +289,7 @@ inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP3
const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
return BGC_FAILURE;
}
const float multiplicand = 1.0f / square_modulus;
@ -297,7 +297,7 @@ inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP3
inverse->real = number->real * multiplicand;
inverse->imaginary = -number->imaginary * multiplicand;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number)
@ -305,7 +305,7 @@ inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP6
const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
return 0;
return BGC_FAILURE;
}
const double multiplicand = 1.0 / square_modulus;
@ -313,7 +313,7 @@ inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP6
inverse->real = number->real * multiplicand;
inverse->imaginary = -number->imaginary * multiplicand;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number)
@ -374,90 +374,142 @@ inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP
difference->imaginary = minuend->imaginary - subtrahend->imaginary;
}
// ================== Multiply ================== //
// ========== Multiply By Real Number =========== //
inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{
const float real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
product->real = real;
product->imaginary = imaginary;
}
inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{
const double real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
product->real = real;
product->imaginary = imaginary;
}
// ============= Multiply By Number ============= //
inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier)
inline void bgc_fp32_complex_multiply_by_real(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
}
inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier)
inline void bgc_fp64_complex_multiply_by_real(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier)
{
product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier;
}
// =================== Divide =================== //
// ========= Multiply By Complex Number ========= //
inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor)
inline void bgc_fp32_complex_multiply_by_complex(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const BGC_FP32_Complex* multiplier)
{
const float real = multiplicand->real * multiplier->real - multiplicand->imaginary * multiplier->imaginary;
const float imaginary = multiplicand->real * multiplier->imaginary + multiplicand->imaginary * multiplier->real;
product->real = real;
product->imaginary = imaginary;
}
inline void bgc_fp64_complex_multiply_by_complex(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const BGC_FP64_Complex* multiplier)
{
const double real = multiplicand->real * multiplier->real - multiplicand->imaginary * multiplier->imaginary;
const double imaginary = multiplicand->real * multiplier->imaginary + multiplicand->imaginary * multiplier->real;
product->real = real;
product->imaginary = imaginary;
}
// ======== Multiply By Conjugate Number ======== //
inline void bgc_fp32_complex_multiply_by_conjugate(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const BGC_FP32_Complex* 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;
product->real = real;
product->imaginary = imaginary;
}
inline void bgc_fp64_complex_multiply_by_conjugate(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const BGC_FP64_Complex* 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;
product->real = real;
product->imaginary = imaginary;
}
// =========== Divide by Real Number ============ //
inline int bgc_fp32_complex_divide_by_real(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* 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);
return BGC_SUCCESS;
}
inline int bgc_fp64_complex_divide_by_real(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* 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);
return BGC_SUCCESS;
}
// ========== Divide by Complex Number ========== //
inline int bgc_fp32_complex_divide_by_complex(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor)
{
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
return 0;
return BGC_FAILURE;
}
const float real = divident->real * divisor->real + divident->imaginary * divisor->imaginary;
const float imaginary = divident->imaginary * divisor->real - divident->real * divisor->imaginary;
bgc_fp32_complex_multiply_by_conjugate(quotient, divident, divisor);
bgc_fp32_complex_multiply_by_real(quotient, quotient, 1.0f / square_modulus);
const float multiplier = 1.0f / square_modulus;
quotient->real = real * multiplier;
quotient->imaginary = imaginary * multiplier;
return 1;
return BGC_SUCCESS;
}
inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor)
inline int bgc_fp64_complex_divide_by_complex(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor)
{
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
return 0;
return BGC_FAILURE;
}
const double real = divident->real * divisor->real + divident->imaginary * divisor->imaginary;
const double imaginary = divident->imaginary * divisor->real - divident->real * divisor->imaginary;
bgc_fp64_complex_multiply_by_conjugate(quotient, divident, divisor);
bgc_fp64_complex_multiply_by_real(quotient, quotient, 1.0 / square_modulus);
const double multiplier = 1.0 / square_modulus;
quotient->real = real * multiplier;
quotient->imaginary = imaginary * multiplier;
return 1;
return BGC_SUCCESS;
}
// ============== Divide By Number ============== //
// ========= Divide By Conjugate Number ========= //
inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor)
inline int bgc_fp32_complex_divide_by_conjugate(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor_to_conjugate)
{
bgc_fp32_complex_multiply(quotient, dividend, 1.0f / divisor);
const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor_to_conjugate);
if (square_modulus <= BGC_FP32_SQUARE_EPSILON) {
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);
return BGC_SUCCESS;
}
inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor)
inline int bgc_fp64_complex_divide_by_conjugate(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor_to_conjugate)
{
bgc_fp64_complex_multiply(quotient, dividend, 1.0 / divisor);
const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor_to_conjugate);
if (square_modulus <= BGC_FP64_SQUARE_EPSILON) {
return BGC_FAILURE;
}
bgc_fp32_complex_multiply_by_complex(quotient, divident, divisor_to_conjugate);
bgc_fp32_complex_multiply_by_real(quotient, quotient, 1.0 / square_modulus);
return BGC_SUCCESS;
}
// ================== Average2 ================== //

View file

@ -12,6 +12,18 @@ extern inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, c
extern inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second);
extern inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second);
extern inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_dual_number_conjugate(BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_conjugate(BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_dual_number_get_conjugate(BGC_FP32_DualNumber* conjugate, const BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_get_conjugate(BGC_FP64_DualNumber* conjugate, const BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second);
extern inline void bgc_fp64_dual_number_add(BGC_FP64_DualNumber* sum, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second);
@ -41,9 +53,3 @@ extern inline void bgc_fp64_dual_number_get_mean3(BGC_FP64_DualNumber* mean, con
extern inline void bgc_fp32_dual_number_interpolate(BGC_FP32_DualNumber* interpolation, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second, const float phase);
extern inline void bgc_fp64_dual_number_interpolate(BGC_FP64_DualNumber* interpolation, const BGC_FP64_DualNumber* first, const BGC_FP64_DualNumber* second, const double phase);
extern inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number);
extern inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number);
extern inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number);

View file

@ -69,6 +69,74 @@ inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualN
first->dual = second->dual;
}
// ================== Convert =================== //
inline void bgc_fp64_dual_number_convert_to_fp32(BGC_FP32_DualNumber* first, BGC_FP64_DualNumber* second)
{
first->real = (float) second->real;
first->dual = (float) second->dual;
}
inline void bgc_fp32_dual_number_convert_to_fp64(BGC_FP64_DualNumber* first, BGC_FP32_DualNumber* second)
{
first->real = second->real;
first->dual = second->dual;
}
// =================== Revert =================== //
inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
// ================ Get Reverse ================= //
inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
// ================= Conjugate ================== //
inline void bgc_fp32_dual_number_conjugate(BGC_FP32_DualNumber* number)
{
number->dual = -number->dual;
}
inline void bgc_fp64_dual_number_conjugate(BGC_FP64_DualNumber* number)
{
number->dual = -number->dual;
}
// =============== Get Conjugate ================ //
inline void bgc_fp32_dual_number_get_conjugate(BGC_FP32_DualNumber* conjugate, const BGC_FP32_DualNumber* number)
{
conjugate->real = number->real;
conjugate->dual = -number->dual;
}
inline void bgc_fp64_dual_number_get_conjugate(BGC_FP64_DualNumber* conjugate, const BGC_FP64_DualNumber* number)
{
conjugate->real = number->real;
conjugate->dual = -number->dual;
}
// ==================== Add ===================== //
inline void bgc_fp32_dual_number_add(BGC_FP32_DualNumber* sum, const BGC_FP32_DualNumber* first, const BGC_FP32_DualNumber* second)
@ -211,32 +279,4 @@ inline void bgc_fp64_dual_number_interpolate(BGC_FP64_DualNumber* interpolation,
interpolation->dual = first->dual * counter_phase + second->dual * phase;
}
// =================== Revert =================== //
inline void bgc_fp32_dual_number_revert(BGC_FP32_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
inline void bgc_fp64_dual_number_revert(BGC_FP64_DualNumber* number)
{
number->real = -number->real;
number->dual = -number->dual;
}
// ================ Get Reverse ================= //
inline void bgc_fp32_number_get_reverse(BGC_FP32_DualNumber* reverse, const BGC_FP32_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
inline void bgc_fp64_number_get_reverse(BGC_FP64_DualNumber* reverse, const BGC_FP64_DualNumber* number)
{
reverse->real = -number->real;
reverse->dual = -number->dual;
}
#endif

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -21,11 +21,11 @@ extern inline void bgc_fp64_dual_quaternion_add_scaled(BGC_FP64_DualQuaternion*
extern inline void bgc_fp32_dual_quaternion_subtract(BGC_FP32_DualQuaternion* difference, const BGC_FP32_DualQuaternion* minuend, const BGC_FP32_DualQuaternion* subtrahend);
extern inline void bgc_fp64_dual_quaternion_subtract(BGC_FP64_DualQuaternion* difference, const BGC_FP64_DualQuaternion* minuend, const BGC_FP64_DualQuaternion* subtrahend);
extern inline void bgc_fp32_dual_quaternion_multiply_by_number(BGC_FP32_DualQuaternion* product, const BGC_FP32_DualQuaternion* multiplicand, const float multipier);
extern inline void bgc_fp64_dual_quaternion_multiply_by_number(BGC_FP64_DualQuaternion* product, const BGC_FP64_DualQuaternion* multiplicand, const double multipier);
extern inline void bgc_fp32_dual_quaternion_multiply_by_real(BGC_FP32_DualQuaternion* product, const BGC_FP32_DualQuaternion* multiplicand, const float multipier);
extern inline void bgc_fp64_dual_quaternion_multiply_by_real(BGC_FP64_DualQuaternion* product, const BGC_FP64_DualQuaternion* multiplicand, const double multipier);
extern inline void bgc_fp32_dual_quaternion_divide_by_number(BGC_FP32_DualQuaternion* quotient, const BGC_FP32_DualQuaternion* divident, const float divisor);
extern inline void bgc_fp64_dual_quaternion_divide_by_number(BGC_FP64_DualQuaternion* quotient, const BGC_FP64_DualQuaternion* divident, const double divisor);
extern inline void bgc_fp32_dual_quaternion_divide_by_real(BGC_FP32_DualQuaternion* quotient, const BGC_FP32_DualQuaternion* divident, const float divisor);