MCPcopy Create free account
hub / github.com/boostorg/compute / generate_matrix

Function generate_matrix

example/matrix_transpose.cpp:197–212  ·  view source on GitHub ↗

generate a matrix inside 'in' and do the tranposition inside 'out'

Source from the content-addressed store, hash-verified

195
196// generate a matrix inside 'in' and do the tranposition inside 'out'
197void generate_matrix(std::vector<float>& in, std::vector<float>& out, uint_ rows, uint_ cols)
198{
199 // generate a matrix
200 for(uint_ i = 0 ; i < rows ; ++i){
201 for(uint_ j = 0 ; j < cols ; ++j){
202 in[i*cols + j] = i*cols + j;
203 }
204 }
205
206 // store transposed result
207 for(uint_ j = 0; j < cols ; ++j){
208 for(uint_ i = 0 ; i < rows ; ++i){
209 out[j*rows + i] = in[i*cols + j];
210 }
211 }
212}
213
214// neccessary for 64-bit integer on win32
215#ifdef _WIN32

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected