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

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

[Octave-bug-tracker] [bug #64813] pararrayfun of the parallel package do


From: Umberto
Subject: [Octave-bug-tracker] [bug #64813] pararrayfun of the parallel package does not work when using the official example
Date: Wed, 25 Oct 2023 06:33:51 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?64813>

                 Summary: pararrayfun of the parallel package does not work
when using the official example
                   Group: GNU Octave
               Submitter: umbe1987
               Submitted: Wed 25 Oct 2023 10:33:48 AM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error or Warning
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: GNU/Linux
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 25 Oct 2023 10:33:48 AM UTC By: Umberto <umbe1987>
I am testing the pararrayfun function of the parallel package using the
official example at this link:
https://wiki.octave.org/wiki/images/e/e9/Examples_of_how_to_use_parrarrayfun.pdf

When running the code, I get the following error:


could not save variable.
error: 'myfun' undefined near line 1 column 6
execution error
error: __parcellfun_get_next_result__: could not receive result


The code I am testing is this one (taken from the aforementioned example):


# In this script 4 ways of calculating the values of a one-dimensional
function
# are compared, the time taken by each way is measured and it is verified
that
# there are no discrepancies in the results.
pkg load parallel

nmax = 10000; # Number of points where the function is calculated

function [a,b] = myfun(n); # Function used in this test
  a = pi*(n-2)/n;
  f = @(x) (cos(x).^n + sin(x).^(n-1));
  b = quadgk(f,0,a);
endfunction

# Fist method, using a for loop, defining the function to calculate
# within the loop.
tic
for n = 1:nmax;
  a1(n) = pi*(n-2)/n;
  b1(n) = quadgk(@(x) (cos(x).^n + sin(x).^(n-1)),0,a1(n));
endfor
t1 = toc

# Second method, using a for loop and calling "myfun"
tic
for n = 1:nmax
  [a2(n),b2(n)] = myfun(n);
endfor
t2= toc

# Third method, using arrayfun to call "myfun"
tic
ni = 1:nmax;
[a3,b3] = arrayfun("myfun",ni);
t3 = toc

# Forth method, using parrayfun to call "myfun"
tic
ni = 1:nmax;
[a4,b4] = pararrayfun(4,@(n) myfun(n),ni);
t4 = toc

# Are discrepancies in the results?
discrepancies_1 = max(a2-a1) + max(b2-b1) + max(a3-a1)
discrepancies_2 = max(b3-b1) + max(a4-a1) + max(b4-b1)


System info in the attached image ("system_info.png").







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64813>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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