IsProductVector

From QETLAB
Jump to: navigation, search
IsProductVector
Determines if a pure state is a product vector

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

IsProductVector is a function that determines if a bipartite or multipartite vector (e.g., a pure quantum state) is a product vector or not. If it is a product vector, its tensor decomposition can be provided.

Syntax

  • IPV = IsProductVector(VEC)
  • IPV = IsProductVector(VEC,DIM)
  • [IPV,DEC] = IsProductVector(VEC,DIM)

Argument descriptions

Input arguments

  • VEC: A vector that lives in a bipartite or multipartite Hilbert space.
  • DIM (optional, by default has two subsystems of equal dimension): A specification of the dimensions of the subsystems that VEC lives in. DIM can be provided in one of two ways:
    • If DIM is a scalar, it is assumed that VEC lives in the tensor product of two subsystems, the first of which has dimension DIM and the second of which has dimension length(VEC)/DIM.
    • If $VEC \in \mathbb{C}^{n_1} \otimes \cdots \otimes \mathbb{C}^{n_p}$ then DIM should be a vector containing the dimensions of the subsystems (i.e., DIM = [n_1, ..., n_p]).

Output arguments

  • IPV: Either 1 or 0, indicating that VEC is or is not a product vector.
  • DEC (optional): If IPV = 1 (i.e., VEC is a product vector), then DEC is a cell containing two or more vectors, the tensor product of which is VEC. If IPV = 0 then DEC is meaningless.

Examples

A random example

A randomly-generated pure state will almost surely not be a product vector. The following code demonstrates this for a random pure state chosen from $\mathbb{C}^2 \otimes \mathbb{C}^3 \otimes \mathbb{C}^5$:

>> v = RandomStateVector(30);
>> IsProductVector(v,[2,3,5])
 
ans =
 
     0

A product state's decomposition

The following code determines that a certain pure state living in $\mathbb{C}^2 \otimes \mathbb{C}^2 \otimes \mathbb{C}^2$ is a product state, and provides a decomposition of that product state. It is then verified that the tensor product of the vectors in that decomposition do indeed give the original state.

>> v = [1 0 0 0 1 0 0 0]/sqrt(2);
>> [ipv,dec] = IsProductVector(v,[2,2,2])
 
ipv =
 
     1
 
dec = 
 
    [2x1 double]    [2x1 double]    [2x1 double]
 
>> celldisp(dec) % display the contents of dec
 
dec{1} =
 
    0.7071
    0.7071
 
dec{2} =
 
    1.0000
         0
 
dec{3} =
 
     1
     0
 
>> Tensor(dec)
 
ans =
 
    0.7071
         0
         0
         0
    0.7071
         0
         0
         0

Source code

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

  1. %%  ISPRODUCTVECTOR   Determines if a pure state is a product vector
  2. %   This function has one required argument:
  3. %     VEC: a vector living in the tensor product of two or more subsystems
  4. %
  5. %   IPV = IsProductVector(VEC) is either 1 or 0, indicating that VEC is or
  6. %   is not a product state (note that VEC is assumed to be bipartite unless
  7. %   the optional argument DIM (see below) is specified).
  8. %
  9. %   This function has one optional input argument:
  10. %     DIM (default has two subsystems of equal dimension)
  11. %
  12. %   [IPV,DEC] = IsProductVector(VEC,DIM) indicates that VEC is or is not a
  13. %   product state, as above. DIM is a vector containing the dimensions of
  14. %   the subsystems that VEC lives on. If IPV = 1 then DEC is a product
  15. %   decomposition of VEC. More specifically, DEC is a cell containing
  16. %   vectors whose tensor product equals VEC.
  17. %
  18. %   URL: http://www.qetlab.com/IsProductVector
  19.  
  20. %   requires: opt_args.m, SchmidtDecomposition.m
  21. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
  22. %   package: QETLAB
  23. %   last updated: November 26, 2012
  24.  
  25. function [ipv,dec] = IsProductVector(vec,varargin)
  26.  
  27. lv = length(vec);
  28.  
  29. % set optional argument defaults: dim=sqrt(length(vec))
  30. [dim] = opt_args({ round(sqrt(lv)) },varargin{:});
  31.  
  32. % allow the user to enter a single number for dim
  33. num_sys = length(dim);
  34. if(num_sys == 1)
  35.     dim = [dim,lv/dim];
  36.     if abs(dim(2) - round(dim(2))) >= 2*lv*eps
  37.         error('IsProductVector: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.     num_sys = 2;
  41. end
  42.  
  43. % if there are only two subsystems, just use the Schmidt decomposition
  44. if(num_sys == 2)
  45.     [s,u,v] = SchmidtDecomposition(vec,dim,2);
  46.     ipv = (s(2) <= prod(dim) * eps(s(1)));
  47.     if(ipv) % provide this even if not requested, since it is needed if this function was called as part of its recursive algorithm (see below)
  48.         u = u*sqrt(s(1));
  49.         v = v*sqrt(s(1));
  50.         dec = {u(:,1) v(:,1)};
  51.     end
  52.  
  53. % if there are more subsystems, recursively use the Schmidt decomposition across many cuts until we are sure
  54. else
  55.     [ipv,dec] = IsProductVector(vec,[dim(1)*dim(2),dim(3:end)]);
  56.     if(ipv)
  57.         [ipv,tdec] = IsProductVector(dec{1},[dim(1),dim(2)]);
  58.         if(ipv)
  59.             dec = [tdec dec{2:end}];
  60.         end
  61.     end
  62. end
  63.  
  64. if(~ipv)
  65.     dec = 0;
  66. end