acer

32313 Reputation

29 Badges

19 years, 312 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@nm No, your original Question did not explicitly state your wanting "sub modules", or "at any level". It is disingenuous to now claim that it did.

In your example you apparently already know that a module assigned to name A has been stored in the .mla archive file. Since you've asked, the purpose of the code I showed (which does actually answer the code you actually asked) is to programmatically generate such (module assigned) names stored directly in the archive.

I did in fact answer the question literally asked, and I provided the explicit, complete code that I used and which worked, with code that works properly unless invalidly changed. I find your followup sentences like,
  "Did you actually try it your self or is it something you think should work?"
  "Explicit is always better than implicit."
  "If you did actually try, it would be easier to show the exact commands you typed instead of having one guess."
to be inappropriate and aggressive. I doubt that I'll be writing code that recurses into found modules, an easy 2-line modification of my Answer to your previous Question thread.

Here's your original Question. I don't see anything in it related to "sub modules", or "at any level", which is why I first brought that aspect up, in my response. A submodule that is merely a member of a module stored in a .mla archive is not itself directly stored at the top of that .mla archive, ie. in the sense that ShowContents utilizes.

You've since claimed, "I said I wanted same list showed by LibraryTools:-Browse("..../my_file.mla") and that includes all modules (at any level). Top and sub modules." But there is no mention of "at any level" or "sub modules" in your original. Here is the original:

I can't figure how to obtain list of all modules inside my .mla file.

I can see all the modules using the command LibraryTools:-Browse("..../my_file.mla") then clicking EDIT then VIEW option at top right corner.  Member type is automatically set to MODULE in the lower left corner. So I can see the names of all the modules. And using the slider, I can scrol down. I see 73 modules listed.

But I want to do this in code. Not using GUI.

I tried the command

          L:=LibraryTools:-ShowContents(my_file.mla):

And this gives L of lenght 15805. Looking at each entry in the above list, it shows things I do not understand and I do not want. It has names in there which I do not know where these came from.

There does not seem to be an option in LibraryTools:-ShowContents() to only return the names of the modules inside .mla. At least I can't find such option.

reference Maple help page

Any idea how to do this in code? Not using the maplet? 

Maple 2022 on windows 10

ps. I know I can use the GUI and do EXTRACT to save the list to a file. But this is not good solution. I need the list of names of the modules be in a list so I can do this all in a function with no manual steps.

 

ps. If you're bothered about mistakenly passing an assigned module name to ShowContents, rather than a .mla library archive file name (as I used, and its documentation describes), then please don't take it out on me.

@nm Of course I tried the code that I wrote. The code I put in my answer is exactly what I tried. It worked. I don't know quite what to make of your followup request that I show the actual code I used, since I already have done so.

You have not assigned to L in any way even close to what I wrote.

I wrote about passing one of the library file names in libname to LibraryTools:-ShowContents. That is, the name (string) of an .mla archive file. But, very differently, you appear to be passing the name of some module (in your session) to LibraryTools:-ShowContents. That's not what I suggested.

I had an example in which L was one of the items in libname. That means that L was assigned a string. In my case I was using,

   L := [libname][1];
             L := "/usr/local/maple/maple2022.2/lib"

If instead I use any of the other .mla file names in libname, then those work perfectly fine as well, showing different results, of course.

But here are the commands you used to assign to L. It does something completely different and is not at all what I described. You pass the name of some module, A, to LibraryTools:-ShowContents.

   currentdir("C:/tmp/"):
   libname := "C:/tmp/my_library.mla",libname:
   exports(A);
                             B,C
   L := A;
                            L := A

That's why it doesn't work for you.

Also, in your original Question you wrote that you want the names of the modules in the library archive. And my Answer shows how that literal request can be accomplished. You didn't write up front that you wanted the names of submodules of such stored modules in the archive (and any further recursion of membership). To get that you could write short code to recursively test using op(3,...) of found modules, a modification of my answer to your previous Question.

@nm You need L to be the (string) name of the library archive file that you want to examine.

I only used libname[1] as an example.

@nm I mistakenly used m:-_pexports, where I ought to have used exports(m) . Sorry. I copy&pasted the wrong version from that older Answer of mine.

Does this do better?

H := proc(m::`module`) local res;
  local oldOM := kernelopts(':-opaquemodules'=false);
  try
    res := select(p->type(m[p],procedure),
                  [exports(m)[],op(3,eval(m))]);
  catch:
    res := [];
  finally
    kernelopts(':-opaquemodules'=oldOM);
  end try;
  res;
end proc:

If you already have kernelopts(opaquemodules=false) , so as to be able to trace the local procedures, then the short form of my code would be,

select(p->type(m[p],procedure),
       [exports(m)[],op(3,eval(m))]);

