temporary_alloc.cpp 1.59 KB
Newer Older
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 31 32 33 34
/***************************************
	Auteur : Pierre Aubert
	Mail : aubertp7@gmail.com
	Licence : CeCILL-C
****************************************/


#include "temporary_alloc.h"

///Allocate temporary
/**	@param[out] tmpU1 : matrix temporary U
 * 	@param[out] tmpU2 : matrix temporary U
 * 	@param[out] tmpV1 : matrix temporary V
 * 	@param[out] tmpV2 : matrix temporary V
 * 	@param[out] tmpInU : Tensor temporary in U
 * 	@param[out] tmpInV : Tensor temporary in V
 * 	@param[out] tmpOutU : Tensor temporary out U
 * 	@param[out] tmpOutV : Tensor temporary out V
 * 	@param nbRow : number of rows of the matrices to be created
 * 	@param nbCol : number of columns of the matrices to be created
*/
void allocate_temporary(float *& tmpU1, float *& tmpU2, float *& tmpV1, float *& tmpV2,
			PTensor<float> & tmpInU, PTensor<float> & tmpInV, PTensor<float> & tmpOutU, PTensor<float> & tmpOutV,
			size_t nbRow, size_t nbCol)
{
	tmpInU.resize(AllocMode::ALIGNED, nbRow, nbCol);
	tmpInV.resize(AllocMode::ALIGNED, nbRow, nbCol);
	tmpOutU.resize(AllocMode::ALIGNED, nbRow, nbCol);
	tmpOutV.resize(AllocMode::ALIGNED, nbRow, nbCol);
	tmpInU.fill(1.0f);
	tmpOutU.fill(1.0f);
	tmpInV.fill(0.0f);
	tmpOutV.fill(0.0f);
	
Pierre Aubert's avatar
Pierre Aubert committed
35
	size_t frac(9lu), numBegin(4lu), numEnd(5lu), rowShift(-25lu);
36 37 38 39 40 41 42 43 44 45 46 47 48 49
	for(size_t i(rowShift + (numBegin*nbRow)/frac); i < rowShift + (numEnd*nbRow)/frac; ++i){
		for(size_t j((numBegin*nbCol)/frac); j < (numEnd*nbCol)/frac; ++j){
			tmpInU.setValue(i, j, 0.0f);
			tmpInV.setValue(i, j, 1.0f);
		}
	}
	
	tmpU1 = tmpInU.getData();
	tmpU2 = tmpOutU.getData();
	tmpV1 = tmpInV.getData();
	tmpV2 = tmpOutV.getData();
}