octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dot product full-sparse


From: Marco Caliari
Subject: Re: Dot product full-sparse
Date: Thu, 12 Aug 2010 10:14:20 +0200 (CEST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Thu, 12 Aug 2010, Jaroslav Hajek wrote:

On Wed, Aug 11, 2010 at 8:20 AM, Marco Caliari <address@hidden> wrote:
Dear maintainers,

if I run

A = toeplitz ([-2, 1, 1, 1, zeros(1, 856)]);
A = reshape (A, 18490, 40);
SA = sparse (A);
B = rand (size (A));
tic, A .* B;,toc
tic, SA .* B;, toc
tic, SA .* sparse (B);, toc

I get

Elapsed time is 0.00745105 seconds.
Elapsed time is 0.229055 seconds.
Elapsed time is 0.0203849 seconds.

(3.3.51 with Suitesparse 3.5.0, similar results with 3.2.4 with Suitesparse
3.4.0). Why SA .* sparse (B) is so faster than SA .* B? What is done by
default when a full-sparse dot product is required?

Best regards,

Marco


Apparently this operation is just poorly optimized.

Before I start doing anything here, I'd like to know what the Matlab
behavior is w.r.t. NaNs. Namely, if
A = sparse ([2,3,1,2], [1,1,3,3], [0.1, 0.2, 0.3, 0.4]);
B = ones (3); B(1,1) = NaN;
C = sparse ([1,2,3,1,2], [1,1,1,3,3], [NaN, 0.1, 0.2, 0.3, 0.4]);

what is the output of A.*B, B.*A, A ./ B, A .*C?
Of course, newer version is better.

Here are the results with Matlab 7.6.0 (R2008a)

A.*B
ans =
   (1,1)          NaN
   (2,1)       0.1000
   (3,1)       0.2000
   (1,3)       0.3000
   (2,3)       0.4000
 B.*A
ans =
   (1,1)          NaN
   (2,1)       0.1000
   (3,1)       0.2000
   (1,3)       0.3000
   (2,3)       0.4000
A ./ B
ans =
   (1,1)          NaN
   (2,1)       0.1000
   (3,1)       0.2000
   (1,3)       0.3000
   (2,3)       0.4000
A .* C
ans =
   (1,1)          NaN
   (2,1)       0.0100
   (3,1)       0.0400
   (1,3)       0.0900
   (2,3)       0.1600

Marco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]