octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #49940] The svd function takes very long time


From: Saleh
Subject: [Octave-bug-tracker] [bug #49940] The svd function takes very long time for big matrices
Date: Wed, 28 Dec 2016 02:13:29 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

Follow-up Comment #2, bug #49940 (project octave):

results of octave compared to matlab 

>> x = rand (1e3);
>> svd (x); % warmup
>> tic; sv      = svd (x); bm1 = toc
bm1 =  0.21399  %matlab 0.1721
>> tic; [u,s,v] = svd (x); bm2 = toc
bm2 =  11.840   %matlab 0.3880  approx 30x slowdown
>> tic; [s]     = svd (x); bm3 = toc
bm3 =  0.20974  %matlab 0.1556
>>
>> x = rand (2e3);
>> tic; sv      = svd (x); bm1 = toc
bm1 =  1.7601   %matlab 1.3173
>> tic; [u,s,v] = svd (x); bm2 = toc
bm2 =  96.207   %matlab 2.4857  approx 38x slowdown
>> tic; [s]     = svd (x); bm3 = toc
bm3 =  1.6928   %matlab 1.2874
>>
>> x = rand (3e3);
>> tic; sv      = svd (x); bm1 = toc
bm1 =  6.8742   %matlab 5.2722
>> tic; [u,s,v] = svd (x); bm2 = toc
bm2 =  353.66   %matlab 8.3250  approx 40x slowdown
>> tic; [s]     = svd (x); bm3 = toc
bm3 =  7.6766   %matlab 5.2956


I found in the svd.cc file at line 235 some relevant part (for real matrix)


if (nargout == 0 || nargout == 1) // if number of output arguments is one 
    retval(0) = sigma.extract_diag ();
else 
    retval = ovl (result.left_singular_matrix (),
        sigma,
    result.right_singular_matrix ());
// results is of type octave::math::svd<Matrix>


I belive the culprit is one of two things
a- ovl :it is copying the matrix, instead of copying its address
b- the algorithms  result.left_singular_matrix and right_singular_matrix are
very expensive to evaluate in octave.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49940>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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