dharr

Dr. David Harrington

8482 Reputation

22 Badges

21 years, 34 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

@acer Thanks for the detailed explanation. (I realised later that just entering the GAMMA equivalent didn't give the same result, and so the real situation was more complicated.)

@SHIVAS There is an attempt to do an inverse transformation at the end of my worksheet, which shows how to do it. It does not succeed but Eq 22 was different, Perhaps if it agreed with Eq 22 it would work. You will need to find the error in the eqns or conditions (assuming there is an error) to proceed.

@SHIVAS Yes, I did not get the same answer in eqn 22. I do not know what is wrong. If you think an assumption needs to be changed you will need to say which assumption it is and what it needs to be changed to, or change it yourself.

@SHIVAS I get a different transformed answer, which probably can't be inverse-transformed. Please check I didn't make any mistakes.

Download laplace.mw

@dharr If your objective is to follow the derivation in the paper, I can mostly derive the laplace transformed quantities, but I have to guess at the initial conditions - what are they? And why do x and y suddenly appear in the solution? Perhaps you can provide a link to the paper.

@Traruh Synred Somehow Export is being interpreted as ExportMatrix. I can't reproduce this in Maple 2023. @acer suggests you are using 2018, which had Export, but Maple 18 did not (use interface(version) to check your version). You can convert to a 4x1 Matrix and export it as you said, but saving to a .m file will save any Maple object and might be better for your application.

@Traruh Synred I can't figure out what is happening (not a version error) - please upload your worksheet using the green up-arrow in the Mapleprimes editor - choose the file, upload then choose insert link or insert contents.

@sursumCorda I added the timing test for the undocumented Makesplit, and it is not so different from some of the others, I guess there is a lot of overhead for some of these, so it might have been fairer to test with a case that had many more digits.

As for ithprime, according to ?GMP, it makes extensive use of the GMP library isprime, though that is for more digits that your test case here. Actually, processing nextprime a million times in 30 seconds seems pretty good to me!


restart;

p:= 2233433222;

2233433222

What is the fastest way to get the digits of an integer (encoded in any form) into an Array

p1:=proc(p); StringTools:-ToByteArray(sprintf("%d",p)) end proc:

a1:=CodeTools:-Usage(p1(p),iterations=10^6);

memory used=0.98KiB, alloc change=45.00MiB, cpu time=8.75us, real time=8.32us, gc time=8.3e+02ns

Vector[row](10, {(1) = 50, (2) = 50, (3) = 51, (4) = 51, (5) = 52, (6) = 51, (7) = 51, (8) = 50, (9) = 50, (10) = 50})

p2:=proc(p); Array(StringTools:-Explode(sprintf("%d",p))) end proc:

a2:=CodeTools:-Usage(p2(p),iterations=10^6);

memory used=496 bytes, alloc change=-4.00MiB, cpu time=4.11us, real time=3.87us, gc time=5.2e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p3:=proc(p); Array(convert(p,base,10)) end proc: #shockingly slow

a3:=CodeTools:-Usage(p3(p),iterations=10^6);

memory used=10.04KiB, alloc change=0 bytes, cpu time=64.62us, real time=59.91us, gc time=10.34us

Vector[row](10, {(1) = 2, (2) = 2, (3) = 2, (4) = 3, (5) = 3, (6) = 4, (7) = 3, (8) = 3, (9) = 2, (10) = 2})

p4:=proc(p) local i,s:=sprintf("%d",p); Array([seq(s[i],i=1..length(s))]) end proc:

a4:=CodeTools:-Usage(p4(p),iterations=10^6);

memory used=0.79KiB, alloc change=0 bytes, cpu time=5.88us, real time=5.53us, gc time=7.0e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p5:=proc(p) local i,s:=sprintf("%d",p); Array(1..length(s),i->s[i]) end proc:

a5:=CodeTools:-Usage(p5(p),iterations=10^6);

memory used=0.90KiB, alloc change=0 bytes, cpu time=7.48us, real time=7.04us, gc time=9.2e+02ns

Vector[row](10, {(1) = "2", (2) = "2", (3) = "3", (4) = "3", (5) = "4", (6) = "3", (7) = "3", (8) = "2", (9) = "2", (10) = "2"})

p6:=proc(p) Array(convert(sprintf("%d",p),'bytes')) end proc:

a6:=CodeTools:-Usage(p6(p),iterations=10^6);

memory used=504 bytes, alloc change=0 bytes, cpu time=3.52us, real time=3.26us, gc time=5.3e+02ns

Vector[row](10, {(1) = 50, (2) = 50, (3) = 51, (4) = 51, (5) = 52, (6) = 51, (7) = 51, (8) = 50, (9) = 50, (10) = 50})

p7:=proc(p); kernelopts(opaquemodules=false); Array([`convert/base`:-MakeSplit(length(p), 1, 10)(p)]) end proc:

a7:=CodeTools:-Usage(p7(p),iterations=10^6);

memory used=0.83KiB, alloc change=0 bytes, cpu time=7.95us, real time=7.16us, gc time=1.67us

Vector[row](10, {(1) = 2, (2) = 2, (3) = 2, (4) = 3, (5) = 3, (6) = 4, (7) = 3, (8) = 3, (9) = 2, (10) = 2})

NULL

 

Download DigitsToArray.mw

@2cUniverse You cannot export a plot structure to a .tiff file. But you can convert it to an Image and then use ImageTools:-Write to write the file - see the code I provided above.

@Scot Gould I used the term "copy contents". The Vector has to be pre-existing; in your example z was not predined as a vector, and by default was a table. copy(v) does copy the vector and is fine at the top level, but within the OPs procedure prev:=copy(curr) still has the problem of assigning to a formal parameter.

@2cUniverse You can convert a plot directly to an Image without writing it to a file, so I think the following does what you want. I made the white background in the plot structure but if you prefer you can add it with PadImage after converting.

restart;

Make some square plot structure with white frame

sq:=plottools:-rectangle([-1,-1],[1,1],color=red):
lbl:=plots:-textplot([0,0,"HELLO"]):
whitebg:=plottools:-rectangle([-1.1,-1.1],[1.1,1.1],color=white):
plt:=plots:-display([sq,whitebg,lbl],axes=none,scaling=constrained,size=[500,500]):

Convert plot structure to image and output as .tiff

img:=convert(plt,Image):

ImageTools:-Write("C:/Users/dharr/Desktop/plt.tiff",img);

9510

NULL

Download maketiff.mw

@2cUniverse You can output plots to .gif or .jpeg or .png or  some other image formats (not .tiff). You can set the directory to anything you like for example

path:="C:/Users/dharr/Desktop";
filnam:=cat(path,"/plt",i,".gif");

and omit the base=option if using Export.

@2cUniverse I didn't understand your resolution comments. You could add the white frame as a rectangle behind all elements before exporting the plot in whatever format you want at whatever resolution you want (or as svg or eps vector graphics to later convert to tiff)

Edit: Following makes a square SVG with a white frame.

restart;

Make some square svg files with white frame

for i to 3 do
  sq:=plottools:-rectangle([-1,-1],[1,1],color=red);
  lbl:=plots:-textplot([0,0,convert(i,string)]);
  whitebg:=plottools:-rectangle([-1.1,-1.1],[1.1,1.1],color=white);
  plt:=plots:-display([sq,whitebg,lbl],axes=none,scaling=constrained,size=[0.5,"square"]);
  Export(cat("plt",i,".svg"),plt,base=worksheetdir,format="SVG");
  #print(plt);
end do:

NULL

Download makesvg.mw

@2cUniverse I can't access your zip file. But here is how to make square format .png files (I used Export) - note the size option to give the number of pixels.

restart;

Make some png files

for i to 3 do
  sq:=plottools:-rectangle([-1,-1],[1,1],color=red);
  lbl:=plots:-textplot([0,0,convert(i,string)]);
  Export(cat("plt",i,".png"),plots:-display(sq,lbl,axes=none,scaling=constrained,size=[500,500]),base=worksheetdir);
end do:

NULL

Download makepng.mw

First 41 42 43 44 45 46 47 Last Page 43 of 89