# OperatorSchmidtRank

 Other toolboxes required OperatorSchmidtRank Computes the operator Schmidt rank of a bipartite operator none OperatorSchmidtDecompositionSchmidtRank Entanglement and separability

OperatorSchmidtRank is a function that computes the operator Schmidt rank of a bipartite operator. If the operator is full, the operator Schmidt rank is computed using MATLAB's rank function. If the operator is sparse, the operator Schmidt rank is computed using the QR decomposition.

## Syntax

• RNK = OperatorSchmidtRank(X)
• RNK = OperatorSchmidtRank(X,DIM)

## Argument descriptions

• X: A bipartite operator to have its operator Schmidt rank computed.
• DIM (optional, by default has both subsystems of equal dimension): A specification of the dimensions of the subsystems that X lives on. DIM can be provided in one of three ways:
• If DIM is a scalar, it is assumed that the first subsystem has dimension DIM and the second subsystem has dimension length(X)/DIM.
• If $X \in M_{n_1} \otimes M_{n_2}$ then DIM should be a row vector containing the dimensions (i.e., DIM = [n_1, n_2]).
• If the subsystems aren't square (i.e., $X \in M_{m_1, n_1} \otimes M_{m_2, n_2}$) then DIM should be a matrix with two rows. The first row of DIM should contain the row dimensions of the subsystems (i.e., the mi's) and its second row should contain the column dimensions (i.e., the ni's). In other words, you should set DIM = [m_1, m_2; n_1, n_2].

## Examples

### A random example

A random unitary will almost surely have full operator Schmidt rank:

>> OperatorSchmidtRank(RandomUnitary(4))

ans =

4

## Source code

Click on "expand" to the right to view the MATLAB source code for this function.

1. %%  OPERATORSCHMIDTRANK    Computes the operator Schmidt rank of a bipartite operator
2. %   This function has one required argument:
3. %     X: a bipartite operator
4. %
5. %   RNK = OperatorSchmidtRank(X) is the operator Schmidt rank of X, which
6. %   is assumed to live in bipartite space, where both subsystems have
7. %   dimension equal to sqrt(length(X)).
8. %
9. %   This function has one optional argument:
10. %     DIM (default has two subsystems of equal dimension)
11. %
12. %   RNK = OperatorSchmidtRank(X,DIM) is the operator Schmidt rank of X,
13. %   where the two subsystems it lives on have dimensions specified by the
14. %   1-by-2 vector DIM.
15. %
16. %   URL: http://www.qetlab.com/OperatorSchmidtRank
17. 
18. %   requires: opt_args.m, PermuteSystems.m, SchmidtRank.m, sporth.m, Swap.m
19. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
20. %   package: QETLAB
21. %   last updated: November 12, 2014
22. 
23. function rnk = OperatorSchmidtRank(X,varargin)
24. 
25. dX = size(X);
26. sdX = round(sqrt(dX));
27. 
28. % set optional argument defaults: dim=sqrt(length(X))
29. [dim] = opt_args({ [sdX(1) sdX(1);sdX(2) sdX(2)] },varargin{:});
30. 
31. % allow the user to enter a single number for dim
32. if(length(dim) == 1)
33.     dim = [dim,dX(1)/dim];
34.     if abs(dim(2) - round(dim(2))) >= 2*dX(1)*eps
35.         error('OperatorSchmidtRank:InvalidDim','If DIM is a scalar, X must be square and DIM must evenly divide length(X); please provide the DIM array containing the dimensions of the subsystems.');
36.     end
37.     dim(2) = round(dim(2));
38. end
39. 
40. % allow the user to enter a vector for dim if X is square
41. if(min(size(dim)) == 1)
42.     dim = dim(:)'; % force dim to be a row vector
43.     dim = [dim;dim];
44. end
45. 
46. % The operator Schmidt rank is just the Schmidt rank of a related vector
47. % obtained by moving matrix elements around.
48. rnk = SchmidtRank(Swap(reshape(X,prod(prod(dim)),1),[2,3],[dim(2,:),dim(1,:)]),prod(dim));