acer

22182 Reputation

29 Badges

15 years, 230 days

Social Networks and Content at Maplesoft.com

"My friend George Mallory… once did an inexplicable climb on Snowdon. He had left his pipe on a ledge, half-way down one of the Liwedd precipices, and scrambled back by a short cut to retrieve it, then up again by the same route. No one saw what route he took, but when they came to examine it the next day for official record, they found an overhang nearly all the way. By a rule of the Climbers' Club, climbs are never named in honour of their inventors, but only describe natural features. An exception was made here. The climb was recorded as follows: 'Mallory's Pipe, a variation on route 2; see adjoining map. This climb is totally impossible. It has been performed once, in failing light, by Mr G. H. L. Mallory.'." -- "Goodbye to All That", Robert Graves

MaplePrimes Activity


These are answers submitted by acer

The ImageTools:-PlotHistogram command allows for a line or a point plot.

You can do a similar thing, with bars, using the Statistics:-Histogram command.

PlotHistogram.mw

Here are two examples, for N=16 and N=128 buckets. These overlay the results from both commands, with a few options adjust to get the points to align with the horizontal midpoints of the bars. (See also their Help pages.)

You can experiment. I believe that you'll find that, as the number of bars gets high there are visual abberations as the sides of the bars get very close (eg. Moire, etc). That happens even with thickness=0 to make the bar's side lines thinner. That's one reason why ImageTools:-PlotHistogram shows only the midpoints (connected via lines, or as separated points) and not the actual bars.

You could also add the style=polygon option to the call to the Statistics:-Histogram command. That suppresses the inner lines between the bars, giving the effect of a solid filled region. Similarly you could pass the option filled to the ImageTools:-PlotHistogram command.

FYI, thickness=0 doesn't produce the thinnest line possible in the Maple 17 GUI. Using N=256 bins you can also try this kind of thing, where Lena is the 2D Array of your imported grayscale image.

N:=256;
P2:=Statistics:-Histogram(convert(Lena,Vector),
                          bincount=N, color="Azure",
                          frequencyscale=absolute,
                          thickness=0):
RR:=[min,max](map(x->map[2](op,1,x), [op([1,..-2],P2)])):

P1:=ImageTools:-PlotHistogram(Lena, N, range=RR[1]..RR[2],
                              thickness=0):

plots:-display(P2, P1);
P1b:=subsindets(P1,specfunc(anything,THICKNESS),u->THICKNESS(0.01)):
P2b:=subsindets(P2,specfunc(anything,THICKNESS),u->THICKNESS(0.01)):

plots:-display(P2b, P1b);

 

What version of Maple, and what platform Operating System, are you using.

With Maple 2020.1 on Linux I get them different font specifics if not preceded immediately by a newline character (or possibly another special symbol?).

Omega_printf.mw

By the way, I used "Ω" instead of your "#937".

The following seems to work in Maple 2019.2, if the conversion to exp is ok.

simplify(int(factor(expand(convert(v, exp))), x));

Help_1_ac_2019.mw

Are you trying to upload and use a MapleCloud application document with embedded components and code behind them, which (via libname) directly and automatically utilizes some of user-defined procedures/packages stored within an .mla file? That is how your Question reads, to me.

A usual way to do such, in a modest scale, would be to have the user-defined code be in the Startup Code of the application .mw file uploaded to the cloud site. (A similar idea is to use a Code Edit Region marked as auto-execute.) If the amount of user-defined code is large and unwieldy, or if you only have someone else's .mla file but not the source code text, then this idea can become problematic.

It might be possible to utilize a .maple workbook rather than a .mw worksheet/document, and have the user-defined procedures be stored in the workbook. But I am not sure whether this is practical, in terms of automated usability as the application running as a single standalone entry point on the MapleCloud.

[edit] It is possible to upload a .mla file inside a cloud package, which the end-user can download or install locally. That would allow them to run your application locally in Maple or the MaplePlayer on the local machine, and have it pick up the .mla's contents. But this does not provide a way for the end-user to utilize the application on the MapleCloud site itself and have that pick up and use the .mla's contents. 

