Операции минимальный и максимальный для векторов
This commit is contained in:
parent
5754c5747c
commit
e7ba1ad218
4 changed files with 124 additions and 0 deletions
|
@ -62,6 +62,12 @@ extern inline void bgc_vector2_mean_of_two_fp64(const BgcVector2FP64* vector1, c
|
|||
|
||||
extern inline void bgc_vector2_mean_of_three_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const BgcVector2FP32* vector3, BgcVector2FP32* mean);
|
||||
extern inline void bgc_vector2_mean_of_three_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const BgcVector2FP64* vector3, BgcVector2FP64* mean);
|
||||
|
||||
extern inline void bgc_vector2_minimize_fp32(const BgcVector2FP32* vector, BgcVector2FP32* minimal);
|
||||
extern inline void bgc_vector2_minimize_fp64(const BgcVector2FP64* vector, BgcVector2FP64* minimal);
|
||||
|
||||
extern inline void bgc_vector2_maximize_fp32(const BgcVector2FP32* vector, BgcVector2FP32* maximal);
|
||||
extern inline void bgc_vector2_maximize_fp64(const BgcVector2FP64* vector, BgcVector2FP64* maximal);
|
||||
|
||||
extern inline float bgc_vector2_scalar_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2);
|
||||
extern inline double bgc_vector2_scalar_product_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2);
|
||||
|
|
|
@ -366,6 +366,54 @@ inline void bgc_vector2_mean_of_three_fp64(const BgcVector2FP64* vector1, const
|
|||
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP64;
|
||||
}
|
||||
|
||||
// ================== Minimal =================== //
|
||||
|
||||
inline void bgc_vector2_minimize_fp32(const BgcVector2FP32* vector, BgcVector2FP32* minimal)
|
||||
{
|
||||
if (vector->x1 < minimal->x1) {
|
||||
minimal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 < minimal->x2) {
|
||||
minimal->x2 = vector->x2;
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_vector2_minimize_fp64(const BgcVector2FP64* vector, BgcVector2FP64* minimal)
|
||||
{
|
||||
if (vector->x1 < minimal->x1) {
|
||||
minimal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 < minimal->x2) {
|
||||
minimal->x2 = vector->x2;
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Maximal =================== //
|
||||
|
||||
inline void bgc_vector2_maximize_fp32(const BgcVector2FP32* vector, BgcVector2FP32* maximal)
|
||||
{
|
||||
if (vector->x1 > maximal->x1) {
|
||||
maximal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 > maximal->x2) {
|
||||
maximal->x2 = vector->x2;
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_vector2_maximize_fp64(const BgcVector2FP64* vector, BgcVector2FP64* maximal)
|
||||
{
|
||||
if (vector->x1 > maximal->x1) {
|
||||
maximal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 > maximal->x2) {
|
||||
maximal->x2 = vector->x2;
|
||||
}
|
||||
}
|
||||
|
||||
// =============== Scalar Product =============== //
|
||||
|
||||
inline float bgc_vector2_scalar_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2)
|
||||
|
|
|
@ -63,6 +63,12 @@ extern inline void bgc_vector3_mean_of_two_fp64(const BgcVector3FP64* vector1, c
|
|||
extern inline void bgc_vector3_mean_of_three_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* result);
|
||||
extern inline void bgc_vector3_mean_of_three_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* result);
|
||||
|
||||
extern inline void bgc_vector3_minimize_fp32(const BgcVector3FP32* vector, BgcVector3FP32* minimal);
|
||||
extern inline void bgc_vector3_minimize_fp64(const BgcVector3FP64* vector, BgcVector3FP64* minimal);
|
||||
|
||||
extern inline void bgc_vector3_maximize_fp32(const BgcVector3FP32* vector, BgcVector3FP32* maximal);
|
||||
extern inline void bgc_vector3_maximize_fp64(const BgcVector3FP64* vector, BgcVector3FP64* maximal);
|
||||
|
||||
extern inline float bgc_vector3_scalar_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2);
|
||||
extern inline double bgc_vector3_scalar_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2);
|
||||
|
||||
|
|
|
@ -378,6 +378,70 @@ inline void bgc_vector3_mean_of_three_fp64(const BgcVector3FP64* vector1, const
|
|||
result->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP64;
|
||||
}
|
||||
|
||||
// ================== Minimal =================== //
|
||||
|
||||
inline void bgc_vector3_minimize_fp32(const BgcVector3FP32* vector, BgcVector3FP32* minimal)
|
||||
{
|
||||
if (vector->x1 < minimal->x1) {
|
||||
minimal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 < minimal->x2) {
|
||||
minimal->x2 = vector->x2;
|
||||
}
|
||||
|
||||
if (vector->x3 < minimal->x3) {
|
||||
minimal->x3 = vector->x3;
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_vector3_minimize_fp64(const BgcVector3FP64* vector, BgcVector3FP64* minimal)
|
||||
{
|
||||
if (vector->x1 < minimal->x1) {
|
||||
minimal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 < minimal->x2) {
|
||||
minimal->x2 = vector->x2;
|
||||
}
|
||||
|
||||
if (vector->x3 < minimal->x3) {
|
||||
minimal->x3 = vector->x3;
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Maximal =================== //
|
||||
|
||||
inline void bgc_vector3_maximize_fp32(const BgcVector3FP32* vector, BgcVector3FP32* maximal)
|
||||
{
|
||||
if (vector->x1 > maximal->x1) {
|
||||
maximal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 > maximal->x2) {
|
||||
maximal->x2 = vector->x2;
|
||||
}
|
||||
|
||||
if (vector->x3 > minimal->x3) {
|
||||
minimal->x3 = vector->x3;
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_vector3_maximize_fp64(const BgcVector3FP64* vector, BgcVector3FP64* maximal)
|
||||
{
|
||||
if (vector->x1 > maximal->x1) {
|
||||
maximal->x1 = vector->x1;
|
||||
}
|
||||
|
||||
if (vector->x2 > maximal->x2) {
|
||||
maximal->x2 = vector->x2;
|
||||
}
|
||||
|
||||
if (vector->x3 > minimal->x3) {
|
||||
minimal->x3 = vector->x3;
|
||||
}
|
||||
}
|
||||
|
||||
// =============== Scalar Product =============== //
|
||||
|
||||
inline float bgc_vector3_scalar_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue