Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

What's the difference between

projection= Table[Conjugate[autoVett[[k]].someVector1], {k, 1, r}]
Dimensions[projection]

that gave me as results {12} which is ok.

Dimensions[baseComp]
{8}
Dimensions[Transpose[{baseVector}]]
{12,1}
startState = 
  KroneckerProduct[baseComp, Transpose[{baseVector}]] ;
Dimensions[startState]
{96,1}
scompoStartState = 
  Table[Conjugate[CCNOTHvec[[k]].startState], {k, 1, 
    Length[CCNOTHvec]}];
Dimensions[scompoStartState]
{96,1}

What's the difference between a {12} vector and a {96,1} vector? I need to have just 96-dimensional vector.

share|improve this question
    
What's the difference between autoVett[[k]], someVector1, baseComp[[4]], and someVector2? –  bill s Jun 17 '13 at 10:15
    
they are both {n} dimensional vector.. –  Alessandro 'Scinawa' Antani Jun 17 '13 at 10:54
add comment

1 Answer

up vote 2 down vote accepted

The Kronecker product of two vectors of sizes $n$ and $m$ always gives a matrix of size $n$ by $m$. For example:

a = RandomReal[{-1, 1}, 4];
b = RandomReal[{-1, 1}, 5]; 
Dimensions[KroneckerProduct[a, b]]

In fact, the KroneckerProduct is just a rewriting of

Outer[Times, a, b]

and this same calculation can also be done with Table

Table[a[[i]] b[[j]], {i, 1, Length[a]}, {j, 1, Length[b]}]

all of which give the same $n=4$ by $m=5$ matrix. You can turn any of the above into a vector using Flatten. Hence

Flatten[Outer[Times,a,b]]

is a vector of size $4\times 5=20$ containing the same elements as the 4 by 5 matrix.

share|improve this answer
    
I know, but I want to have a 5*4 vector, not a matrix. eg: Command[{a,b},{c,d}] = {a*c, a*d, b*c, b*d} –  Alessandro 'Scinawa' Antani Jun 17 '13 at 11:44
1  
See change... Flatten[Outer[Times, {a, b}, {c, d}]] gives what you ask for (make sure to Clear a,b,c,d so the values don't conflict.) –  bill s Jun 17 '13 at 11:58
    
THANKS!!!! It works! :D –  Alessandro 'Scinawa' Antani Jun 17 '13 at 12:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.