If you haven't programmatically removed components via the "replaceable content" mechanism for a Task region then it's also a rather weird and unusualy thing to to -- in that case likely indicating inadequate bookkeeping during creation of components.

Here is one way, using the idea (which I suspect is correct) that all Embedded Components have the visible property.

ExistsEC:=proc(EC::{name,string})
  try
    DocumentTools:-GetProperty(EC, ':-visible');
    true;
  catch "Attempted to retrieve property of unknown component":
    false;
  end try;
end proc:

ExistsEC_example.mw

Here is another, less efficient, way. It is possible to get all the string identities of components in the current Worksheet/Document, but it is not an efficient thing to do.

For example,

raw := :-Worksheet:-FromString(streamcall(INTERFACE_WORKSHEET("extract"))):
CBs := select(x->member(_XML_ElementType("EC-ComboBox"),[op(x)]),
              indets(raw,'specfunc(_XML_Element)')):
map(x->map(xxx->op(1,indets(xxx,'specfunc(_XML_AttrValue)')[-1]),
           select(xx->member(_XML_AttrName("id"),[op(xx)])
                      and indets(xx,'specfunc(_XML_AttrValue)')<>{},
                  indets(x,'specfunc(_XML_Attribute)'))), CBs);

EC_query.mw

You could then programmatically test for membership in that set of all existing components of the given kind.

There is no mechanism for getting such context-menu direct changes (to the displayed plot) to be stored/saved as a plotting command.

That is one of the reasons why such context-menu changes to plots are not very useful. The corresponding command cannot be obtained directly.

If you are interested in discovering the plotting command and options for a particular look&feel you might try using the PlotBuilder instead. It lets you adjust properties and options in the context-panel, and has a button to reveal the equivalent plotting command.

You can invoke it either as the command  PlotBuilder(x^2)  or by choosing the  PlotBuilder  item from the panel context-menu shown when the focus is on  x^2  as output or 2D Input.

One way is to do these assignments, initallly:

kappa:=Typesetting:-mo("kappa", "italic"="true"):
phi:=Typesetting:-mo("phi", "italic"="true"):

That causes evaluated instances of names phi and kappa to pretty-print in output as that text form, in italics, similarly as for other regular names like x, t, F, etc.

You could also do it as,

kappa:=Typesetting:-mo("kappa", "italic"="true", "color"="Black"):
phi:=Typesetting:-mo("phi", "italic"="true", "color"="Black"):

A broader change is to execute the following command (but not in the same paragraph or execution group as restart).

interface(prettyprint=1):

That makes all output render in plain text. That handles all the Greek letters, etc, at once. But it also affects how other things like a Matrix or a piecewise are pretty-printed (more crudely). You might find this change too heavy-handed. The default for the GUI is prettyprint=3.  This can also be changed using the menubar item Tools->Options->Display->"Output display" and its choice "Character Notation", where the default is "2-D Math Notation".

@mmcdara As I mentioned before, there is usually no need to explicitly declare a variable as global at the top level, in order to use it on the left hand side of an assignment statement.

There doesn't seem (as yet) to be any reason given why you cannot do it similarly to this:

restart;
x:=0:

f := proc() 
  global x: 
  x:=x+1: 
end proc:

f()
                 1

In other words: like so,

restart:
# reading of some data files
:
:
# reshaping of the data
:
:
:

Main := proc()  # how I badly wrote this line was confusing in my previous reply
global G:
:
M := Maplet(......)
:
:
Display(M)
end proc:

G:=[ ]:
Main():

I asked earlier whether that kind of thing works in your Maple 2015, ie. whether the explicit top level global declaration of G were somehow required there.

What is the reason that you did the global declaration explicitly in Maple 2015? I'll repeat my very first query: What effect do you think it had?

If you do  lprint(eval(Bb,1))  then do you see integer values or merely unevaluated function calls to LArip? (You can try that for a small value of n, as a quicker test.)

So, is it fast because the actual work is not being done under the Grid:-Map calls, but only when you subsequently evaluate Bb? If so then the computational effort is not what is parallelized.

