232 Reputation

8 Badges

6 years, 288 days

MaplePrimes Activity

These are replies submitted by Gillee

@mmcdara Thank you for your answer.

@acer Thank you for your answer.

@acer In the define_external line, I deleted the RETURN:: ... phrase to get a NULL return and added "c" after the fmay_mult(a,b,c,3,3).

>fmat_mult:=define_external( 'mat_mult', LIB= "C:/Users/familee/OneDrive/Documents/Maple/DLL-example/mat_mult.dll", FORTRAN, 'a'::(ARRAY(datatype=float[8])), 'b'::(ARRAY(datatype=float[8])), 'c'::(ARRAY(datatype=float[8])), 'm'::(integer[4]), 'n'::(integer[4]) ):

The results should be the Matrix c

                        [30.  66.  102.]
                        [36.  81.  126.]
                        [42.  96.  150.]


I ran your program and it works. I did not make any changes to the C++ compiler.

Thanks again  


I added the line infolevel[compiler]:=3. I got a similar response in Maple 2023 Windows 11: Compile: Compile Command: "C:\Program Files\Maple 2023\llvm\bin\x86_64-w64-mingw32-clang++.exe" -c  -DX86_64_WINDOWS=1 -I"C:\Program Files\Maple 2023\extern\include" -O2  -w  

In Maple 2022 Windows 11, the response is: Compile: Compiling generated C code with LLVM. Then everything works.

I also have Maple 2023 running on Linux, it works fine.

Thank you for your input.


Thanks for your response.

One more try at speeding it up. Write procedure and compile it to native code. The compiled procedure is faster than any of the previous attempts found in



restart; kernelopts(version)

`Maple 2021.1, X86 64 WINDOWS, May 19 2021, Build ID 1539851`


datLoop := proc (i_high::integer, j_high::integer, X::(Vector(datatype = float[8])), Y::(Vector(datatype = float[8])), Z::(Vector(datatype = float[8]))) local i::integer, j::integer, k::integer, di::(float[8]), dj::(float[8]); k := 1; di := 1.0/i_high; dj := 1.0/j_high; for j to j_high do for i to i_high do X[k] := i*di; Y[k] := j*dj; Z[k] := X[k]^2+Y[k]^2; k := k+1 end do end do end proc


If you can compile a Maple procedure to native code, then it runs fast. There are only small number of mathematical functions in the run-time library, see help on Compiler.  


cdatLoop := Compiler:-Compile(datLoop)

proc () options call_external, define_external(_mf85e7835c3fc2354c4b104b43e721728, MAPLE, IN_MEM = 2379591451296); call_external(0, 2379591451296, true, false, args) end proc



Initialize variables:


i_high := 1000; j_high := 1000; X := Vector(1 .. i_high*j_high, datatype = float[8]); Y := Vector(1 .. i_high*j_high, datatype = float[8]); Z := Vector(1 .. i_high*j_high, datatype = float[8])


Run datLoop procedure


CodeTools:-Usage(datLoop(i_high, j_high, X, Y, Z))

memory used=480.47MiB, alloc change=8.00MiB, cpu time=5.44s, real time=5.49s, gc time=1.94s



Display the first ten data points


X[1 .. 10], Y[1 .. 10], Z[1 .. 10]

Vector[column](%id = 36893490527006812148), Vector[column](%id = 36893490527006812268), Vector[column](%id = 36893490527006812388)



Run compiled datLoop procedure: cdatLoop


CodeTools:-Usage(cdatLoop(i_high, j_high, X, Y, Z))

memory used=1.06KiB, alloc change=0 bytes, cpu time=16.00ms, real time=17.00ms, gc time=0ns


X[1 .. 10], Y[1 .. 10], Z[1 .. 10]

Vector[column](%id = 36893490527006802756), Vector[column](%id = 36893490527006802876), Vector[column](%id = 36893490527006802996)


"n:=3: f(x,y):=x^(~2)+y^(~2): data := CodeTools:-Usage([seq([seq([i/10^(n), j/10^(n), f(i/10^(n), j/10^(n))], i = 1 .. 10^(n))], j = 1 .. 10^(n))]): "

memory used=0.99GiB, alloc change=225.29MiB, cpu time=6.73s, real time=5.95s, gc time=1.75s


data[1][1 .. 2][1 .. 2]

[[1/1000, 1/1000, 1/500000], [1/500, 1/1000, 1/200000]]






I realized I should have shown that zeta = xi - beta * I.

I added negative signs to the following two lines of code:

soln1:=select(s->Re(s)>0 and -Im(s)>0, soln);



It is a nice solution.


Thank you


@Carl Love Two thumbs up.

@Carl Love Your improvements did make it run faster by 20 to 30 percent on my computer. Using the original script before it was modified for Grid Map and your M values, I calculated values for the Array A and found the results from both methods identical - element by element.  Thanks again for your great insight to this problem. 

@Carl Love The efficiency of your code is wonderful. Your lesson is greatly appreciated. I am in the process of verifying the results. Thanks again.

1 2 3 Page 1 of 3