[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #52342] vecnorm command
From: |
Marco Caliari |
Subject: |
[Octave-bug-tracker] [bug #52342] vecnorm command |
Date: |
Mon, 6 Nov 2017 09:22:48 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0 |
Follow-up Comment #5, bug #52342 (project octave):
Sorry, I used the conj function but I had in mind the sum of the squared real
and imaginary parts. In fact, I thougth that computing
(real (A) .^2 + imag (A) .^ 2) .^ (p / 2)
is faster than
(abs (A)) .^ p
But, I see a strange behavior:
octave:1> version
ans = 4.3.0+
octave:2> A=randn(5000)+1i*randn(5000);
octave:3> p=2;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 0.545308 seconds.
Elapsed time is 0.432356 seconds.
octave:4> p=3;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 0.534551 seconds.
Elapsed time is 1.92207 seconds.
octave:5> p=4;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 2.18147 seconds.
Elapsed time is 0.269113 seconds.
octave:6> p=5;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 2.13997 seconds.
Elapsed time is 1.91831 seconds.
octave:7> p=6;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 2.13447 seconds.
Elapsed time is 0.265429 seconds.
octave:8> p=7;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 2.2243 seconds.
Elapsed time is 1.92152 seconds.
octave:9> p=8;tic,(abs(A)).^p;,toc,tic,(real(A).^2+imag(A).^2).^(p/2);,toc
Elapsed time is 2.14631 seconds.
Elapsed time is 1.84531 seconds.
So, (real^2+imag^2)^(p/2) is always faster, except when p=3. In fact, it is
elevation to power 2 or 3 to be very fast. Is it just me?
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52342>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52342] vecnorm command, CH, 2017/11/05
- [Octave-bug-tracker] [bug #52342] vecnorm command, Marco Caliari, 2017/11/06
- [Octave-bug-tracker] [bug #52342] vecnorm command, CH, 2017/11/06
- [Octave-bug-tracker] [bug #52342] vecnorm command, Marco Caliari, 2017/11/06
- [Octave-bug-tracker] [bug #52342] vecnorm command, CH, 2017/11/06
- [Octave-bug-tracker] [bug #52342] vecnorm command,
Marco Caliari <=
- [Octave-bug-tracker] [bug #52342] vecnorm command, CH, 2017/11/06
- [Octave-bug-tracker] [bug #52342] vecnorm command, Rik, 2017/11/07
- [Octave-bug-tracker] [bug #52342] vecnorm command, Rik, 2017/11/07
- [Octave-bug-tracker] [bug #52342] vecnorm command, Marco Caliari, 2017/11/07
- [Octave-bug-tracker] [bug #52342] vecnorm command, Marco Caliari, 2017/11/08
- [Octave-bug-tracker] [bug #52342] vecnorm command, Rik, 2017/11/09