The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches

Functions for calculating reduced density matrices, creating a new output Qureg. More...

Functions

Qureg calcPartialTrace (Qureg qureg, int *traceOutQubits, int numTraceQubits)
 
Qureg calcReducedDensityMatrix (Qureg qureg, int *retainQubits, int numRetainQubits)
 

Detailed Description

Functions for calculating reduced density matrices, creating a new output Qureg.

Function Documentation

◆ calcPartialTrace()

Qureg calcPartialTrace ( Qureg qureg,
int * traceOutQubits,
int numTraceQubits )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 368 of file calculations.cpp.

368 {
369 validate_quregFields(qureg, __func__);
370 validate_quregIsDensityMatrix(qureg, __func__);
371 validate_targets(qureg, traceOutQubits, numTraceQubits, __func__);
372 validate_quregCanBeReduced(qureg, numTraceQubits, __func__);
373
374 // attempt to create reduced Qureg with same deployments as input Qureg
375 Qureg out = validateAndCreateCustomQureg(
376 qureg.numQubits - numTraceQubits,
377 qureg.isDensityMatrix, qureg.isDistributed,
378 qureg.isGpuAccelerated, qureg.isMultithreaded, __func__);
379
380 // set it to reduced density matrix
381 auto targets = util_getVector(traceOutQubits, numTraceQubits);
382 localiser_densmatr_partialTrace(qureg, out, targets);
383
384 return out;
385}
Definition qureg.h:42

Referenced by calcReducedDensityMatrix(), and TEST_CASE().

◆ calcReducedDensityMatrix()

Qureg calcReducedDensityMatrix ( Qureg qureg,
int * retainQubits,
int numRetainQubits )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 388 of file calculations.cpp.

388 {
389 validate_quregFields(qureg, __func__);
390 validate_quregIsDensityMatrix(qureg, __func__);
391 validate_targets(qureg, retainQubits, numRetainQubits, __func__);
392 validate_quregCanBeReduced(qureg, qureg.numQubits - numRetainQubits, __func__);
393
394 auto traceQubits = util_getNonTargetedQubits(retainQubits, numRetainQubits, qureg.numQubits);
395
396 // harmlessly re-validates
397 return calcPartialTrace(qureg, traceQubits.data(), traceQubits.size());
398}
Qureg calcPartialTrace(Qureg qureg, int *traceOutQubits, int numTraceQubits)

Referenced by TEST_CASE().