Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

barycenter2d.cpp 833 Bytes
Newer Older
Pierre Aubert's avatar
Pierre Aubert committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/***************************************
	Auteur : Pierre Aubert
	Mail : aubertp7@gmail.com
	Licence : CeCILL-C
****************************************/

//some doc at : https://en.cppreference.com/w/cpp/header/algorithm
#include <algorithm>

//Some doc at : https://en.cppreference.com/w/cpp/header/execution
#include <execution>


#include "barycenter2d.h"

///Do a classical barycenter
/**	@param[out] res : result
 * 	@param tabX : talbe of x values
 * 	@param tabY : talbe of y values
 * 	@param nbElement : number of elements in the tables
*/
void barycenter2d(float & res, const float* tabX, const float* tabY, size_t nbElement){
	res = std::transform_reduce(std::execution::unseq,
					tabX, tabX + nbElement, tabY,
					0.0f, std::plus<float>(),
					[](float xi, float yi){ return xi*yi; });
	res /= (float)nbElement;
}