Question: How to make (if possible) this procedure ThreadSafe?


I have the following procedure that uses the Lie Derivatives of a vector field to build a set of equations.

description "This function returns the system of equations based on the Lie derivative.":
local i,n:=numelems(vars),L:=Array(0..n):
for i from 1 to n do
    L[i]:=inner(f,map((a,b) -> diff(b,a),vars,L[i-1])):
end do:
end proc:

Below it is an example on how to call the procedure.

I used CodeTools:-ThreadSafetyCheck to check all the procedures used within LieDerList and LieDerList itself, but nothing wrong came out. However when I try to run 


where models4 is a list of 1765 elements, maple returns "Error, (in factors) attempting to assign to `LinearAlgebra:-Modular:-Create` which is protected". If I change Threads to Grid, there is no problem at all.  

What am I overlooking? Is there a method to ensure the procedure is thread-safe?

Many thanks.   

PS.  I found one problem - inner, which is related to LinearAlgebra package, is not thread-safe.  

Please Wait...