You might have noticed this even when testing smaller value of n if the output were not suppressed by terminating statements with full colons.

By using  Grid:-Set(LArip)  I can see actual improvement in the timing, because then your LArip procedure is actually called and computes withing the Grid:-Map.

I made another edit so that the values of r and M were accessible to LArip on each node.

If I force numcpus=2 at the start of the worksheet then for n=8 I get a real time elapsed of 43sec, while with numcpus=4 at the start then (after restart) I get a real time elapsed of 24sec.

Magma_GridMap_acc.mw

(Does it make sense to also give datatype=float[4] to the local A inside LArip?)

eval~(z,[rootsq0]);

If you plan on re-using the approach then you could make it into a (more conveniently re-usable) procedure.

I have a slight preference for adding the LEGEND call to the POLYGONS substructure's operands, rather than relying on that having a COLOUR substructure.

Also, even for your original you could get by with subsindets/evalindets directly on HS and HT, and save the actions both of putting their operands into lists and then making PLOT calls to bundle it back together.

For example,

with(plots): with(Statistics):
S := Sample(Normal(0, 1), 1000): T := Sample(Normal(1, 1), 1000):
HS := Histogram(S, color=gold, transparency=0.3):
HT := Histogram(T, transparency=0.3):
F := (P,L)->subsindets(P,specfunc(POLYGONS),p->POLYGONS(op(p),LEGEND(L))):
display(F(HS,"N(0,1)"),F(HT,"N(1,1)"));

[edit] I have removed something incorrect that I wrote about overrideoption not being relevant here. I apologize. The following works in Maple 2020 (and Maple 2017.2, but not 2016.2 or your Maple 2015.2).

with(plots): with(Statistics):
S := Sample(Normal(0, 1), 1000): T := Sample(Normal(1, 1), 1000):
HS := Histogram(S, color=gold, transparency=0.3):
HT := Histogram(T, transparency=0.3):
display(display(HS, legend="N(0,1)", overrideoptions),
        display(HT, legend="N(1,1)", overrideoptions));

But I'll also mention that in Maple 2017.2 (and onwards) the Histogram command accepts and makes use of the legend option. So this works directly,

display(Histogram(S, color=gold, transparency=0.3, legend="N(0,1)"),
        Histogram(T, transparency=0.3, legend="N(1,1)"));

You can make print_table a keyword parameter (option).

Specifying that procedure parameter as {print_table::=truefalse:=false} means that it's default value is false. You can then pass either print_table=true or just print_table to see it work.

You can also omit it in the call, in which case it takes on its default value.

integ_R_ac.mw

This example can be dealt with using overrideoption .

restart:
with(Statistics):
data:=Vector[row]([2,5.3,4.6,.88,2.5,5.9,5,10,1.7,7.8,7.2,
                   9.42,9.01,3.42,4,11.59,8,10.3,1.5,8.5,11.4]):
a:=SunflowerPlot(data,length=4,size=[600,200],color=red):
plots:-display(a,color=red,overrideoption);

SunflowerPlot(data,length=4,size=[600,200],color=red,overrideoption);

overrideoption.mw

restart;
y:=t->808.2213240*(1 - 0.63*(1993551437/1601983488 - sqrt(3)/2)^0.3)
      *(1 - 335345*(45188/147189 - 53/(4820*ln(2)))
            *335345^(131537/203808)*131537^(72271/203808)
            *(1 - 1/(1 + (203808*exp(-677.0138344*t))/131537)^(131537/203808))
            /34603964738):

fsolve(y-196.9594856);

          -0.002844711966

fsolve(y(t)-196.9594856,t);

          -0.002844711966

plot(y-196.9594856, -1e-2..1e-2);

fsolve_examp.mw

Your query is unclear: is your problem that you cannot do multiple (separate) plots, or arrays of plots, or that they appear only after all usual output, or all of the above, oder...?

You can use the plots:-display command to assemble Arrays of plots that print in a GUI table. You can use the print command to get single (or Arrays) of plots interleaved with regular output. 

 

4 5 6 7 8 9 10 Last Page 6 of 247