Добавление проверки при делении, стандартизация возвращаемого значения (BGC_SUCCESS, BGC_FAILURE)
This commit is contained in:
parent
a4b9f8b2b9
commit
e9558ff977
27 changed files with 589 additions and 370 deletions
|
|
@ -242,7 +242,7 @@ inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC
|
|||
const float determinant = bgc_fp32_matrix2x2_get_determinant(matrix);
|
||||
|
||||
if (bgc_fp32_is_zero(determinant)) {
|
||||
return 0;
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
const float r1c1 = matrix->r2c2;
|
||||
|
|
@ -259,7 +259,7 @@ inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC
|
|||
inverse->r2c1 = r2c1 * multiplier;
|
||||
inverse->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC_FP64_Matrix2x2* matrix)
|
||||
|
|
@ -267,7 +267,7 @@ inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC
|
|||
const double determinant = bgc_fp64_matrix2x2_get_determinant(matrix);
|
||||
|
||||
if (bgc_fp64_is_zero(determinant)) {
|
||||
return 0;
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
const double r1c1 = matrix->r2c2;
|
||||
|
|
@ -284,7 +284,7 @@ inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC
|
|||
inverse->r2c1 = r2c1 * multiplier;
|
||||
inverse->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
// =================== Invert =================== //
|
||||
|
|
@ -557,14 +557,24 @@ inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_F
|
|||
|
||||
// =================== Divide =================== //
|
||||
|
||||
inline void bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor)
|
||||
inline int bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor)
|
||||
{
|
||||
if (bgc_fp32_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp32_matrix2x2_multiply(quotient, dividend, 1.0f / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor)
|
||||
inline int bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor)
|
||||
{
|
||||
if (bgc_fp64_is_zero(divisor) || isnan(divisor)) {
|
||||
return BGC_FAILURE;
|
||||
}
|
||||
|
||||
bgc_fp64_matrix2x2_multiply(quotient, dividend, 1.0 / divisor);
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
// ================ Interpolate ================= //
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue