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

Function cpu_allocMatrix

quest/src/cpu/cpu_config.cpp:325–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323
324
325qcomp** cpu_allocMatrix(qindex dim) {
326
327 // NOTE:
328 // this function creates a matrix where rows are not necessarily
329 // contiguous in memory, which can incur gratuitous caching penalties
330 // when accessed in hot loops. As such, we do not use this function
331 // to allocate memory for CompMatr (instead, cpu_allocAndInitMatrixWrapper()),
332 // but instead use it for the individual Kraus matrices of a KrausMap,
333 // which are each quadratically smaller than the important superoperator.
334
335 // allocate outer array
336 qcomp** rows = (qcomp**) malloc(dim * sizeof *rows); // nullptr if failed
337
338 // if that did not fail, allocate each inner array
339 if (rows != nullptr)
340 for (qindex r=0; r<dim; r++)
341 rows[r] = cpu_allocArray(dim); // nullptr if failed
342
343 // caller will validate whether mallocs were successful
344 return rows;
345}
346
347
348void cpu_deallocMatrix(qcomp** matrix, qindex dim) {

Callers 1

cpu_allocMatrixListFunction · 0.85

Calls 1

cpu_allocArrayFunction · 0.85

Tested by

no test coverage detected