Ronan

1022 Reputation

14 Badges

13 years, 157 days
East Grinstead, United Kingdom

MaplePrimes Activity


These are replies submitted by Ronan

@acer Thank you. I have all three packages stored properly now. 

On a side note I had asked a question on the CodeBuilder package in 2017. Didn't know it had answered till today. And i see you had some comments to make there. It might be useful for what I wand to do. How do I use the CodeBuilder package? - MaplePrimes I have asked another question on it there.

@acer The LibraryTools make it much easier. So now before I go any futher I an sorting out my RationalTrigonometry and RonanRoutines packages. I am using the AlgCalc package to experiment with.

So I have managed to make the Ratonal trigonometry save out seperately into it's own .mla. I renamed the directsearch.mla extension to mxla to do this. I can always download direct search again.

Problems with the RonanRoutines package deciding to not evaluate to a module. Will come back to that. Though it did work the last time I modified it in september. Moved to 2022.2 at weekend??
 Now the AlgCalc package burried its self inside the CodeBuilder .mla so I deleted that whole package folder set.

The problem I am having now is the AlgCalc package not saving correctly. This document has screen shots to show what I have done.

 Yes I watched the package part of the conference. A bit too brief but I have screen shots I can go through at the weekend.

restart

Date()

_m2295771860928

dr := cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

SignedArea := proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then M := Matrix([a, b]); A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then M := Matrix([a, b]); A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

NULL

save SignedArea, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mm"

NULL

NULL

`⊕` := proc (a, b) (a+b)/(1-a*b) end proc

proc (a, b) (a+b)/(1-b*a) end proc

NULL

save `⊕`, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/⊕.mm"

 

This Part I did in Standard Notepad

 

AlgCalc := module ()
export SignedArea,
       `⊕`;
 option package;

$include "SignedArea.mm"
$include "`⊕`.mm"

 end module;

NULL

 

restart

with(LibraryTools)

[ActivationModule, AddFromDirectory, Author, Browse, BuildFromDirectory, ConvertVersion, Create, Delete, FindLibrary, PrefixMatch, Priority, Save, ShowContents, Timestamp, UpdateFromDirectory, WriteMode]

NULL

NULL

dr := cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

NULL

currentdir(dr)

"C:\Users\Ronan\Documents\MAPLE\A & Q Maple primes"

currentdir()

"C:\Users\Ronan\Documents\maple\Alibrary\Procedures"

read "AlgCalc.mpl"

_m2295817165792

LibLocation := "C:/Users/Ronan/maple/toolbox/personal/AlgCalc/AlgCalc.mla"

"C:/Users/Ronan/maple/toolbox/personal/AlgCalc/AlgCalc.mla"

Save('AlgCalc', LibLocation)

NULL

 

NULL

restart

NULLLibraryTools:-FindLibrary(AlgCalc)

NULLNULL

LibraryTools:-FindLibrary(RationalTrigonometry)

"C:\Users\Ronan\maple\toolbox\personal\lib\RationalTrigonometry.mla"

with(AlgCalc)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received AlgCalc

SignedArea([9, 1], [-5, 8], [7, 9])

SignedArea([9, 1], [-5, 8], [7, 9])

`⊕`(-3, 4)

`⊕`(-3, 4)

`⊕`(-3, 4)

`⊕`(-3, 4)

NULL

Download 4-11-22_Q_$include_Alg_Calc_Routines.mw

@acer Hello, I have managed to get some of your advice to work. So I haven't used a code editor. I codnloaded Sublime Text by didn't know what to do with it. So read through the Programming Guide Ch 11 I got something to work.

1. I had to save the procedures as *.mm files     Why is this so. *.mpl files would not work.

2. Using Notepad I made made the module/package incorporating $include

3. I saved this as an *.mpl file

4 restart and set the folder path. then read in the .mpl file

5 used savelib('AlgCalc', "AlgCalc.mla")

6 restart with(AlgCalc) both procecures in the package worked

I am having a problem saving the AlgCalc.mla to "C:UsersRonanmaple\toolboxpersonal\lib"  I found the command LibraryTools:-FindLibrary(AlgCalc)It is burried inside the CodeBuilder package. Something I downloaded about 4 years ago but never got anywhere with. Wonder if it would help now?
  My two other pagkages are also inside other packages.  
1. How do I properly save my packages to "C:UsersRonanmaple\toolboxpersonal\lib"?

2. How do I remove my packages from the other packages?

It is all shown in the attached document. 

restart

Date()

_m1493333135424

dr := cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

SignedArea := proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then M := Matrix([a, b]); A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then M := Matrix([a, b]); A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

NULL

save SignedArea, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mm"

NULL

NULL

`⊕` := proc (a, b) (a+b)/(1-a*b) end proc

proc (a, b) (a+b)/(1-b*a) end proc

NULL

save `⊕`, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/⊕.mm"

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

NULL

This Part I did in Standard Notepad

 

AlgCalc := module ()
export SignedArea,
       `⊕`;
 option package;

$include "SignedArea.mm"
$include "`⊕`.mm"

 end module;

NULL

restart

dr := cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

NULL

currentdir(dr)

"C:\Users\Ronan\Documents\MAPLE\A & Q Maple primes"

currentdir()

"C:\Users\Ronan\Documents\maple\Alibrary\Procedures"

read "AlgCalc.mpl"

_m1493380928384

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

"C:\Users\Ronan\maple\toolbox\personal\lib"

savelib('AlgCalc', "AlgCalc.mla")

restart

LibraryTools:-FindLibrary(AlgCalc)

"C:\Users\Ronan\maple\toolbox\CodeBuilder\lib\CodeBuilder.maple"

LibraryTools:-FindLibrary(RonanRoutines)

"C:\Users\Ronan\maple\toolbox\personal\lib\DirectSearch.mla"

LibraryTools:-FindLibrary(RationalTrigonometry)

"C:\Users\Ronan\maple\toolbox\personal\lib\DirectSearch.mla"

with(AlgCalc)

[`⊕`, SignedArea]

SignedArea([9, 1], [-5, 8], [7, 9])

-49

`⊕`(-3, 4)

1/13

`⊕`(-3, 4)

1/13

NULL


 

Download 1-11-22_Q_$include_Alg_Calc_Routines.mw

@Deeshani   Instead of typing one very long hard to read equation into solve, break it down into smaller pieces.  Makes it much easier to debug.

for example.

a:=.....

b:=....

c:=...

eqn:= a+b+c

solve(eqn,rho[1])

 

@acer 

Ist question. Where do I put the $include directive? Is it placed in the SignedArea.mpl file, another file, the module/package? This doesnt work

$include<SignedArea.mpl>;
SignedArea := proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, 
null} := null) local M, A; description 
"signed area of a line segment or 3 points"; if c = null then A := 1/2*a[1]*b[2
]-1/2*a[2]*b[1]; else A := 1/2*(b[2]-c[2])*a[1]+1/2*(-b[1]+c[1])*a[2]+1/2*c[2]*
b[1]-1/2*c[1]*b[2]; end if; return A; end proc;

2nd question. Why use a code editor and which/what one? Ok, I see the nice highlighting bracket matching and line indenting.  If I write a procedure in an external code editor, I would have no idea whether it works or not. Would have to save it and then read it into Maple. Then go back around that loop getting it to work. Also a read in .mpl file seems to loose all its nice formatting.
  revision control is not really required at my home use level. Though I understand it's importance in comerical use applications.

 Would the Maple Code Edit region that can be inserted into a document suffice. Or even the start up code edit region as that make it east to load and save files?

 I realise I may have to use notepad to add the $include directive.

I am coming from a level of having no background knowledge on what you are advising me to do.
If we take the following my comments in red.
“ I'd rather write my source in plaintext files to begin with, so that I could use decent revision control, a code editor of my choice, etc. Ok I see that. I could read them into any session as I wanted What read method are you using? The start up code edit region or read “ C: …….SignedArea.mpl; while prototyping functionality. Once satisfied I could write a module (again: itself authored in a plaintext file, with $include directives I really need to see how the $include directives are actually used and pointed to where the procedure.mpl files are stored. for its member procedures) and either read that in or store it all in a .mla as in a package? archive. 

Thank you for the link to the conference I have now regestered for it.

Edit:- So $include can't be used in a Maple document. Slowely starting to see why you advocate your approach. 


 

@acer I am interested in $include usage in a package. That may solve a long term problem of storing all the procedures inside the package. Now this question from @mmcdara referencing module members within the module - MaplePrimes was linked in my email notification. I tried to copy what was done by @Joe Riel but could not get it to work. He states " To build the mla you would use a shell command". I do not know what that it or how to impliment it.
Basically I have copied an old package and cut it down to experiment with using two procedures I often use.

restart

Date()

_m2615960902368

cat(kernelopts(homedir), "/Documents/maple/Alibrary/Procedures")

"C:\Users\Ronan/Documents/maple/Alibrary/Procedures"

SignedArea := proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

proc (a::{Vector, list}, b::{Vector, list}, c::{Vector, list, null} := null) local M, A; description "signed area of a line segment or 3 points"; if c = null then A := (1/2)*a[1]*b[2]-(1/2)*a[2]*b[1] else A := (1/2)*(b[2]-c[2])*a[1]+(1/2)*(-b[1]+c[1])*a[2]+(1/2)*c[2]*b[1]-(1/2)*c[1]*b[2] end if; return A end proc

save SignedArea, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl"

NULL

NULL

`&oplus;` := proc (a, b) (a+b)/(1-a*b) end proc

proc (a, b) (a+b)/(1-b*a) end proc

NULL

save `&oplus;`, "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/&oplus;.mpl"

NULL

NULL

NULL

NULL

NULL

NULL

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

"C:\Users\Ronan\maple\toolbox\personal\lib"

NULL

libname := mylibdir, libname

"C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\2022\Physics Updates\lib", "C:\Program Files\Maple 2022\lib", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib", "C:\Users\Ronan\maple\toolbox\OEIS\lib", "C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\UTF8\lib"

libname

"C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\2022\Physics Updates\lib", "C:\Program Files\Maple 2022\lib", "C:\Users\Ronan\maple\toolbox\CodeBuilder\lib", "C:\Users\Ronan\maple\toolbox\DirectSearch\lib", "C:\Users\Ronan\maple\toolbox\OEIS\lib", "C:\Users\Ronan\maple\toolbox\personal\lib", "C:\Users\Ronan\maple\toolbox\UTF8\lib"

"AlgCalc:=module()  option  package;  export   `&oplus;`,                  SignedArea ;    local ModuleLoad ;  #` ModuleLoad := proc`()       #`end proc;`    $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl";  $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/&oplus;.mpl";                     end module:"

Error, invalid `$` operator

"AlgCalc:=module() option package;  export `&oplus;`,  SignedArea ;   local ModuleLoad ;  #` ModuleLoad := proc`()       $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/SignedArea.mpl";  $include  "C:/Users/Ronan/Documents/maple/Alibrary/Procedures/`&oplus;`.mpl";            end module:"

savelib('AlgCalc')

NULL

NULL

restart

with(AlgCalc)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received AlgCalc

NULL

NULL


 

Download 29-10-22_Q_$include_Alg_Calc_Routines.mw

@acer I am away till next Thursday. I will look at your advice when I'm back.

@acer Thank you.  I am surprised I haven't been caught out by that before. For me I will use

gnrpoly:=proc(M::Matrix,var:=n)
.
.
.

return  p  

 end proc

 

@MathPrincess123 Is this what you want?

q := p^2;
nsr1 := simplify(NSR, 'assume = nonnegative');

nsr:=Quotient(nsr1,deltaa,p,'r')
r;

@MathPrincess123  Use the green arrow button to upload the worksheet

@Christian Wolinski ok I realised what you mean. That situation is not likely to occour for me. thank you.

@Christian Wolinski 

In the first post I had set a,b,c,d.  See attached. If this fatally flawed? I dont quite understand your answer.

restart

NULL

a, b, c, d := 1, -1, 1, -1

1, -1, 1, -1

a

1

b

-1

c

1

d

-1

``

Test := proc (a, b, c, d) if (a, b, c, d) = (1, 0, 1, -1) then print("foo") elif (a, b, c, d) = (1, 1, 1, -1) then print("bar") elif (a, b, c, d) = (0, -1, 1, -1) then print("foo-bar") elif (a, b, c, d) = (1, -1, 1, -1) then print("no-foo-bar") else print("no match") end if end proc

proc (a, b, c, d) if (a, b, c, d) = (1, 0, 1, -1) then print("foo") elif (a, b, c, d) = (1, 1, 1, -1) then print("bar") elif (a, b, c, d) = (0, -1, 1, -1) then print("foo-bar") elif (a, b, c, d) = (1, -1, 1, -1) then print("no-foo-bar") else print("no match") end if end proc

NULL

Test(a, b, c, d)

"no-foo-bar"

d := 0

0

Test(a, b, c, d)

"no match"

NULL

Download Q_19-9-22_test_if.mw

I worked it out

a, b, c, d := 1, -1, 1, -1;
if (a, b, c, d) = (1, 0, 1, -1) then
    print("foo");
elif (a, b, c, d) = (1, 1, 1, -1) then
    print("bar");
elif (a, b, c, d) = (1, -1, 1, -1) then
    print("foo-bar");
elif (a, b, c, d) = (0, -1, 1, -1) then
    print("no-foo-bar");
end if;

 

@tomleslie I ran into a situation where the procedure didn't work. I got to work. 

a[h]/(h + 1) as a coefficient caused a failure
getCP1 := proc(t, var := x) 
local cf, varpwr; 
if not has(t, var) then 
return <0, t>;
 elif op(-1, t) = var then
 return <1, `*`(op([1 .. -2], t))>;
    else varpwr, cf := selectremove(has, [op(t)], var);
    return <op(-1, op(varpwr)), `*`(op(cf))>; 
end if; 
end proc;

 

@dharr @tomleslie   Dharr. That is clever. Totally missed it myself.  Tomsile yes that is what I am looking for.

5 6 7 8 9 10 11 Last Page 7 of 24