Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Minor disappointment with Matlab
Date: Sat, 5 Sep 2009 06:45:06 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 28
Message-ID: <h7t1dh$41j$1@fred.mathworks.com>
References: <25f0b0e8-fa6b-4283-81eb-d3bfebeb4a97@c37g2000yqi.googlegroups.com> <h7s406$m8j$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252133106 4147 172.30.248.37 (5 Sep 2009 06:45:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 5 Sep 2009 06:45:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:568507


function t

n = 100000;
A = rand(3,n);
B = rand(3,n);

tic
for k=1:n
    a = A(:,k);
    b = B(:,k);
    c = cross(a,b);
end
toc % 7.201296 seconds.

tic
for k=1:n
    a = A(:,k);
    b = B(:,k);
    c = [ a(2)*b(3)-a(3)*b(2) a(3)*b(1)-a(1)*b(3) a(1)*b(2)-a(2)*b(1) ];
end
toc % 0.215036 seconds.

tic
C = cross(A,B);
for k=1:n
    c = C(:,k);
end % 0.078556 seconds.
toc