@NanaP Please do not spawn another, wholly separate Question thread on this TriangularTypeII procedure or re-parametrizing a triangular distribution.

It's not clear what you want.

Do you hope to substitute numeric values of t for the unknown variable a inside the Matrix?

What do you want the plot of a single instance (single numeric value) of t to look like?

@Rouben Rostamian  The OP's attachment was last saved in Maple 2021.

If I run your worksheet in Maple 2021.2 then it throws an error when forming Matrix assigned to IC.

But it succeeds if I first do,
   with(Physics):
at the start of the worksheet.

@Aung Please don't start additional (duplicate) Question threads for this.

@sursumCorda The different qualities of data structures can lend them to different kinds of good use.

For example, use of a list has been highly optimized within the Maple kernel/engine, in terms of memory management, especially for lightweight creation at small sizes. But it's not actually a mutable data structure and should not be used as such.

As an indexable, mutable data structure that can store numeric data in contiguous memory blocks (and thus allow no-copy transfer to externally linked code) the rtable (Matrix/Vector/Array) is great. It has "growable" functionality, but not in the same class as the mutable table hashed data structure.

The uniquification functionality of the set is also tuned.

These different data structures provide quite different functionality benefits, and suitability for different kinds of task. Unfortunately, I'm not aware of any good book or documentation chapter which focuses primarily on this through close explanation accompanied by example.

One of the few logical duplications is the (lowercase) table-based matrix & vector. The last-name-evaluation allowed for in-place (no copy) semantics when being passed as argument in a procedure call. The overlap with more modern Matrix/Vector is less evident, due to deprecation.

ps. There are several other additional data structures available for use in Maple. I just wanted to mention these basic & commonly used ones, to help illustrate a point.

ps. Mma also has more than one flavour of data structure. It's packed array shares some qualities with Maple's rtable, allowing for no-copy access by external functions. But it too has some optimal use-cases that are non-trivial in general, eg. use of ToPackackedArray, NumericArray. In fact Mathematica has many flavours of data structure, and knowing which to use optimally, and how, is also complicated.

@Anthrazit We all have such moments, now and then.

@Danish Toheed I asked whether your NM procedure can actually do root-finding sucessfully because it's not clear to me that it has been correctly implemented.

If there are no starting values (ie, x0) for which it converges to the roots (say, when the funciton is x^3-1) then won't it be problematic to try and use it for computing basins of attraction?

Please consider that an addition to my previously list of queries above. In my opinion those are still germane to the goal of plotting basins of attraction.

@Danish Toheed Can you demonstrate that your NM procedure can actually be used to return approximations of the three complex roots of k^3-1 ?

Please don't start a duplicate Question thread for this.

If you have revisions to your code you can attach them in Replies here.

@Danish Toheed You've repeated much of the information you had previously given, but you haven't answered my queries, and you haven't added the missing, crucial, details. Your latest Reply hasn't really provided additional information.

You may have noticed that your iterated augmentation of sol_coordinates is muddled up and not working properly. Your code has an outer loop, (for i from 1 to nIteration do...). Now, I don't think that you understand what I meant before by "inner loop". There is an inner loop, in the lines,
   sols := [op(sol_coordinates), x];
   for sol in sols do
      sol_coordinates := [op(sol_coordinates), [sol, 0]];
   end do;

And it's not clear what you're hoping that inner loop would accomplish. It seems its purpose is to form the final numeric point data for the plot. But, as written, it's creating a muddled structure rather than well structured actual numeric data points (eg. a list of lists of numeric pairs). In order to fix it, we should be told the exact goal for it. Your code has no comments that might make the intended structure clear. 

You use the plot command, which is for 2D plots. So, what do you intend that the horizontal/vertical data pairs will represent, at each plotted point -- if constructing sol_coordinates were actually successful?

For example, are the horiz/vertical point pairs just going to be the i and x values in the outer loop?  If so, then why did you you write the inner loop?! What do you think that your inner loop would do?

Also, your code appears to use a single intial value, x0, and then iterate. How would using a single initial value be a way to construct a plot of a basin of attraction?

Moving on... are you trying to make Newton's method work in the complex plane? It seems so, to me, judging by your phrase, "rectangle D ∈ C of size [−2, 2] × [−2, 2]". But I don't see that in your code, or your choice initial point x0, or your attempt at assembling data from the iterations, etc. Please clarify.

ps. Why differentiate to obtain the expression assigned to df, if it's not going to be used?

I'm afraid that if you cannot answer these queries I would not be able to help you.

@Saha Duplicate queries against this example/problem will be flagged as such, and may be deleted.

First 68 69 70 71 72 73 74 Last Page 70 of 591