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

@ -63,8 +63,8 @@ extern inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, c
extern inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier);
extern inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier);
extern inline void bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
extern inline void bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
extern inline int bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor);
extern inline int bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor);
extern inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase);
extern inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase);
@ -82,7 +82,7 @@ int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_M
const float determinant = bgc_fp32_matrix3x3_get_determinant(matrix);
if (bgc_fp32_is_zero(determinant)) {
return 0;
return BGC_FAILURE;
}
const float r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
@ -111,7 +111,7 @@ int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_M
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
return BGC_SUCCESS;
}
int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_Matrix3x3* matrix)
@ -119,7 +119,7 @@ int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_M
const double determinant = bgc_fp64_matrix3x3_get_determinant(matrix);
if (bgc_fp64_is_zero(determinant)) {
return 0;
return BGC_FAILURE;
}
const double r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
@ -148,5 +148,5 @@ int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_M
inverse->r3c2 = r3c2 * multiplier;
inverse->r3c3 = r3c3 * multiplier;
return 1;
return BGC_SUCCESS;
}