Difference between revisions of "TensorSum"

From QETLAB
Jump to navigation Jump to search
m
Line 18: Line 18:
 
===Inverse of <tt>[[SchmidtDecomposition]]</tt>===
 
===Inverse of <tt>[[SchmidtDecomposition]]</tt>===
 
This function acts as an inverse of the <tt>SchmidtDecomposition</tt> function:
 
This function acts as an inverse of the <tt>SchmidtDecomposition</tt> function:
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
 
>> vec = [1,2,3,4];
 
>> vec = [1,2,3,4];
>> [s,u,v] = [[SchmidtDecomposition|SchmidtDecomposition(vec)]];
+
>> [s,u,v] = SchmidtDecomposition(vec);
 
>> TensorSum(s,u,v)
 
>> TensorSum(s,u,v)
  
Line 29: Line 29:
 
     3.0000
 
     3.0000
 
     4.0000
 
     4.0000
</pre<noinclude></noinclude>>
+
</syntaxhighlight>
  
 
===Inverse of <tt>[[OperatorSchmidtDecomposition]]</tt>===
 
===Inverse of <tt>[[OperatorSchmidtDecomposition]]</tt>===
 
This function also acts as an inverse of the <tt>OperatorSchmidtDecomposition</tt> function:
 
This function also acts as an inverse of the <tt>OperatorSchmidtDecomposition</tt> function:
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
 
>> X = reshape(1:16,4,4)'
 
>> X = reshape(1:16,4,4)'
  
Line 43: Line 43:
 
     13    14    15    16
 
     13    14    15    16
  
>> [s,U,V] = [[OperatorSchmidtDecomposition|OperatorSchmidtDecomposition(X)]];
+
>> [s,U,V] = OperatorSchmidtDecomposition(X);
 
>> TensorSum(s,U,V)
 
>> TensorSum(s,U,V)
  
Line 52: Line 52:
 
     9.0000  10.0000  11.0000  12.0000
 
     9.0000  10.0000  11.0000  12.0000
 
   13.0000  14.0000  15.0000  16.0000
 
   13.0000  14.0000  15.0000  16.0000
</pre<noinclude></noinclude>>
+
</syntaxhighlight>
 +
 
 +
{{SourceCode|name=TensorSum}}

Revision as of 14:22, 20 September 2014

TensorSum
Computes a vector or operator from its tensor decomposition

Other toolboxes required none
Related functions FilterNormalForm
OperatorSchmidtDecomposition
SchmidtDecomposition

TensorSum is a function that computes a vector or operator from its tensor decomposition. It acts as an inverse of the OperatorSchmidtDecomposition and SchmidtDecomposition functions, but also works for multipartite decompositions.

Syntax

  • TS = TensorSum(A1,A2,...)
  • TS = TensorSum(S,A1,A2,...)

Argument descriptions

  • A1,A2,...: Either matrices or cells containing matrices (and they should all be the same: either all matrices or all cells). If they are matrices, then the k-th column of each Ai will be tensored together for all k, and then the sum over k will be taken at the end. If they are cells, then the k-th element of each Ai will be tensored together for all k, and then the sum over k will be taken at the end.
  • S (optional, default [1,1,...,1]): A vector of weights (such as Schmidt coefficients) that will be applied when summing the terms at the end of the computation.

Examples

Inverse of SchmidtDecomposition

This function acts as an inverse of the SchmidtDecomposition function:

>> vec = [1,2,3,4];
>> [s,u,v] = SchmidtDecomposition(vec);
>> TensorSum(s,u,v)

ans =

    1.0000
    2.0000
    3.0000
    4.0000

Inverse of OperatorSchmidtDecomposition

This function also acts as an inverse of the OperatorSchmidtDecomposition function:

>> X = reshape(1:16,4,4)'

X =

     1     2     3     4
     5     6     7     8
     9    10    11    12
    13    14    15    16

>> [s,U,V] = OperatorSchmidtDecomposition(X);
>> TensorSum(s,U,V)

ans =

    1.0000    2.0000    3.0000    4.0000
    5.0000    6.0000    7.0000    8.0000
    9.0000   10.0000   11.0000   12.0000
   13.0000   14.0000   15.0000   16.0000

Source code

Click here to view this function's source code on github.