SchmidtRank

From QETLAB
Jump to: navigation, search
SchmidtRank
Computes the Schmidt rank of a bipartite vector

Other toolboxes required none
Related functions OperatorSchmidtRank
SchmidtDecomposition
Function category Entanglement and separability

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

Syntax

  • RNK = SchmidtRank(VEC)
  • RNK = SchmidtRank(VEC,DIM)
  • RNK = SchmidtRank(VEC,DIM,TOL)

Argument descriptions

  • VEC: A bipartite vector (e.g., a pure quantum state) to have its Schmidt rank computed.
  • DIM (optional, by default has both subsystems of equal dimension): A 1-by-2 vector containing the dimensions of the subsystems that VEC lives on.
  • TOL (optional, default sqrt(length(VEC))*eps(norm(VEC))): The numerical tolerance used when determining if a Schmidt coefficient equals zero or not.

Examples

The following code computes a random state vector in $\mathbb{C}^4 \otimes \mathbb{C}^6$ with Schmidt rank three, and then verifies that its Schmidt rank is indeed 3:

>> SchmidtRank(RandomStateVector([4,6],0,3),[4,6])
 
ans =
 
     3

Source code

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

  1. %%  SCHMIDTRANK    Computes the Schmidt rank of a bipartite vector
  2. %   This function has one required argument:
  3. %     VEC: a bipartite vector to have its Schmidt rank computed
  4. %
  5. %   RNK = SchmidtRank(VEC) is the Schmidt rank of the vector VEC, assumed
  6. %   to live in bipartite space, where both subsystems have dimension equal
  7. %   to sqrt(length(VEC)).
  8. %
  9. %   This function has two optional arguments:
  10. %     DIM (default [sqrt(length(VEC)),sqrt(length(VEC))])
  11. %     TOL (default sqrt(length(VEC))*eps(norm(VEC)))
  12. %
  13. %   RNK = SchmidtRank(VEC,DIM,TOL) is the Schmidt rank of the bipartite
  14. %   vector VEC, where the two subsystems it lives on have dimensions
  15. %   specified by the 1-by-2 vector DIM and the rank is determined as the
  16. %   number of Schmidt coefficients larger than TOL.
  17. %
  18. %   URL: http://www.qetlab.com/SchmidtRank
  19.  
  20. %   requires: opt_args.m, sporth.m
  21. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
  22. %   package: QETLAB
  23. %   last updated: December 19, 2012
  24.  
  25. function rnk = SchmidtRank(vec,varargin)
  26.  
  27. lv = length(vec);
  28. slv = round(sqrt(lv));
  29.  
  30. % set optional argument defaults: dim=sqrt(length(vec))
  31. [dim,tol] = opt_args({ slv, slv*eps(norm(vec)) },varargin{:});
  32.  
  33. % allow the user to enter a single number for dim
  34. if(length(dim) == 1)
  35.     dim = [dim,lv/dim];
  36.     if abs(dim(2) - round(dim(2))) >= 2*lv*eps
  37.         error('SchmidtRank:InvalidDim','The value of DIM must evenly divide length(VEC); please provide a DIM array containing the dimensions of the subsystems.');
  38.     end
  39.     dim(2) = round(dim(2));
  40. end
  41.  
  42. % compute the Schmidt rank
  43. if(issparse(vec))
  44.     [~,rnk] = sporth(reshape(vec,dim(end:-1:1)),tol);
  45. else
  46.     rnk = rank(reshape(vec,dim(end:-1:1)),tol);
  47. end