/*************************************** Auteur : Pierre Aubert Mail : aubertp7@gmail.com Licence : CeCILL-C ****************************************/ #include using namespace std; ///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(float* tabResult, const float* tabX, const float* tabY, long unsigned int nbElement){ for(long unsigned int i(0lu); i < nbElement; ++i){ tabResult[i] = tabX[i]*tabY[i]; } } ///Get the number of cycles per elements of the Hadamard product /** @param nbElement : number of elements of the tables */ void evaluateHadamardProduct(long unsigned int nbElement){ //Allocation of the tables float * tabResult = new float[nbElement]; float * tabX = new float[nbElement]; float * tabY = new float[nbElement]; //Initialisation of the tables for(long unsigned int i(0lu); i < nbElement; ++i){ tabX[i] = (float)(i*32lu%17lu); tabY[i] = (float)(i*57lu%31lu); } //Do the hadamard product hadamard_product(tabResult, tabX, tabY, nbElement); cout << "tabResult[0] = " << tabResult[0] << endl; } int main(int argc, char** argv){ cout << "Hadamard product" << endl; evaluateHadamardProduct(1000lu); evaluateHadamardProduct(2000lu); evaluateHadamardProduct(3000lu); evaluateHadamardProduct(5000lu); evaluateHadamardProduct(10000lu); return 0; }