# Complex Algebra¶

qucumber.utils.cplx.absolute_value(x)[source]

Computes the complex absolute value elementwise.

Parameters: x (torch.Tensor) – A complex tensor. A real tensor. torch.Tensor
qucumber.utils.cplx.conjugate(x)[source]

A function that takes the conjugate transpose of the argument.

Parameters: x (torch.Tensor) – A complex vector or matrix. The conjugate of x. torch.Tensor
qucumber.utils.cplx.elementwise_division(x, y)[source]

Elementwise division of x by y.

Parameters: x (torch.Tensor) – A complex tensor. y (torch.Tensor) – A complex tensor. torch.Tensor
qucumber.utils.cplx.elementwise_mult(x, y)[source]

Alias for scalar_mult().

qucumber.utils.cplx.inner_prod(x, y)[source]

A function that returns the inner product of two complex vectors, x and y (<x|y>).

Parameters: x (torch.Tensor) – A complex vector. y (torch.Tensor) – A complex vector. ValueError – If x and y are not complex vectors with their first dimensions being 2, then the function will not execute. The inner product, . torch.Tensor
qucumber.utils.cplx.kronecker_prod(x, y)[source]

A function that returns the tensor / kronecker product of 2 complex tensors, x and y.

Parameters: x (torch.Tensor) – A complex matrix. y (torch.Tensor) – A complex matrix. ValueError – If x and y do not have 3 dimensions or their first dimension is not 2, the function cannot execute. The tensorproduct of x and y, . torch.Tensor
qucumber.utils.cplx.make_complex(x, y=None)[source]

A function that combines the real (x) and imaginary (y) parts of a vector or a matrix.

Note

x and y must have the same shape. Also, this will not work for rank zero tensors.

Parameters: x (torch.Tensor) – The real part y (torch.Tensor) – The imaginary part. Can be None, in which case, the resulting complex tensor will have imaginary part equal to zero. The tensor [x,y] = x + yi. torch.Tensor
qucumber.utils.cplx.matmul(x, y)[source]

A function that computes complex matrix-matrix and matrix-vector products.

Note

If one wishes to do matrix-vector products, the vector must be the second argument (y).

Parameters: x (torch.Tensor) – A complex matrix. y (torch.Tensor) – A complex vector or matrix. The product between x and y. torch.Tensor
qucumber.utils.cplx.norm(x)[source]

A function that returns the norm of the argument.

Parameters: x (torch.Tensor) – A complex scalar. . torch.Tensor
qucumber.utils.cplx.norm_sqr(x)[source]

A function that returns the squared norm of the argument.

Parameters: x (torch.Tensor) – A complex scalar. . torch.Tensor
qucumber.utils.cplx.outer_prod(x, y)[source]

A function that returns the outer product of two complex vectors, x and y.

Parameters: x (torch.Tensor) – A complex vector. y (torch.Tensor) – A complex vector. ValueError – If x and y are not complex vectors with their first dimensions being 2, then the function will not execute. The outer product between x and y, . torch.Tensor
qucumber.utils.cplx.scalar_divide(x, y)[source]

A function that computes the division of x by y.

Parameters: x (torch.Tensor) – The numerator (a complex scalar, vector or matrix). y (torch.Tensor) – The denominator (a complex scalar). x / y torch.Tensor
qucumber.utils.cplx.scalar_mult(x, y, out=None)[source]

A function that computes the product between complex matrices and scalars, complex vectors and scalars or two complex scalars.

Parameters: x (torch.Tensor) – A complex scalar, vector or matrix. y (torch.Tensor) – A complex scalar, vector or matrix. z (torch.Tensor) – The complex tensor to write the output to. z – A complex scalar, vector or matrix. Can be None, in which case, a new tensor is created and returned. Otherwise, the method overwrites z. The product between x and y. Either overwrites z, or returns a new tensor. torch.Tensor