5.1.1.1.2 : Le fichier source

Écrivons le fichier function_base.cpp :



Nous commençons par inclure le header de la bibliothèque standard de math :

1
#include <cmath>


Ensuite nous incluons notre header :

1
#include "function_base.h"


Et nous ajoutons notre fonction qui appelle une fonction qui sera définie par COMPUTE_FUNCTION_DEF :

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


Le fichier function_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 <cmath>
#include "function_base.h"
///Do the function call
/**	@param[out] tabResult : table of results of function(tabX)
 * 	@param tabX : input table
 * 	@param nbElement : number of elements in the tables
*/
void function_base(float* tabResult, const float* tabX, size_t nbElement){
	for(size_t i(0lu); i < nbElement; ++i){
		tabResult[i] = std::COMPUTE_FUNCTION_DEF(tabX[i]);
	}
}


Vous pouvez le télécharger ici.