parallel processing - Can you parallelise inexact Jacobian calculation in Julia without special arrays? -


In Julia, you wanted to calculate a false Jacobian based on a vector function, F (x), for which Much is necessary to evaluate the calculation of Jacoban's assessment clearly there is quite a systematic similarity in the concept. My question is, can it be done without the support of the distributed array, shadearere etc in Julia?

For example, suppose you have the code:

  function Jacob (f:: function (x) = 1e-7 delta = eps * eye (length (X) J = Zero (length (x), length (x)) for i = 1: length (x) J [:, i] = (F (x + delta [:, ii]) - F ( X-delta [:, ii])) / 2 / EPS end J &   

Is it possible to parallel in this way, according to the manual, the sum of the 200000000 random coin flip Can explain parallel? I = 1: 200000000 int (randbool ()) end

I've tried

  nheads = @ parallel (+) something like this:  
  function of yakub (f :: function, x) Required ("testfunc.jl"); EPS = 1e-7 delta = EPS * eye (length (x)) J = zero (length (x), length (x)) for j = @ parallel (+) I = 1: length (x) j [:, i] = (f (x + delta [:, ii]) - f (x-delta [:, ii])) / 2 / eps j and j end   

Where "TestFunction.jl" is the name of the file, where this code, and its own definition, is found is. When I tried this, f with the evaluation for just x ^ 2 + because (x), I was able to matrix immediately as soon as I got a decent diagonal, but the values ​​do not match the given by non parallel code (which I can confirm to be true value) Further investigations reveal that Jacobian has some value of 2 or 3, when using Julia-4 is being multiplied.

The approach I described is a commendable one (and only need to improve to prevent duplication of evaluation)? If not, then there is another way by which I can judge Jacobian without using more complex special array types?

It seems that adding "J = zero (N, N)" fixes the issue of this duplication parallel to the loop as the first operation. The same thing can be done without the support of this type of brute force clearing of the Jammu array?

After

Do I understand I = 1 for J = @ parallel (+): length (x) From the above code, that is, when you type:

  j = zeros (length (x), length (x) j [:, i] = (f (x + delta [ :, I]] - F (X-Delta [:, ii])) / 2 / EPS J &   

Julia for a new process j , Then evaluates f (x) and the results are met together. I think the better and more efficient way To prevent sending J between threads, and do the following:

  @parallel (+) for i = 1: Length ((X - Delta [ J: = Zero (length (x), length (x)) J [:, I] = (F (x + delta [:, ii]) / eps j end   

With each one of the above code, each thread works on a fresh j and gives the correct answer in the same way.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -