Items tagged with module

Feed

Hello,

I have two simple module's:

1) ------------------------------------------------------------------------

Point := proc(xx::float,yy::float)
    return module()
        local x := xx,y := yy;
        export ShowPoint,GetX,GetY;
        
        ShowPoint := proc()
            printf("Point X,Y -> [%f,%f]",x,y);
        end proc;

        GetX := proc()
            return x;
        end proc;        
        GetY := proc()
            return y;
        end proc;    
    end module:
end proc:

2) ------------------------------------------------------------------------

PointMath := module()
    option package;  
    export `+`;
    
    `+` := proc(a::Point(float,float),b::Point(float,float))
        option overload;
        Point(a:-GetX()+b:-GetX(),a:-GetY()+b:-GetY());
    end proc;
end module:

------------------------------------------------------------------------

Next I use first module:

p1:=Point(1.2,1.4);

p2:=Point(1.0,2.0);

Finally I want to add above two points:

with(PointMath)

p2:=p1+p2

The results is:

p2:=p1+p2

Why is not called operator '+' and two points are not added?

Best,

Rariusz

 

 

 

Hello,

In a module, i have defined a global variable GeometricData. I would like to use this variable in procedures which are inside the module. How can i define variables in a module which can be used in procedure inside a module ?

In my code below, the variable GeometricData is not seen by the procedures.

 

MonPackageFonctions:=module()
option package;
export GammaNum,psiNum;
global GeometricData;

GeometricData:=r=0.2,l=1;

GammaNum:=proc(xx)
global GeometricData;
Gamma := Pi-arccos((1/2)*(-x(t)^2+l^2-r^2)/(x(t)*r));
evalf(eval(Gamma,[GeometricData,x(t)=xx]));
end proc;

psiNum:=proc(xx)
global GeometricData;
psi :=-arcsin((1/2)*sqrt(-(x(t)^4-2*x(t)^2*l^2-2*x(t)^2*r^2+l^4-2*l^2*r^2+r^4)/(x(t)^2*r^2))*x(t)/l);
evalf(eval(psi,[GeometricData,x(t)=xx]));
end proc;

end module;


Thanks a lot for your help

Hello all

 

I am new to Maple, and I am solving a system of two coupled partial differential equations using pdsolve, but I am having a hard time retrieving the solution evaluated at some point from the output. The output of pdsolve is a module, which appears to have different "methods" on it, including "plot3d" and "value". I can easily get a plot of my solution by using plot3d, but I don't know how to get a meaningful value out. For instance, if my solution is (f(x,y), g(x,y)), I would like to define H(x,y) = (f(x,y), g(x,y)), and be able to type H(10,10) into Maple to have my solution evaluated at that point. The result should be (1,1).

Here is a toy example:

firstEq := diff(f(x, y), x)+diff(f(x, y), y) = f(x, y)+g(x, y);
secondEq := diff(g(x, y), x)+diff(g(x, y), y) = 2*f(x, y)+g(x, y);
pdsystem := {firstEq, secondEq};

bv11 := f(10, y) = 1;
bv12 := f(x, 10) = 1;
bv21 := g(10, y) = 1;
bv22 := g(x, 10) = 1;
bvs := {bv11, bv12, bv21, bv22};
 
pdsolution := pdsolve(pdsystem, bvs, numeric, time = x, range = 0 .. 10);
 
pdsolution:-plot3d(x = 1 .. 10, y = 0 .. 10);
pdsolution:-value(10, 10);
Error, (in pdsolve/numeric/value) got additional unknown arguments {2}
 

Best regards.

 

In the test package below I want the the Value of Clr to be "B" when the package is loaded. How do I achieve that?
 

restart

mylibdir := cat(kernelopts(homedir), kernelopts(dirsep), "maple", kernelopts(dirsep), "toolbox", kernelopts(dirsep), "personal", kernelopts(dirsep), "lib")

"C:\Users\Ronan.Ronan-PC\maple\toolbox\personal\lib"

(1)

``

libname := mylibdir, libname

"C:\Users\Ronan.Ronan-PC\maple\toolbox\personal\lib", "C:\Program Files\Maple 2016\lib", "C:\Users\Ronan.Ronan-PC\maple\toolbox\personal\lib"

(2)

``

``

``

"RTest:=module()  option package;  export  Sums;    global Clr;  Clr:=B;  Sums:=proc(p1,p2,c:=Clr)  if c=B or c=b  then    p1+p2  elif c=G or c=g then  p1-p2  elif c=R or c=r  then      if p2 =0 then "Not Valid"       else ( p1)/(p2)        end if  else "Error"  end if  end proc;    end module; "

_m655171968

(3)

``

savelib('RTest')

restart

``

with(RTest)

[Sums]

(4)

"At This point I want the value of Clr to be automaticially   B"

Sums(2, 3)

"Error"

(5)

RTest:-Sums(2, 3, b)

5

(6)

``

RTest:-Sums(2, 3, r)

2/3

(7)

RTest:-Sums(2, 3, g)

-1

(8)

Clr := g

g

(9)

RTest:-Sums(2, 3)

-1

(10)

RTest:-Sums(2, 3, b)

5

(11)

RTest:-Sums(2, 3)

-1

(12)

RTest:-Sums(2, 0, r)

"Not Valid"

(13)

``


 

Download Module_Test_global_Var.mw

Hello,

So as to build a function which gives several outputs, i have made a code with this manner :

Input:=[i1, ..., in]

Output:=proc(Input);

      export o1, o2, o3
      o1=f1(Input);
      o2=f2(Input);
      o3=f3(Input);
      end module

End proc;

By doing, output1:=Output(Input):-o1; , i obtained my result. However, as my structure begins with the procedure (proc End proc), I can't export my result in package.

For this reason, I'm thinking about changing the structure of my code by starting with the creation of the module and put all the functions inside.

Input:=[i1, ..., in]

Output:=module():

export o1,o2,o3;
option package;
o1:=proc(Input)
f1(Input);
end proc;

o2:=proc(Input)
f2(Input);
end proc;

o3:=proc(Input)
f3(Input);
end proc;
   
End module;

Can you give me your feedback on the two structures ? Do you think that the second choice Module->Functions is more appropriated ?

Thanks a lot of your help and feedback.

Hi,

I want to write my first module, and I failed!  I create an instance of the class (module?)

myList := TestModule(3);                    # works.

But I've no acess to the members, since I use export! What's wrong?

myList:-get_n;
myList:-set_n(20);
myList:-run();

Error, `myList` does not evaluate to a module
Error, `myList` does not evaluate to a module
Error, `myList` does not evaluate to a module


# *****************************************************************************

TestModule := module()
    export get_n, set_n, run;
    local  n, result, ModuleApply, profileRun;
    option package;
    description "A testmodule";

    # Constructor
    ModuleApply := proc(n)
        print("Calling of Module Apply...");
         thismodule:-n := n;
         result := [];
         profileRun();
         return result;
     end proc:


    # Implementation of member run
     run := proc()
         print("Calling of run...");
         dummy := [];
         for i from 1 to 20000 do
            dummy := [op(dummy), i]
         end do;
         result := TRUE;
    end proc;
    
    # Implementation of member runprofile;
     profileRun := proc()
          print("Call of profileRun...");
          CodeTools[Profiling]:-Profile(run);
           run();
           CodeTools[Profiling]:-PrintProfiles(run);
           CodeTools[Profiling]:-UnProfile(run);
     end proc;

     # getter
     get_n := proc()
         n;
     end proc;

     # setter
     set_n := proc(n)
         thismodule:-n := n;
     end proc;
     
end module;

 

Hello:

I want to make a package or module. Not sure. I cant get my head around what to do. I have loads of formulas I would like to be able to use without going back through work sheets. At present just want to keep it simple.

Have loaded a sample work sheet to use

Intend to place package in Maple2016 library folder.

 

restart

Library Folder

C:\Program Files\Maple 2016\lib

``

``

with(LinearAlgebra):

``

``

Points

Point2 := proc (x1, y1) options operator, arrow; [x1, y1] end proc

proc (x1, y1) options operator, arrow; [x1, y1] end proc

(1)

Point3 := proc (x1, y1, z1) options operator, arrow; [x1, y1, z1] end proc

proc (x1, y1, z1) options operator, arrow; [x1, y1, z1] end proc

(2)

a1 := Point3(x1, y1, z1)

[x1, y1, z1]

(3)

a2 := Point3(x2, y2, z2)

[x2, y2, z2]

(4)

a3 := Point3(x3, y3, z3)

[x3, y3, z3]

(5)

Line through 2 points

LinePts := proc (p1, p2) options operator, arrow; (p2[2]-p1[2])*x+(p1[1]-p2[1])*y-p2[2]*p1[1]+p1[2]*p2[1] end proc

proc (p1, p2) options operator, arrow; (p2[2]-p1[2])*x+(p1[1]-p2[1])*y-p2[2]*p1[1]+p1[2]*p2[1] end proc

(6)

``

Line

Line := proc (a, b, c) options operator, arrow; a*x+b*y+c end proc

proc (a, b, c) options operator, arrow; a*x+b*y+c end proc

(7)

Lines s

LnPrll := proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, y)-coeff(l2, x)*coeff(l1, y) = 0) end proc

proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, y)-coeff(l2, x)*coeff(l1, y) = 0) end proc

(8)

Lines t

LnPrpnd := proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, x)+coeff(l1, y)*coeff(l2, y) = 0) end proc

proc (l1, l2) options operator, arrow; is(coeff(l1, x)*coeff(l2, x)+coeff(l1, y)*coeff(l2, y) = 0) end proc

(9)

``

``

Quadrance between 2 points (2D)

Quadrance := proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2 end proc

proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2 end proc

(10)

``

Quadrance between 2 points (3D)

Qd3 := proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2+(a1[3]-a2[3])^2 end proc

proc (a1, a2) options operator, arrow; (a1[1]-a2[1])^2+(a1[2]-a2[2])^2+(a1[3]-a2[3])^2 end proc

(11)

Triple Quad Formula (3 colinear points)

TQF := proc (Q1, Q2, Q3) options operator, arrow; (Q1+Q2+Q3)^2 = 2*Q1^2+2*Q2^2+2*Q3^2 end proc

proc (Q1, Q2, Q3) options operator, arrow; (Q1+Q2+Q3)^2 = 2*Q1^2+2*Q2^2+2*Q3^2 end proc

(12)

Spread*PolynomialsNULL

SpreadPoly := proc (n, s, rn) with(orthopoly); s-factor(1/2-(1/2)*T(n, 1-2*rn)) end proc

proc (n, s, rn) with(orthopoly); s-factor(1/2-(1/2)*T(n, 1-2*rn)) end proc

(13)

SpreadPoly(3, s, r)

s-r*(4*r-3)^2

(14)

``

 

Download Testpackage.mw

I need some help fix my mathematics maple code problem , I define everything my Procedures,and procedures run is ok, but when I using call functions for another procedures  I can not operator my program . For sure procedures is work and correct. if somebody can help me , I really appreciate you help.

Dear All

Say I have created a Maple module called MYMODULE. This means that I have a .mpl file called

mymodule.mpl, with inside

   MYMODULE := module()

   export myfunction;

   ****

   ****

   end module:

   savelib(MYMODULE, "MYMODULE.mla"):

Hence I use it in such a way:

> with(MYMODULE);

                                                              [myfunction]

I want to associate a help to the function myfunction. I know that with Maple18 things have changed

but I am not able to find enough information online. Say I have a .txt file called help_myfunction.txt.

How can I enable this help for my function, so that at the command

> ?myfunction;

the content of help_myfunction.txt shows up?

 

Many thanks,Simone

 

Hello,

I have .mla. package and I would like to create the source code associated to this package.

In the past, you have also help me to obtain the source code of procedure of the module.

Here the post where Carl Love has helped me :

http://www.mapleprimes.com/questions/203676-Open-A-Maple-Package

How can I do to create the complete source code of package directly ?

Is there a direct way enabling to not have to read one procedure by one procedure but to obtain the code source for all the package ?

Thank you for your help

 

 

Hello,

In the creation of package wrapping some procedures, may you tell me the differences between using a table or a module so as to wrap the procedures ?

In my case, it seems to me that table is more convenient since I can create with table packages while keeping my program with a structure of section, subsection, ...

But, I'm a beginner in the use of packages. Consequently, I'm very interested in your opinions on this question.

Thanks a lot for your help

Hello, guys

         I am a totally new comer in this erea. I get a new module file and want to implement it into maple,here is the link:

         http://cpc.cs.qub.ac.uk/summaries/ADWE

         After I downloaded the package, I didn't know the next step and I can't find a perfect solution to this case, maybe it is too easy.

         Can some cool guys can help me, THX.

Hello,

Thanks to the function Exports, it is possible to see the differents functions and modules which are in a module.

For example, I find in the module GetMultibody a module called GetLGM which permits to conduct some linear graph analysis. I'm interested by this module.

However, to my knowledge, I didn't see any help on this module.

How can I do so as to understand the inputs to give to the functions of this module in order to use the functions of this module ? In other words, how it is possible to use functions from a module when you don't have any help at your disposal ? 

Thanks a lot for your help.

Hello,

I would like to know : how I can get all the contents of the module GetMultibody of MapleSim?

Is there in classic maple a function enabling me to ask the content of a module ?

Thank a lot for your help.

 

Hi,

i have been looking to see if i could get the source code for some of the calculus functions in maple. So far, i have tried this

kernelopts(opaquemodules = false)

interface(verboseproc = 3)

print(DiffTutor)

which shows the result

module() ... end module

does anybody have any idea how i would:

1) get the full list of sub-procedures in the module

2) get the source code of any of the sub-procedures in the module?

Thanks in advance!!

1 2 3 4 5 6 7 Page 1 of 7