Melvin Brown

79 Reputation

6 Badges

13 years, 251 days

Social Networks and Content at Maplesoft.com

Maple Application Center

MaplePrimes Activity


These are replies submitted by Melvin Brown

@Carl Love 

@acer

Well, I've just tested this.  Here are my findings:

MAPLE 2015.1 running a Maple worksheet
==========================

I placed the following code in the Start up Code section

libname := libname, "S:/MRBwork/MAPLE/MRBlibrary/BealSearch/BealSearchSp8.mla";
with(BealSearchSp8);

This automatically links in the package I require, when the worksheet starts up.

I then use the Mathematical Expression component to embed a call to a procedure from this package. On pressing return outside the component box, I obtain the expected result.

Fine!

MAPLE Player 2015
=================

However, when I start the same worksheet in MAPLE Player, I have the following response:

0, "permission denied: no read access (%1)", "S:/MRBwork/MAPLE/MRBlibrary/BealSearch/BealSearchSp8.mla"

which presumably comes from the start up code section.

I then find (perhaps unsurprisingly) that the Mathematical Expression component calling the procedure evokes no result at all.

I have taken a look at the permissions on that file and all groups and users have read and read/excute permission.

Are you able to suggest a route forward?

MRB

@acer 

Thanks very much for the helpful tips; I'll work through your suggestions. I've not previously used the Startup Code Region.

MRB

Mac

 

Many thanks for that helpful answer; particularly that A knows about B and C.

 

Cheers MRB

@acer 

This problem of creating a fortran dll for calling in MAPLE is now solved. The solution is explained and exemplified below.

My first attempt at generating dll with fortran g77 failed because g77 does not have a -shared option to generate a dll.

The gfortran complier in the gcc collection does have the -shared option for dll generation. However, my attempt at using gfortran from the MinGw gcc compiler set (under Windows 7) failed to create an executable let alone a dll. I was unable to diagnose the cause.

Finally, I installed Cygwin (on a Windows 7 laptop). This includes the gcc collection of compilers, and I was thus able to successfully generate a dll. A key step was setting an environmental path variable to the cygwin1.dll in C:\cygwin64\bin to enable its link from the .dll to be resolved.

The gfortran compile sequence was as follows: First compile myfunc.c into object code:

gfortan -c myfunc.for

in which myfunc.for defines the FORTRAN function mult(a,b) where a and b are real numbers being multplied together. Then, using gfortran we build a shared library from the object file:

gfortran -shared -o myfunc.dll myfunc.o

The dll is then called up to define a function in MAPLE as follows:

fmult:=define_external(mult,LIB="C:/shared/myfunc.dll",FORTRAN,'a'::(float[4]),'b'::(float[4]),RETURN::(float[4])):

We then find that:

fmult(3, 2.7);
8.10000038146972656

and

[seq(fmult(2*j, 5*(j-1)), j = 1 .. 10)];

[0., 20., 60., 120., 200., 300., 420., 560., 720., 900.]

This completes the example. The difficultly lay not with MAPLE, but with finding and apt implementation of the gcc compiler set.

MRB

 

 

@acer 

Thanks again for engaging with this.    I am running MAPLE 18 under Windows 7.  I was unable to generate a dll using g77, as the latter seems not to recognise the -shared option.  

So I switched to using CYGWIN, and successfully used the -shared option to generated a dll file there:

$ gfortran -c test2.for

$ gfortran -c Mtest.for

$ gfortran -shared -o mult.dll test2.o

However, that dll file was not accepted by MAPLE, in which the line

fmult:=define_external('mult',LIB="c:/shared/mult.dll",FORTRAN,'a'::(float[4]),'b'::(float[4]),RETURN::(float[4]));

produced the following error:

Error, external linking: error loading external library c:/shared/mult.dll: The specified module could not be found.

Am I correct in thinking that a dll generated under CYGWIN will not be correctly parsed by MAPLE running under Windows, which presumably requires a dll targetted at Windows?  Can flags can be used to tell gfortran (under CYGWIN) to generate a dll targetted at Windows? Ideally, I am looking for a working example.

Regards

MRB

 

Thanks for your quick response.  I am working on Windows 7, hence use of dll.    I am also using g77 which appears not to support the -shared option; at least for me on Windows !! I have now separately compiled the main and function fortran files.  However, it remains the case that I am unable to create a dll that does not generate an error from the external function call.

MRB

I have some old (R3,4,5..) MAPLE files of types:

.mwz and .msz

and would like to open these files asndf convert them for viewing in MAPLE 16.

Is the way of doing this?

MRB 

 

 

I have some old (R3,4,5..) MAPLE files of types:

.mwz and .msz

and would like to open these files asndf convert them for viewing in MAPLE 16.

Is the way of doing this?

MRB 

 

 

