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

Functions for overwriting the elements of channels. More...

Functions

void setInlineKrausMap (KrausMap map, int numQb, int numOps, {{{ matrices }}})
 
void setInlineSuperOp (SuperOp op, int numQb, {{ matrix }})
 
void setKrausMap (KrausMap map, qcomp ***matrices)
 
void setKrausMap (KrausMap map, qcomp matrices[map.numMatrices][map.numRows][map.numRows])
 
void setSuperOp (SuperOp op, qcomp **matrix)
 
void setSuperOp (SuperOp op, qcomp matrix[op.numRows][op.numRows])
 

Detailed Description

Functions for overwriting the elements of channels.

Function Documentation

◆ setInlineKrausMap()

void setInlineKrausMap ( KrausMap map,
int numQb,
int numOps,
{{{ matrices }}}  )

Overwrites the Kraus operators of map from an inline literal.

The {{{matrices}}} argument is a 3D array literal, of dimensions numOps by 1<<numQb by 1<<numQb.

  • In C, this is a macro, where numQb and numOps must be compile-time literals, and turn {{{matrices}}} into a compound literal.
  • In C++, this is a function which accepts {{{matrices}}} as a nested std::vector literal.
Example
setInlineKrausMap(map, 1, 3, {
{{1,2},{3,4}},
{{5,5},{6,6}},
{{1i,2i},{-3i,-4i}}
});
KrausMap createKrausMap(int numQubits, int numOperators)
Definition channels.cpp:176
Parameters
[in,out]mapthe KrausMap to overwrite.
[in]numQbthe number of qubits of the literal {{{matrices}}}.
[in]numOpsthe number of Kraus operators of the literal {{{matrices}}}.
Exceptions
error
  • if map is uninitialised.
  • if numQb differs from the number of qubits in map.
  • if numOps differs from the number of operators in map.
See also
Author
Tyson Jones

◆ setInlineSuperOp()

void setInlineSuperOp ( SuperOp op,
int numQb,
{{ matrix }}  )

Overwrites the elements of op from an inline literal.

The {{matrix}} argument is a 2D array literal, of dimensions 1<<(2*numQb) by 1<<(2*numQb).

  • In C, this is a macro, where numQb must be a compile-time literal, amd turns {{matrix}} into a compound literal.
  • In C++, this is a function which accepts {{matrix}} as a nested std::vector literal.
Example
setInlineSuperOp(a, 1, {
{1,2,3,4},
{5,3.14i,7,8},
{9,10,11,12},
{13,14,15,16+1.23i}
});
SuperOp createSuperOp(int numQubits)
Definition channels.cpp:162
Parameters
[in,out]opthe SuperOp to overwrite.
[in]numQbthe number of qubits of the {{matrix}} literal.
Exceptions
error
  • if op is uninitialised.
  • if numQb does not match the number of qubits in op.
See also
Author
Tyson Jones

◆ setKrausMap() [1/2]

void setKrausMap ( KrausMap map,
qcomp *** matrices )

Overwrites the Kraus operators of map.

Argument matrices must be a list of KrausMap::numMatrices matrices, each of dimension KrausMap::numRows by KrausMap::numRows.

This updates KrausMap::matrices and other internal properties.

Parameters
[in,out]mapthe KrausMap to overwrite.
[in]matricesa 3D nested list of the above dimensions.
Exceptions
error
  • if map is uninitialised.
seg-fault
  • if matrices is not of the expected dimensions.
See also
Author
Tyson Jones

Definition at line 309 of file channels.cpp.

309 {
310 validate_krausMapFields(map, __func__);
311
312 setAndSyncKrausMapElems(map, matrices);
313}

Referenced by TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ setKrausMap() [2/2]

void setKrausMap ( KrausMap map,
qcomp matrices[map.numMatrices][map.numRows][map.numRows] )

Overwrites the Kraus operators of map from a C array.

Note
This entity is actually a macro.
Remarks
This function is only available in C.

This is a C convenience macro equivalent to setKrausMap().

Example
qcomp arr[2][4][4] = {
{
{1,2,3,4},
{5,6,7,8},
{9,8,7,6},
{5,4,3,2},
}, {
{1i,2i,3i},
{5i}
}
};
setKrausMap(map, arr);
void setKrausMap(KrausMap map, qcomp ***matrices)
Definition channels.cpp:309
Parameters
[in,out]mapthe KrausMap to overwrite.
[in]matricesa 3D array.
Exceptions
error
  • if map is uninitialised.
See also
Author
Tyson Jones

◆ setSuperOp() [1/2]

void setSuperOp ( SuperOp op,
qcomp ** matrix )

Overwrites the elements of op.

This copies matrix into SuperOp::cpuElems and synchronises op to GPU memory when relevant.

Parameters
[in,out]opthe SuperOp to overwrite.
[in]matrixa SuperOp::numRows by SuperOp::numRows matrix of new elements.
Exceptions
error
  • if op is uninitialised.
  • if matrix is a null or invalid pointer.
See also
Author
Tyson Jones

Definition at line 271 of file channels.cpp.

271 {
272 validate_superOpFields(op, __func__);
273 validate_matrixNewElemsPtrNotNull(matrix, op.numRows, __func__); // fine for superop
274
275 setAndSyncSuperOpElems(op, matrix);
276}
qindex numRows
Definition channels.h:119

Referenced by TEST_CASE(), and TEST_CASE().

◆ setSuperOp() [2/2]

void setSuperOp ( SuperOp op,
qcomp matrix[op.numRows][op.numRows] )

Overwrites the elements of op from a C array.

Note
This entity is actually a macro.
Remarks
This function is only available in C.

This is a C convenience macro equivalent to setSuperOp().

Example
qcomp arr[4][4] = {
{1,2,3,4},
{5,6,7,8},
{9,8,7,6},
{5,4,3,2}
};
setSuperOp(a, arr);
void setSuperOp(SuperOp op, qcomp **matrix)
Definition channels.cpp:271
Parameters
[in,out]opthe SuperOp to overwrite.
[in]matrixa SuperOp::numRows by SuperOp::numRows array.
Exceptions
error
  • if op is uninitialised.
See also
Author
Tyson Jones