Joe Riel

9380 Reputation

23 Badges

17 years, 313 days

MaplePrimes Activity

These are replies submitted by Joe Riel

A  problem is the omitted multiplication signs. You should use

   v1 := sin(c)*sin(a)*(a-b);
   v2 := sin(c1)*sin(a1)*(-a+b)

x := 0:
to 10 do
    x += 0.1;  # equivalent to x := x+0.1;
end do:

@nicolesharp100 Interesting idea (tagging).

@Vector For me, the calls FindLonLat returned nothing.  On debugging them, the record returned by a call to JSON:-ParseFile contains:

error_message = "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to",

Please upload the msim file.  Use the green-uparrow at this site when responding.

I don't understand.  What do you mean by "proper form"?

@emendes It isn't needed here because coefmodel is also an argument of CleanExpr, that is, coefmodel is passed to CleanExpr in the call to Grid:-Seq.  It would be possible to remove it as an argument, then you would have to use Grid:-Set to make it known to the various kernels. 

@Carl Love I could not recall the Statistics:-Tally function and searching for it was hopeless---best I could think of was the more or less equivalent StringTools:-CharacterFrequencies, but the usage is all wrong.  Was hesistant to extend to other than symbols because am not sure about the interpretation of, say, [a, -a].

@acer The use of print came directly from the original:

(**) showstat(WARNING);

WARNING := proc(msg)
   1   if not _Env_hide_warnings = true then
   2       print(INTERFACE_WARN(1,msg,_passed[2 .. -1]))
       end if
end proc

The environment variable is relatively new (added a couple years ago); useful to know about.
Here's an updated version of the module that fixes a few bugs (thanks) and adds a clear option to Caught to clear a warning once it has been noted.

Warnings := module()
option package;

local catchall, formats, warnings;

    Catch := proc(fmts? :: seq(string), { all :: truefalse := false })
        if all then
            catchall := true;
            formats := [fmts?];
        end if;
    end proc;

    ModuleLoad := proc()
    global WARNING;
        WARNING := proc(fmt)
            if catchall or Match(fmt) then
                warnings[fmt] := StringTools:-FormatMessage(fmt, _rest);
            end if;
        end proc;
    end proc;

    Display := proc()
    local msg;
        for msg in [entries(warnings,'nolist')] do
            printf("%s\n", msg);
        end do;
    end proc;

    Caught := proc(fmt :: string, { clear :: truefalse := false } )
        for f in [indices(warnings,'nolist')] do
            if SearchText(fmt,f)=1 then
                if clear then
                    warnings[f] := evaln(warnings[f]);
                end if;
                return true;
            end if;
        end do;
        return false;
    end proc;

    Match := proc(fmt)
        ormap(f -> SearchText(f, fmt)=1, formats);
    end proc;

    Clear := proc()
        catchall := false;
        warnings := table();
        formats := [];
    end proc:

    ModuleUnload := proc()
        kernelopts('unread' = ':-WARNING');
    end proc;


end module:


@PaulNewton A colon suppresses output only if it terminates a top-level statement; colons that terminate (technically separate) substatements of a structured statement have no effect on whether output is generated.

@PaulNewton For an Excel spreadsheet you should be able to use the ImportMatrix command to assign the data to a Maple matrix.  Here I'll manually assign the data to avoid creating a spreadsheet:

# M := ImportMatrix("acid-data.xls"); 
M := Matrix([["acetic acid", 1.75e-5], ["ammonia", 5.70e-10], ["benzoic acid", 6.28e-5]]):
# create list of strings
L := [seq(sprintf("%s (%g)", M[i,1], M[i,2]), i = 1 .. upperbound(M,1))]:
# insert list into combobox (previously inserted into worksheet)
DocumentTools:-SetProperty("ComboBox0", 'itemList', L);

To do something with a selection you can either parse the selected string, or probably simpler and better, use DocumentTools:-GetProperty("ComboBox0", 'selectedindex') to return a 0-based index that you can then increment by one and use as a row index into the Matrix.

Is there a space between the $ifdef and the __FILE__?  The following worked for me.
File named FILE.mpl:

file := __FILE__:
$ifdef __FILE__

From O/S:

$ maple FILE.mpl
(**) file := "FILE.mpl":
(**) print(file);


I experimented with your example code and reproduced your results.  A little more experimentation suggests what is happening.  It seems as though __FILE__ is only defined when it is actually used in the file (other than in the condition of a preprocessor conditional).   So if you insert, say, # __FILE__ before the conditional that checks for it, then the observed output of a call to f is the desired
     "1", "2", "3", "4", "FILE.mpl"

@zenterix Here's what I do (I've written 100+ Maple packages, 75 of which are installed as personal toolboxes).  The source for each toolbox is kept in its own directory tree, under $HOME/maple; the actual location is not significant.  To create a new package, I do

