How do I add and use packages in Maple?...

Currently working on Fourier series. Having trouble plotting the graph of the Fourier series and would love to add and use a package such as the one found here: https://www.maplesoft.com/applications/view.aspx?SID=4857 . I'm having trouble installing and using the package, though. Could anyone be so kind as to assist me in adding and using packages not already found in Maple?

ClusterAnalysis applications: Finding a Minimal...

by: Maple 2017

A project that I have been working on is adding some functionality for Cluster Analysis to Maple (a small part of a much bigger project to increase Maple’s toolkit for exploratory data mining and data analysis). The launch of the MapleCloud package manager gave me a way to share my code for the project as it evolves, providing others with some useful new tools and hopefully gathering feedback (and collaborators) along the way.

At this point, there aren’t a lot of commands in the ClusterAnalysis package, but I have already hit upon several interesting applications. For example, while working on a command for plotting clusters of points, one problem I encountered was how to draw the minimal volume enclosing ellipsoid around a group (or cluster) of points. After doing some research, I stumbled upon Khachiyan’s Algorithm, which related to solving linear programming problems with rational data. The math behind this is definitely interesting, but I’m not going to spend any time on it here. For further reading, you can explore the following:

Khachiyan’s Algorithm had previously been applied in some other languages, but to the best of my knowledge, did not have any Maple implementations. As such, the following code is an implementation of Khachiyan’s Algorithm in 2-D, which could be extended to N-dimensional space rather easily.

This routine accepts an Nx2 dataset and outputs either a plot of the minimum volume enclosing ellipsoid (MVEE) or a list of results as described in the details for the ‘output’ option below.

MVEE( X :: DataSet, optional arguments, additional arguments passed to the plotting command );

The optional arguments are as follows:

• tolerance : realcons;  specifies the convergence criterion
• maxiterations : posint; specifies the maximum number of iterations
• output : {identical(data,plot),list(identical(data,plot))}; specifies the output. If output includes plot, then a plot of the enclosing ellipsoid is returned. If output includes data, then the return includes is a list containing the matrix A, which defines the ellipsoid, the center of the ellipse, and the eigenvalues and eigenvectors that can be used to find the semi-axis coordinates and the angle of rotation, alpha, for the ellipse.
• filled : truefalse; specifies if the returned plot should be filled or not

Code:

#Minimum Volume Enclosing Ellipsoid
MVEE := proc(XY,
{tolerance::positive:= 1e-4}, #Convergence Criterion
{maxiterations::posint := 100},
{output::{identical(data,plot),list(identical(data,plot))} := data},
{filled::truefalse := false}
)

local alpha, evalues, evectors, i, l_error, ldata, ldataext, M, maxvalindex, n, ncols, nrows, p1, semiaxes, stepsize, U, U1, x, X, y;
local A, center, l_output; #Output

if hastype(output, 'list') then
l_output := output;
else
l_output := [output];
end if;

kernelopts(opaquemodules=false):

ldata := Statistics:-PreProcessData(XY, 2, 'copy');

nrows, ncols := upperbound(ldata);
ldataext := Matrix([ldata, Vector[column](nrows, ':-fill' = 1)], 'datatype = float');

if ncols <> 2 then
error "expected 2 columns of data, got %1", ncols;
end if;

l_error := 1;

U := Vector[column](1..nrows, 'fill' = 1/nrows);

##Khachiyan Algorithm##
for n to maxiterations while l_error >= tolerance do

X := LinearAlgebra:-Transpose(ldataext) . LinearAlgebra:-DiagonalMatrix(U) . ldataext;
M := LinearAlgebra:-Diagonal(ldataext . LinearAlgebra:-MatrixInverse(X) . LinearAlgebra:-Transpose(ldataext));
maxvalindex := max[index](map['evalhf', 'inplace'](abs, M));
stepsize := (M[maxvalindex] - ncols - 1)/((ncols + 1) * (M[maxvalindex] - 1));
U1 := (1 - stepsize) * U;
U1[maxvalindex] := U1[maxvalindex] + stepsize;
l_error := LinearAlgebra:-Norm(LinearAlgebra:-DiagonalMatrix(U1 - U));
U := U1;

