Рефакторинг и оптимизация вычислений / Refactoring and optimization of computations
This commit is contained in:
parent
03e390c1d0
commit
2655e43cb4
15 changed files with 810 additions and 829 deletions
|
@ -510,76 +510,60 @@ static inline void bg_fp64_matrix3x3_multiply(const BgFP64Matrix3x3* multiplican
|
|||
|
||||
static inline void bg_fp32_matrix3x3_divide(const BgFP32Matrix3x3* dividend, const float divisor, BgFP32Matrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
bg_fp32_matrix3x3_multiply(dividend, 1.0f / divisor, quotient);
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x3_divide(const BgFP64Matrix3x3* dividend, const double divisor, BgFP64Matrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
bg_fp64_matrix3x3_multiply(dividend, 1.0 / divisor, quotient);
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
static inline void bg_fp32_matrix3x3_left_product(const BgFP32Vector3* vector, const BgFP32Matrix3x3* matrix, BgFP32Vector3* result)
|
||||
{
|
||||
bg_fp32_vector3_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2,
|
||||
vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3,
|
||||
result
|
||||
);
|
||||
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const float x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
result->x1 = x1;
|
||||
result->x2 = x2;
|
||||
result->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x3_left_product(const BgFP64Vector3* vector, const BgFP64Matrix3x3* matrix, BgFP64Vector3* result)
|
||||
{
|
||||
bg_fp64_vector3_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2,
|
||||
vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3,
|
||||
result
|
||||
);
|
||||
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||
const double x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3;
|
||||
|
||||
result->x1 = x1;
|
||||
result->x2 = x2;
|
||||
result->x3 = x3;
|
||||
}
|
||||
|
||||
// ============ Right Vector Product ============ //
|
||||
|
||||
static inline void bg_fp32_matrix3x3_right_product(const BgFP32Matrix3x3* matrix, const BgFP32Vector3* vector, BgFP32Vector3* result)
|
||||
{
|
||||
bg_fp32_vector3_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3,
|
||||
matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3,
|
||||
result
|
||||
);
|
||||
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const float x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
result->x1 = x1;
|
||||
result->x2 = x2;
|
||||
result->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_matrix3x3_right_product(const BgFP64Matrix3x3* matrix, const BgFP64Vector3* vector, BgFP64Vector3* result)
|
||||
{
|
||||
bg_fp64_vector3_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3,
|
||||
matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3,
|
||||
result
|
||||
);
|
||||
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||
const double x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3;
|
||||
|
||||
result->x1 = x1;
|
||||
result->x2 = x2;
|
||||
result->x3 = x3;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue