FunctionCenter of Gravity of an array over an explicitly given abscissa
Syntax C/C++#include <VFstd.h>
float VF_centerOfGravityV( fVector X, fVector Y, ui size );
C++ VecObj#include <OptiVec.h>
T vector<T>::centerOfGravityV( const vector<T>& X );
Pascal/Delphiuses VFstd;
function VF_centerOfGravityV( X, Y:fVector; size:UIntSize ): Single;
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_centerOfGravityV( float *h_RetVal, fVector d_X, fVector d_Y, ui siz );
int cusdVF_centerOfGravityV( float *d_RetVal, fVector d_X, fVector d_Y, ui siz );
float VFcu_centerOfGravityV( fVector h_X, fVector h_Y, ui siz );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_centerOfGravityV( var h_RetVal:Single; d_X, d_Y:fVector; size:UIntSize ): IntBool;
function cusdVF_centerOfGravityV( d_RetVal:PSingle; d_X, d_Y:fVector; size:UIntSize ): IntBool;
function VFcu_centerOfGravityV( h_X, h_Y:fVector; size:UIntSize ): Single;
DescriptionThe center of gravity of the vector Y = f(X) is calculated according to the formula:
COG = sum( Yi * Xi ) / sum( Yi ).
It is assumed that the values of Y represent point masses, situated at the positions given by X. If all elements of X are 0, there is no mass and no gravity; nevertheless, the center of gravity is assumed as the mid-point of X, i.e. (X[size-1] - X[0]) / 2.
To calculate the center of gravity of a vector over its indices as the abscissa, call VF_centerOfGravityInd.
Error handlingnone
Return valueThe (interpolated) position of the center of gravity on the X axis is returned.
See alsoVF_centerOfGravityInd

VectorLib Table of Contents  OptiVec home