end do;

A := (1/ncols) * LinearAlgebra:-MatrixInverse(LinearAlgebra:-Transpose(ldata) . LinearAlgebra:-DiagonalMatrix(U) . ldata - (LinearAlgebra:-Transpose(ldata) . U) . LinearAlgebra:-Transpose((LinearAlgebra:-Transpose(ldata) . U)));
center := LinearAlgebra:-Transpose(ldata) . U;
evalues, evectors := LinearAlgebra:-Eigenvectors(A);
evectors := evectors(.., sort[index](1 /~ (sqrt~(Re~(evalues))), `>`, ':-output' = ':-permutation'));
semiaxes := sort(1 /~ (sqrt~(Re~(evalues))), `>`);
alpha := arctan(Re(evectors[2,1]) / Re(evectors[1,1]));

if l_output = [':-data'] then
return A, center, evectors, evalues;
elif has( l_output, ':-plot' ) then
x := t -> center[1] + semiaxes[1] * cos(t) * cos(alpha) - semiaxes[2] * sin(t) * sin(alpha);
y := t -> center[2] + semiaxes[1] * cos(t) * sin(alpha) + semiaxes[2] * sin(t) * cos(alpha);
if filled then
p1 := plots:-display(subs(CURVES=POLYGONS, plot([x(t), y(t), t = 0..2*Pi], ':-transparency' = 0.95, _rest)));
else
p1 := plot([x(t), y(t), t = 0..2*Pi], _rest);
end if;
return p1, `if`( has(l_output, ':-data'), op([A, center, evectors, evalues]), NULL );
end if;

end proc:

You can run this as follows:

M:=Matrix(10,2,rand(0..3)):

plots:-display([MVEE(M,output=plot,filled,transparency=.3),
plots:-pointplot(M, symbol=solidcircle,symbolsize=15)],
size=[0.5,"golden"]);

As it stands, this is not an export from the “work in progress” ClusterAnalysis package – it’s actually just a local procedure used by the ClusterPlot command. However, it seemed like an interesting enough application that it deserved its own post (and potentially even some consideration for inclusion in some future more geometry-specific package). Here’s an example of how this routine is used from ClusterAnalysis:

with(ClusterAnalysis);

X := Import(FileTools:-JoinPath(["datasets/iris.csv"], base = datadir));

kmeans_results := KMeans(X[[`Sepal Length`, `Sepal Width`]],
clusters = 3, epsilon = 1.*10^(-7), initializationmethod = Forgy);

ClusterPlot(kmeans_results, style = ellipse);

The source code for this is stored on GitHub, here:

https://github.com/dskoog/Maple-ClusterAnalysis/blob/master/src/MVEE.mm

If you don’t have a copy of the ClusterAnalysis package, you can install it from the MapleCloud window, or by running:

PackageTools:-Install(5629844458045440);

How to make Danish letters work in MapleCloud pack...

I have a package of routines meant to help Danish highschool students use Maple. I would like to use MapleCloud to distribute this but have run into a major stumbling block:

While Maple is perfectly happy to use non-latin letters such as the Scandinavian letters æ, ø and å it seems that MapleCloud can't handle that. Specifically, strings containing such letters is displayed in garbled form (the non-latin letters are shows as squares), and symbolic names containing such characters seems not to be recognized. The latter problem in particular makes MapleCloud quite useless to me.

I have attached a simple workbook demonstrating the problems to this message.

The patch package project

Maple

Was just pondering this idea and posted this in the post topic for discussion.

Each Maple finished version of Maple may still have certain bugs that will not be updated for that version, so I am suggesting (I think anyone could implement it) that if there is a workaround, one could wrap it up in something I would call a patch package updateable by us users we could update here on mapleprimes.  It would be good for people who haven't upgraded or can't upgrade due to costs etc...

