Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to make the function 'norm' treat its input as vectors?
Date: Wed, 13 Oct 2010 18:54:04 +0000 (UTC)
Organization: Xoran Technologies
Lines: 10
Message-ID: <i94v8c$r8p$1@fred.mathworks.com>
References: <i938ok$smb$1@fred.mathworks.com> <i93kdo$o8f$1@fred.mathworks.com> <i94def$3h4$1@fred.mathworks.com> <i94mh3$9c3$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1286996044 27929 172.30.248.37 (13 Oct 2010 18:54:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 13 Oct 2010 18:54:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:678178

By modifying Bruno's benchnorm, I've found some contenders that are faster than norm().


norm(a) -> 0.003428
sqrt(a*a.') -> 0.001468
sqrt(mtimesx(a,a,'t')) -> 0.001392

The problem is that a*a.' can't be easily generalized to multiple rows, but the approach using mtimesx can. It is available here,

http://www.mathworks.com/matlabcentral/fileexchange/25977-mtimesx-fast-matrix-multiply-with-multi-dimensional-support