$ cd ~/maple
$ cp -r clone Foo  # copy a custom source tree to Foo, the new package
$ tree Foo  # display the tree
├── bin
│   └── version
├── etc
│   └── MapleHelp_en.xml
├── Makefile
├── maple
│   ├── doc
│   │   └──
│   ├── include
│   │   ├── About.mi
│   │   ├── mpldoc_macros.mpi
│   │   ├── standard.mi
│   │   └── test_macros.mi
│   ├── installer
│   │   └── CreateInstaller.mpl
│   └── src
│       └── _PKG_.mpl
├── README.setup
└── sbin
    ├── release
    └── setup

8 directories, 15 files

$ cd Foo
$ sbin/setup 

The call to sbin/setup renames and edits some of the source files, expanding __PKG__ to Foo (based on the directory name).  It then creates a git repository.  At that point there is a file Foo/maple/src/Foo.mpl containing a skeleton of a Maple package assignment.   Executing make mla-install will build an mla from the source and install it to ~/maple/toolbox/Foo/lib/Foo.mla, from which Maple will automatically find it when it starts. The Makefile defines a number of useful targets:

$ make help
mla-version	Update maple/include/version.mi
mla		Create Maple archive: Foo.mla
mla-install	Install mla into /home/joe/maple/toolbox/Foo/lib
hlp-version	Update maple/include/version.mpi
hlp		Create Maple help database:
hlp-clean	Delete extracted help sources
hlp-install	Install in /home/joe/maple/toolbox/Foo/lib
book		Create Foo.maple
intro		Create Foo.intro
book-info-copy	Copy the saved cloud-info from to Foo.maple
book-install	Install package from the book
book-uninstall	Uninstall the book
book-info-save	Save the cloud-info from updated Foo.maple to
book-info-create	Create
tags		Create TAGS file
mint		Check Maple syntax
test		Extract and run test suite
test-clean	Delete extracted tests
test-extract	Extract test suite
test-run	Run test suite
install		Install everything
uninstall	Remove directory /home/joe/maple/toolbox/Foo
installer	Create Maple installer: Foo-1.0.0.mla
installer-zip	Create Maple installer zip file:
sweep		Remove editor temp files
clean		Remove built files and sweep
cleanall	Remove intermediate files

The actual Makefile for each project is small; it assigns a few variables and then includes a common Makefile that is used by all the projects:

$ cat Makefile
# Makefile - for Foo
# Maintainer: Joe Riel <>

PKG := Foo

VERSION := 1.0.0

# Assign executables
MAPLE  := $(MAPLE_ROOT)/bin/maple
MINT   := $(MAPLE_ROOT)/bin/smint
MPLDOC := $(MAPLE_ROOT)/bin/mpldoc

# Activate selected make sections
BOOK := true
TEST := true



For the second problem, there is a bug in the handling/conversion of the subcircuit definitions and nodes.  Should have a fix for it shortly. 

For the first am getting getting a different error, though am using an updated version of Syrup.  Will investigate.

@mmcdara I changed the repository to something suitable for my machine, then ran the script.  The result is what I warned about; the generated mla is not usable.  It does assign the package DesignOfExperiments, however, each of the exports is merely a stub.  To make this work you should add wrap each assignment in the module definition with an eval:

DesignOfExperiments := module()

 export  RunifFaure         := eval(:-RunifFaure)         ,
         FullFactDesign     := eval(:-FullFactDesign)     ,
         CenteredStarDesign := eval(:-CenteredStarDesign) ,
         UniformLHD         := eval(:-UniformLHD)         ,
         UniformLHS         := eval(:-UniformLHS)         ,
         UniformMC          := eval(:-UniformMC)          ,
         dmaxDesign         := eval(:-dmaxDesign)         ;

 option  package ; 

end module:

While that seems to work, I have doubts as to the viability of this method for a hierarchically designed package (i.e. one with submodules).  The robust way to do this is to use external source files, with include statements so that there is one top-level file that defines the module; it has include statements to pull in the procedure and submodule assignments (they can have includes to pull in subprocedures).  In your example, the top level file would look like

DesignOfExperiments := module()

option  package;
 export  RunifFaure,

$include <RunifFaure.mpl>
$include <FullFactDesign.mpl>
$include <CenteredStarDesign.mpl>
$include <UniformLHD.mpl>
$include <UniformLHS.mpl>
$include <UniformMC.mpl>
$include <dmaxDesig.mpl>

end module:

Each procedure would be assigned in its own file (FullFactDesign.mpl).  To build the mla you would use a shell command. To get this to work well, you need to build up a little infrastructure (I use a makefile, but a simple shell script will suffice).

There are several advantages to this approach:

  • Source code is isolated from changes to the Maple worksheet format
  • Source can be put under version control
  • Allows using programming editor of choice
  • Allows use of Maple's mint facility to check the syntax 
1 2 3 4 5 6 7 Last Page 1 of 193