Re: tensor product
- To: mathgroup at smc.vnet.net
- Subject: [mg61741] Re: tensor product
- From: Chris Rodgers <rodgers at physchem.NOSPAMox.aREMOVEc.uk>
- Date: Thu, 27 Oct 2005 06:14:51 -0400 (EDT)
- Organization: Oxford University, England
- References: <djq8ci$kd4$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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.