Joe Riel

9575 Reputation

23 Badges

19 years, 52 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@AmirHosein Sadeghimanesh Either works.  The second call returns false because you used test2, not test.

@Carl Love Thanks, makes sense.  A partial workaround would be to do

M := MutableSet(...):
andseq(m :: sometype, m = M);

 

Could you enter an example that generates the error.   The following works as expected
 

M := MutableSet(a,b,c):
type(M, 'MutableSet');  
                                                 true

 

@Rouben Rostamian  I may have not pushed a current version in awhile.  It's supposed to install an examples subdirectory. Will look into that tonight.

Answers

1. Typically you execute the shell script from a shell.  The example shown in the help page undoubtedly causes some confusion (there the Maple command Bark:-ShellCmd is used to execute the command because Maple help pages typically only show Maple commands).

2. The shell script is not self-contained.  It requires Maple.  The Bark:-CreateScript command creates two files: the shell script, which is small (5 lines) and an mla which the script uses.

3. The purpose is to allow doing a particular task from the O/S command line, using Maple.  For example, one of the tools I created with it will print embedded components of a selected type (Button, ComboBox, etc), with all or selected attributes (id, caption, code, etc) of a given Maple worksheet.  It also allows modifying selected attributes.  Mainly I use it for tools I use at work.   Before creating Bark, I would typically create a bash script that processed the arguments then called Maple.  Now I can write everything in Maple, which I prefer.

Update

There appeared to be a bug in Bark:-InstallExamples, which you should normally call from the Bark intro page when installing the package.  I've uploaded a revised version.  It includes three examples: hello, mhelp (for creating a help database from mw files), and checkmo (useful with MapleSim for checking/listing/printing the content of MapleSim modelica libraries).

These are all excellent suggestions, though not sure about 3. Say the components were arranged with flow from left to right.  To flip horizontally each component would be horizontally flipped (locally) and also the left-most would be swapped with the right-most, etc.  An interesting conceptual way to accomplish this, without a specific GUI operation, would be to combine the components into a subsystem, then flip its block and then apply your proposed undo subsystem operation (5).  

@nm copy(old_object) calls Object(old_object), so if the ModuleConstructor requires additional parameter, you'll have to use the second version.  If no additional parameters are needed, then either works and the direct call to Object avoids some negligible overhead.

Note that if the additional arguments will be assigned fields of the object, which is frequently the case, then you can make them optional in the following manner.
 

person := module()
option object;
local name :: string := "";
    
export
    ModuleCopy :: static := proc( self :: person
                                  , proto :: person
                                  , name :: string := proto:-name
                                );
        self:-name := name;
    end proc;
    
export
    GetName :: static := proc( _self )
        name;
    end proc;
    
end module:

p1 := Object(person,"me");

p2 := Object(p1);
GetName(p2);   # returns me

Doing so causes the new object to have the same values as the copied object, as shown above.

@nm The proper way, as I believe you figured out, is to use the Object procedure to copy an object.  Using copy(obj) already does that (invokes Object(obj)), but fails if the deep option is passed.

@nm In your second example, there is nothing special about the use of _self; you can replace it with, say, self, and it behaves the same.

My hand-waving as to why the failure occurred is presumably inaccurate. However, consider the following method added to your object:

export foo :: static := proc(_self)
    proc(self :: person) self:-age end proc(_self);
end proc;

That raises more-or-less the same error when the object class is created.  The anonymous procedure is not a local/export of the object and so has no access to the objects locals.  Maybe it should, but currently Maple's objects don't work like.  On the other hand, that isn't consistent with your use of overload (where the overloaded procedures can access the object locals).  My speculation is that overload has not yet been extended to handle the special case of the _self formal parameter.

@Carl Love A reasonable point. I speculate that it came about because the special nature of _self was introduced after objects.  That may also be why it is best used without a type declaration, that is, if _self as a formal parameter is given a type declaration it then behaves like an ordinary parameter.

@dharr A more efficient way to sort is to use the 'key' option:

sort(vecs, 'key' = (v -> LinearAlgebra:-Norm(v,2))):

That way the key (norm, in this case) is only computed once for each vector.

@Ash Niazi What commands did you execute?  Describing or uploading what you have done or want to do would be helpful.  It's not clear what you mean by "solving a State Space".

@maple_linux Apologies for the delay, didn't see your response until now.  The better way to handle this is with the Maple mint utility.  It can be invoked as a standalone procedure or via the maplemint procedure.  Note that because maplemint processes an assigned Maple procedure, rather than the text that defines the procedure, its reporting of implicitly declared variables is not as nice as mint's.

Using the following modification to your example

test_2 := proc()
    y1 := sin(x1);
    y2 := cos(z1) + z2^2;
    plot(y1, x1=1..2, color = "red");
end proc:

mint reports

Procedure test_2() on lines 1 to 5
  These names were used as global names but were not declared:  color, x1, z1, 
      z2
  These local variables were assigned a value, but otherwise unused:  y2
  These local variables were not declared explicitly:  y1, y2

while maplemint prints

maplemint(test_2);

Warning, (in test_2) `y1` is implicitly declared local
Warning, (in test_2) `y2` is implicitly declared local
Procedure test_2() 
  These names were used as global names but were not declared:  color, x1, z1, 
      z2
  These local variables were assigned a value, but otherwise unused:  y2

 

@mgmcderm Thanks for posting the worksheet, that is helpful.  A few comments.

Syrup actually solves the symbolic case, but doesn't recognize the solution as valid because it is in an unexpected form, a piecewise.  I'll fix that.  However, the solution is not particularly useful. 

You can pass the dontsolve option to Syrup:-Solve; it then returns a list of two sets: the equations and the solving variables. Those can then be manipulated as you wish. 

(eqs,vars) := op(Syrup:-solve(ckt, 'ac', 'dontsolve', 'symbolic'):
solve(eqs, vars) assuming R1 > 0;    # example

Passing them directly to Maple's solve procedure, maybe with additional assumptions may be useful.  For example, using assuming R1 > 0 removes one of the branches.  By using dontsolve you can enter placeholders in component values, then make any desired substitutions after extracting the equations and variables.

Am surprised that using ifelse in the value of the current source worked; Maple generally prefers piecewise, but in this case that returns no solution.

A refactoring of the expression yields results.  Change ifelse(v[2]>Vclamp,(v[2]-Vclamp)/Rclamp+ileak,ileak) to the equivalent max(v[2]-VClamp,0)/RClamp + ileak, then passing the symbolic option returns a result (multiple solutions).

Note that using conditionals dependent on circuit values with an ac analysis doesn't necessarily make sense; the ac analysis assumes linearity which may be violated by the conditions.

From the help page for coeffs:
Note that p must be collected (collect) with respect to the appropriate indeterminates.  For multivariate polynomials, you may need to use collect with `distributed`.

@Thomas Dean Note also,
 

(**) plot(sin);
Error, plot driver not found
(**) restart;
(**) plot(sin);
plotting was not implemented by the application

What would you like it to do?  Essentially what  command-line Maple does in an xterm, that is, pop open a plot window with the displayed plot?

3 4 5 6 7 8 9 Last Page 5 of 195