Tensor

QSharp

The Tensor Command

The TENSOR command in Quantum Console performs a tensor operation. Syntax for this operation is in the following format:

TENSOR({Matrix A}, {Matrix B}, ... , {Matrix N});

Throughout this documentation, the tensor operator is written as:

{Matrix A} (x) {Matrix B}

Results of the TENSOR operation are calculated and returned for inspection. This can be useful for checking manual tensor calculations.

* Note that this command has been limited (in the web version) to a maximum of 5 terms in order to avoid memory pressure.

Example 1

//	Quantum Console command
TENSOR(X, I);

//	Output
{
{0, 0, 1, 0}
{0, 0, 0, 1}
{1, 0, 0, 0}
{0, 1, 0, 0}
}

Example 2

//	Quantum Console command
TENSOR(I, Y, I);

//	Output
{
{0, 0,-i, 0, 0, 0, 0, 0}
{0, 0, 0,-i, 0, 0, 0, 0}
{i, 0, 0, 0, 0, 0, 0, 0}
{0, i, 0, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0,-i, 0}
{0, 0, 0, 0, 0, 0, 0,-i}
{0, 0, 0, 0, i, 0, 0, 0}
{0, 0, 0, 0, 0, i, 0, 0}
}

Example 3

//	Quantum Console command
TENSOR(CNOT, X);

//	Output
{
{0, 1, 0, 0, 0, 0, 0, 0}
{1, 0, 0, 0, 0, 0, 0, 0}
{0, 0, 0, 1, 0, 0, 0, 0}
{0, 0, 1, 0, 0, 0, 0, 0}
{0, 0, 0, 0, 0, 0, 0, 1}
{0, 0, 0, 0, 0, 0, 1, 0}
{0, 0, 0, 0, 0, 1, 0, 0}
{0, 0, 0, 0, 1, 0, 0, 0}
}

 

Copyright © 2024 carlbelle.com