Добавление проверки при делении, стандартизация возвращаемого значения (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

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

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -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;