MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / cpu_allocAndInitMatrixWrapper

Function cpu_allocAndInitMatrixWrapper

quest/src/cpu/cpu_config.cpp:294–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292
293
294qcomp** cpu_allocAndInitMatrixWrapper(qcomp* arr, qindex dim) {
295
296 // do not allocate if arr alloc failed (caller will handle)
297 if (arr == nullptr)
298 return nullptr;
299
300 // allocate only the outer memory (i.e. one row's worth)
301 qcomp** out = (qcomp**) malloc(dim * sizeof *out);
302
303 // caller will handle malloc failure
304 if (out == nullptr)
305 return out;
306
307 // populate out with offsets of arr
308 for (qindex i=0; i<dim; i++)
309 out[i] = &arr[i*dim];
310
311 return out; // may be nullptr
312}
313
314
315void cpu_deallocMatrixWrapper(qcomp** wrapper) {

Callers 2

allocSuperOpFunction · 0.85
createCompMatrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected