Items tagged with module

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,

In my worksheet (dedicated to the calculations of mechanism geometry), i'm trying to have a more "POO" approach (Programming Oriented Object).

In this sense, I begin to get more familiar with module and package. Attached, you can find a worksheet which gives the idea of the structure of my code. With this code, the module is very useful for me to call some results (attributes in terms of POO).

My way of doing is :
1) at the beginning, i use Maple as a calculator that is to say that at each prompt, i calculate expressions.
2) i try to make modules so as to have a easier access to the data that I calculated.

However, as the definition of the expressions that I calculated are outside my module (for example, in the worksheet attached, i calculate the expression of Gamma and psi before in my worksheet and i retrieve these expressions in the module with "global"), i can not use this module independently of this worksheet and namely in a Excel Addin.

In fact, the module works if the worksheet has been launched one time and consequently the expression of psi and Gamma are in the kernel (or in memory i want to say).

Question:

How can I do to transform my module in a independent and thus portable module ?

One idea will be to copy/ paste all the geometric calculations which have been done line by line inside the module.
However, i have many lines in separated prompts and moreover, it is always convenient to keep the line by line approach in the worksheet to make some tests.

I look forward to hearing your tips.

Thanks a lot for your help

MonPackage_ProcModule_variante4.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.

The issue Type check of parameters was resolved using the depends modifier. As far as I can tell, this modifier is not allowed for expected or keyword parameters, though. Thus the issue seems to reemerge for these types of parameters. Consider the following test example:

createModule := proc(V::Vector)
   local dim := LinearAlgebra:-Dimension(V);
   module()
      export f,g,h;
      f := proc( x::depends('Vector'(dim))              ) x end proc;
      g := proc( x::expects('Vector'(dim)) := something ) x end proc;
      h := proc({x::        'Vector'(dim)  := something}) x end proc;
   end module
end proc:
createModule(Vector(4)):-f(    Vector(4));
createModule(Vector(4)):-g(    Vector(4));
createModule(Vector(4)):-h(x = Vector(4));

The function f is just a restatement of the already resolved issue, compare the above link, while the functions g and h are for the expected and keyword parameter cases, respectively. The problem remains the same: the variable dim is not evaluated for g and h. What to do? Does there exist a solution equally satisfactory as the one for f?

Consider the following two test procedures for creation of the same module:

createModule1 := proc(dim::posint)
    module()
        export det;
        det := (x::Matrix(1..dim,1..dim)) -> Determinant(x);
    end module
end proc:

and

createModule2 := proc(A::Matrix(square))
    local dim;
    dim := RowDimension(A);
    module()
        export det;
        det := (x::Matrix(1..dim,1..dim)) -> Determinant(x);
    end module
end proc:

as well as the following code lines calling these:

createModule1(       2 ):-det(IdentityMatrix(2));
createModule2(Matrix(2)):-det(IdentityMatrix(2));

The first line executes unproblematically, while for the second line an error results concerning the dimensionality check 1..dim,1..dim of the matrix. Why is dim available/initialized in the first version, while not in the second?

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 Page 1 of 5