I have two very big column vectors, A
and B
, of size ax1
and bx1
, respectively. I want to construct a vector C
of size (b*a)x1
by computing A(i)*B(j)
for each i
and j
. To illustrate what I mean:
clear
a=10^3;
b=10^3;
A=randn(a,1);
B=randn(b,1);
Ctemp=zeros(a,b);
for i=1:a
for j=1:b
Ctemp(i,j)=A(i)*B(j);
end
end
C=reshape(Ctemp, a*b,1);
Question: is there a more efficient way to obtain C
which avoid double looping? My actual a
and b
are bigger than 10^3
.