MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: tensor product


André Hautot wrote:
> In quantum physics one often needs the matrix representation of tensor 
> products
> 
> Outer[Times,{{1,2},{3,4}},{{a,b},{c,d}}]//MatrixForm
> 
> outputs something like this:
> 
> {{{{a,b},{c,d}},{{2a,2b},{2c,2d}},{{{3a,3b},{3c,3d}},{{4a,4b},{4c,4d}}}}
> 
> what I need is
> 
> {{a,b,2a,2b},{c,d,2c,2d},{3a,3b,4a,4b},{3c,3d,4c,4d}}
> 

Does this do the trick?

Needs["LinearAlgebra`MatrixManipulation`"]

IP::usage = "IP[mat1,mat2,...]: Compute the Kroenecker (Inner) product 
of a number of matrices.";

(* Define the Kroenecker product for matrices *)
IP[a_?MatrixQ, b_?MatrixQ] := BlockMatrix[Outer[Times, a, b]];
IP[a_?MatrixQ, b_?MatrixQ, c__?MatrixQ] := IP[IP[a, b], c];


IP[{{1,2},{3,4}},{{a,b},{c,d}}]

Chris.


  • Prev by Date: Re: Zero argument functions
  • Next by Date: Re: ParametricPlot3D
  • Previous by thread: Re: tensor product
  • Next by thread: Re: Mathematica and version control systems