Thanks; I sent an email asking for help to that email address on Jun 6 2011, but have not yet received a repy!  I have just re-sent that email.

 

MRB

Thanks; I sent an email asking for help to that email address on Jun 6 2011, but have not yet received a repy!  I have just re-sent that email.

 

MRB

Thanks for responding.  The plotted data is just an example, and the result you obtained is what I expect and also obtain on my old XP machine. I could have used any other function.  That is not my problem.  The problem is that I do not get that plot on my VISTA machine when N is sufficiently large; i.e when N=180, MAPLE just stalls and no plot appears.  So this seems to be a problem for plots of datasets above a certain size, on my installation of MAPLE 14 on VISTA.

MRB

Thanks for responding.  The plotted data is just an example, and the result you obtained is what I expect and also obtain on my old XP machine. I could have used any other function.  That is not my problem.  The problem is that I do not get that plot on my VISTA machine when N is sufficiently large; i.e when N=180, MAPLE just stalls and no plot appears.  So this seems to be a problem for plots of datasets above a certain size, on my installation of MAPLE 14 on VISTA.

MRB

Thanks, both.  I have added the shape=hermitian parameter in defining the matrix.

Just to illustrate what seemed to be the consequences:

One may, under certain conditions, see sudden polarity changes in the difference between eigenvalues.  The following code exemplifies the effect, which is not seen in EigenHerm2b2, but is observed in Eigenvectors. (This is an extreme case; in my application, in quantum mechanics, the polarity switches were far less frequent.) This was the motivation for writing EigenHerm2b2 for my application. I wish to track the dependence of the sum and difference of the eigenvalues against t, and although eigenvalues/vectors may change smoothly with t, were their ordering to swap over, while my addresses for them were fixed, might then the sum be unaffected and the difference change sign?! Still, I do have a work around for the 2x2 case.

>K:=(t)->evalf(Matrix(2,2,[[(cos(t)),sin(t/2)*(1-I)],[sin(t/2)*(1+I),(cos(t))]],shape=hermitian));Kperiod:=12:
 
>plot([(''EigenHerm2b2(K(tt))[1][1]''+''EigenHerm2b2(K(tt))[1][2]''),(''EigenHerm2b2(K(tt))[1][1]''-''EigenHerm2b2(K(tt))[1][2]''),Determinant(K(tt))], tt=0..Kperiod,legend=["sum","difference","determinant"],numpoints=100,title="sum and difference of eigenvalues (using EigenHerm2b2)");

>plot([(''Eigenvectors(K(tt))[1][1]''+''Eigenvectors(K(tt))[1][2]''),(''Eigenvectors(K(tt))[1][1]''-''Eigenvectors(K(tt))[1][2]''),Determinant(K(tt))], tt=0..Kperiod,legend=["sum","difference","determinant"],numpoints=100,title="sum and difference of eigenvalues (using Eigenvectors)");

MRB
 

 

 

 

I ran into the ordering problem when using Eigenvectors procedure to diagonalise a 2x2 Hermitian matrix J(t) parameterised by time t. At a certain time J(t) was such that the labelling/ordering of the eigenvectors and eigenvalues would swap, so introducing discontinuity in themasa function of time. I wrote the following procedure to get around the problem, using the same inputs and outputs as for Eigenvectors. While it has worked well for me, no guarantees are given as to its correctness. >EigenHerm2b2:=proc(Mi::Matrix) description "Determine the eigenvectors and eigenvalues of the 2 x 2 Hermitian matrix Input: Mi - Hermitian matrix; Output:(eigenvalues [column], eigenvectors [col1, col2])"; > local mtol,a,b,c,d,V1k,V2k,V,sroot,v,k,vnorm; > mtol:=1.0e-9; > if( not (is( is(Im(Mi[1,1]+Mi[2,2])< mtol) and is(abs(Mi[1,2]-Mi[2,1]^*) < mtol) ) ) ) then > print(`Matrix not Hermitian in EigenHerm2b2 =>`);print(Mi);return; > end if; > a:=(Mi[1,1]+Mi[2,2])/2;b:=(Mi[1,2]+Mi[2,1])/2;c:=(Mi[2,1]-Mi[1,2])/2/I;d:=(Mi[1,1]-Mi[2,2])/2; > sroot:=sqrt(b^2+c^2+d^2); > v[1]:=a+sroot;v[2]:=a-sroot; > for k from 1 by 1 to 2 do > V1k:=(v[k]-(a-d))/(b+I*c); > vnorm:=1/sqrt(1+(abs(V1k))^2); > V[k]:=[V1k*vnorm, vnorm]; > end do; > (Vector(2,[v[1],v[2]]),(Matrix(2, 2,[V[1],V[2]]))^+); > end proc: MRB
1 2 3 Page 3 of 3