From: "Jan Simon" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to make the function 'norm' treat its input as vectors?
Date: Wed, 13 Oct 2010 15:03:03 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 10
Message-ID: <i94hn7$kpl$>
References: <i938ok$smb$> <i93kdo$o8f$> <i94def$3h4$>
Reply-To: "Jan Simon" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1286982183 21301 (13 Oct 2010 15:03:03 GMT)
NNTP-Posting-Date: Wed, 13 Oct 2010 15:03:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: comp.soft-sys.matlab:678105

Dear Yang,

I've created a C-Mex function for the 2-norm along a specific dimension.
For [1 x 10000] vectors it is 20% faster than NORM, but for [1 x 100] vectors the overhead of calling the Mex eats up the performance, such that NORM is 35% faster than the C-Mex. 
Anyhow, for arrays allocating the memory for the x.*x array and the vector replied by SUM consumes a remarkable chunk of time, such that the C-mex, which calculates all values elementwise, is 20 to 50% faster than SQRT(SUM(x.*x)).
If you are interested, I could publish it.

But I'm still surprised, that such a common task is not solved by a built-in function.

Kind regards, Jan