3.2.1.1.2 : Le fichier source

Écrivons le fichier hadamard_product_base.cpp :



Nous commençons par inclure notre header :

1
#include "hadamard_product_base.h"


Et nous ajoutons notre fonction qui calcule un produit de hadamard :

1
2
3
4
5
6
7
8
9
10
11
///Do the Hadamard product
/**	@param[out] tabResult : table of results of tabX*tabY
 * 	@param tabX : input table
 * 	@param tabY : input table
 * 	@param nbElement : number of elements in the tables
*/
void hadamard_product_base(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){
	for(size_t i(0lu); i < nbElement; ++i){
		tabResult[i] = tabX[i]*tabY[i];
	}
}


Le fichier hadamard_product_base.cpp complet :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/
#include "hadamard_product_base.h"
///Do the Hadamard product
/**	@param[out] tabResult : table of results of tabX*tabY
 * 	@param tabX : input table
 * 	@param tabY : input table
 * 	@param nbElement : number of elements in the tables
*/
void hadamard_product_base(float* tabResult, const float* tabX, const float* tabY, size_t nbElement){
	for(size_t i(0lu); i < nbElement; ++i){
		tabResult[i] = tabX[i]*tabY[i];
	}
}


Vous pouvez le télécharger ici.