For example, there was recent issue with pdsolve that was fixed quite quickly in the seperate updateable Physics package.  Things could be done similarily that might work with other workarounds using this patch package idea.

If anyone thinks this is good or even viable idea then lets implement it.  I envisioned it with just this one rule to follow - the name of the patch package would reflect the version we are patching (ie. with(patch12) or with(patch2016) for Maple 12 and Maple 2016 respectively etc...)  We could make these patch packages available in this post or start another.

As I said, I'm just throwing the idea out there.  Thoughts?

Google Maps and Geocoding for Maple

by: Maple

As a momentary diversion, I threw together a package that downloads map images into Maple using the Google Static Maps API.

If you have Maple 2017, you can install the package using the MapleCloud Package Manager or by executing PackageTools:-Install("5769608062566400").

This worksheet has several examples, but I thought I'd share a few below .

Here's the Maplesoft office

Let's view a roadmap of Waterloo, Ontario.

The package features over 80 styles for roadmaps. These are examples of two styles (the second is inspired by the art of Piet Mondrian and the De Stijl movement)

You can also find the longitude and latitude of a location (courtesy of Google's Geocoding API). Maple returns a nested list if it finds multiple locations.

The geocoding feature can also be used to add points to Maple 2017's built-in world maps.

Let me know what you think!

How to make a workbook of a Package, for MapleClou...

I would like to create a Maple Workbook of my Lattice Package so I can put it on MapleCloud. I had an email exchange with Daniel Skoog from Maplesoft about this, and he even sent me an example that looked easy enough to adapt to my purposes. Alas, it does not work. Here is the code I wrote to assemble the already extant files:

restart;
# Build Lattice workbook following example from Daniel Skoog, MapleSoft:
currentdir();
"/Applications/Math_Calc/Maple 2015/Packages/Lattice/Lattice

Version 1.1.0 release files"
# We have all files already from the App Center submission, so just assemble the workbook
PackageTools:-Create("Lattice.maple",\
"MLA file"="Lattice.mla",\
"Lattice.help",\
"Source"="Lattice1.1.mpl",\
"Build procedure"="Lattice1.1.mw",\
"Manual"="The Lattice Package Users Guide.mw",\
"Release Notes"="V1.1 Release Notes.rtf");
Error, (in march) unable to attach worksheet file The Lattice Package Users Guide.mw

When I look at the created workbook (Lattice.maple), the only members included are Lattice.help, the Build procedure Lattice1.1.mw and the source file Lattice.mpl. In particular, Lattice.mla is not there, which is the most important one.

What am I doing wrong? What does "march" (which sounds like machine architecture) have to do with it??

I also don't quite know how to "install" it. I assume I just put the whole workbook into a directory accessible through libname ?

Mac Dude

PS: I could have sorted this privately with Daniel, but this may be of interest to others as well so I hope he'll answer through this forum.

Lattice1.1_workbook_maker.mw

Lattice Package Updated

by: Maple

The Lattice package to investigate particle accelerator magnet lattices (original post) has been updated to V1.1. This is a significant update, addressing a number of inaccuracies and bugs of V1.0 as well as introducing new elements: Octupole, Fringe effect in dipoles, a MatchedSection allowing to insert a piece of beamline when the details are irrelevant, and a few experimental elements like WireQuad. New functions include the 6th synchrotron-radiation integral I6x, momentum compaction alphap and TaylorMap, which allows to compute the Taylor expansion of  the non-linear map to any degree.

The code and documentation are available in the Application Center.

U. Wienands, aka Mac Dude

Command for blow ups...

Is there any command or package in Maple that computes blow ups? I didn't find blow up in the help.

HELP PLZ! How to install FGb package to Maple 2017...

I need to install FGb package into Maple, the instruction is here:http://www-polsys.lip6.fr/~jcf/FGb/FGb/darwin_i386/index.html

But after I tried so many times, I am still unable to install the package(the instruction is a little bit unclear).  Basically, I downloaded the file FGb-1.61.macosx.tar.gz  in my home directory and unzip it. I created .mapleinit and put these commands inside:

libname:= “Macintosh HD/Users/jinhuilitar xvfz/tmp/FGb-1.61.macosx.tar.gz”/FGblib, libname:

 mv <12627>/*.so mv <12627>/FGblib

I put .mapleinit in the home directory as well. But after I did all of these followed the instructions, I opened Maple and type with(FGb), it says FGb does not exist. I am so desperate, I have tried two days to solve this simple problem, please help.

I have made a small package in a workbook and want to upload it as a package to MapleCloud. According to the help pages, I should select Save To Cloud from the File menu and select the package option for Application Type in the dialog that appears. However, no matter what I do the only option availlable is Maple. What is going on?

How to install the MAPLE package "SADE"?...

I can't understand how to install this package "SADE" in Maple 17. Secondly, I am new to Maple. So Please guide me the process to install this package and how to use it. Thanks!

Hot to set a globals default value for a variable ...

In the test package below I want the the Value of Clr to be "B" when the package is loaded. How do I achieve that?

 (1)

 (2)

 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

 (9)

 (10)

 (11)

 (12)

 (13)

CodeBuilder: Build a package from code edit regions...

by: Maple

A number of MaplePrimers have asked how one might use the section and subsections of a Maple worksheet to structure the source code of an extended Maple package.  The usual answer is that it cannot be done; a module-based Maple package must be assigned in a single input region in a worksheet.  A recommended alternative is to write the source in text files and use either command line tools or the Maple read command from a worksheet to assign the package.  Because the read command handles Maple preprocessor macros, specifically the \$include macro, the source can be conveniently split into smaller files.

I prefer this file-based method for development because text files are generally more robust than Maple worksheets, can be edited with the user's preferred editor, can be put under version control, and can be searched and modified by standard Unix-based tools.  However, not everyone is familiar with this method of development.  With that in mind, I wrote a small Maple package, CodeBuilder, that permits splitting the source of a Maple package (or any Maple code) into separate code edit regions in a standard Maple worksheet, using \$include macros to include the source of other regions.  To build the package, the code edit regions are written to external files, using the names of the regions as the local file name relative to a temporary directory.

The package includes a method to run mint on the source code.  The result can be either printed in the worksheet or displayed in a pop-up maplet that allows selecting the infolevel and the region to check.

CodeBuilder includes help pages and a simple example (referenced from the top-level help page) demonstrating the usage.  To install the package, unzip the attached zip file and follow the directions in the README file.

CodeBuilder-1-0-3.zip

Errata Just noticed that a last minute change broke some of the code.  Do not bother with the 1-0-1 version; I'll upload a new version shortly.  The latest version (1-0-3) is now available.

Group/ Ungroup lines (as in a section) inside a pa...

Hello,

To have to better overview of a package, I would like to be able to group/ ungroup all the lines inside a subpackage as it is possible to do for example in a worksheet.

Is there a possibility to group lines (as a section) inside a package ?

Structure and debug a package with multiple subpac...

Hello,

I have a package with multiple subpackages that I want to correct.

For troubleshooting my package, i would be interested by 2 points :
1) I would like use subsection for each subpackage. It would enable to have a better view of the structure of my package. However, I heard that sections, and subsections can lead to syntax errors. Is there a possibility to gather lines in a subpackages as with a section or subsection ?

2) To troubleshoot my package, I would like to comment a important part of code lines. Is there a technique to comment/ uncomment an important group of lines in the same time. I would enable me to valid my code little by little.

Thanks a lot for your help and tips so as to troubleshoot a big package with many subpackages.

 1 2 3 4 5 6 7 Last Page 1 of 33
﻿