How can I find the partial transpose for three qubit density matrix usign mathematica? - wolfram-mathematica

I know that the density matrix of a three-qubit is an 8x8 matrix. How can I use Mathematica to find the partial transpose of this 8x8 matrix with respect to the first, second, or the third qubit?

Related

How to get thin QR decomposition in Julia?

When I perform QR decomposition on a 3x2 matrix A in Julia, it gives a 3x3 matrix Q. Is there any way I can get a "thin" version of this QR, where it returns a Q that is 3x2 (same dimensions as matrix A)? My goal is just to get an orthonormal basis for the column space of A, so I don't need a 3x3 matrix Q.
This can be achieved with Matrix(qr(A)). qr doesn't return matrices, but rather returns an object that can multiply by other matrices or easily extract the thin or full Q matrix.

Dot product of a square rotation matrix to each element of another coordinate matrix

I have a 3D matrix containing Cartesian coordinate points. In the example shown below a scaled down version of such a matrix is given (a) with dimensions 10x10x10x3. Then I have a rotation matrix R of size 3x3 and I want to make a dot product of this to each 3x1 position vector given in the matrix a, for example a[0,0,0] is the position vector for top left most coordinate point.
A simple way to do this is by using a for loop -
import numpy as np
a = np.ones([10, 10, 10, 3])
R=np.ones([3,3])
a=np.reshape(a,(1000,3))
b=np.array([np.dot(R,xyz) for xyz in a])
b=np.reshape(b, (10,10,10,3))
But this is way too slow when the matrix a becomes large. Is there a way to do a matrix multiplication type thing to speed up the computation?
I figured out a solution to my problem which speeds up the computation to more than 10 folds. But it is not a fancy matrix multiplication solution, so something that can make it even faster is always appreciated.
My current solution is the following:
X,Y,Z=a[:,:,:,0],a[:,:,:,1],a[:,:,:,2]
R00X=R[0][0]*X
R10X=R[1][0]*X
R20X=R[2][0]*X
R01Y=R[0][1]*Y
R11Y=R[1][1]*Y
R21Y=R[2][1]*Y
R02Z=R[0][2]*Z
R12Z=R[1][2]*Z
R22Z=R[2][2]*Z
#Rotated Field
Xr=R00X+R01Y+R02Z
Yr=R10X+R11Y+R12Z
Zr=R20X+R21Y+R22Z
b=np.array([Xr,Yr,Zr]).T

Can 2d convolution been represented as matrix multiplication?

Discr. convolution can be represented as multiplication of input with matrix M.
Where M is presented a special case of Toeplitz matrices - circulant matrices.
The questions is: is 2d convolution can also be represented as matrix multiplication?
p.s. By dicr. convolution I mean dicr. convolution with indexing discrete samples in modulus fashion, i.e. the discrete signal is repeating
....X[n-1]x[0]x[1]...x[N-1]x[0]...
Yes, it can, but it will generally be a rather big matrix. If your data set is on a grid of size NxM, then the convolution is a matrix operating on a vector of length N*M; the convolution matrix has N2M2 elements.
If your convolution kernel is small, then the matrix will typically a band matrix where the width of the band is at least N or M.

Finding Matrix inverse using SIMPLEX Method

How can we find inverse of a matrix using Simplex method? Do we need to have square matrix only or inverse can be found of any matrix? Also specify about the upper bound on the matrix size?
The Matrix Inverse is required during simplex only over the Basis Matrix (Basis Inversion).
Base matrix is a square matrix of dimensions (mxm) where m is the total number of constraints.
This Matrix Inversion is carried out using either the Product form of Inverse or LU Decomposition.

Calculate covariance of two images in matlab

I am doing a project on image quality assessment. I converted the image to grayscale & divided the entire image into 8x8 matrices using mat2cell function. I did this for two images, and now I want to calculate covariance between these two images (i.e the covariance between the matrix of image 1 and covariance between the same matrix of image 2). Note that both are the same images: one a pure image without distortions and one with distortions.
First convert your image to matrix:
I = double(imread('photo.jpg'));
then calculate covariance:
x=cov(I);
For single matrix input, C has size [size(A,2) size(A,2)] based on the number of random variables (columns) represented by A. The variances of the columns are along the diagonal. If A is a row or column vector, C is the scalar-valued variance.
For two-vector or two-matrix input, C is the 2-by-2 covariance matrix between the two random variables. The variances are along the diagonal of C.

Resources