11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.3 Packages • 73Packages in the Standard Library A number of packages are shippedwith the standard Maple library. For example, the group, numtheory,codegen, and LinearAlgebra packages are all provided with Maple,along with several dozen others. The group package provides proceduresthat allow you to compute with groups that have a finite representationin terms of permutations, or of generators and defining relations. TheLinearAlgebra package has a large number of procedures available forcomputational linear algebra.Table-Based Packages Many packages are implemented as tables. Theessential idea underlying this implementation scheme is that the name ofa package routine is used as the index into a table of procedures. Thetable itself is the concrete representation of the package.Use Modules for New Packages Modules are the new implementationvehicle for packages. A module represents a package by its exportednames. The exported names can be assigned arbitrary Maple expressions,typically procedures, and these names form the package.Package Exports Some of the data in a package is normally made accessibleto the user as an export of the package. For packages implementedas modules, the package exports are the same as the exports of the underlyingmodule. For packages implemented as tables, the package exportsare the names used to index the underlying table.Accessing the exports of a package is a fundamental operation that issupported by all packages. If P is a Maple package, and e is one among itsexports, you can access e by using the fully qualified reference P[ e ]. IfP is a module, then you can also use the syntax P:-e. These methods ofaccessing the exports of a module are normally used when programmingwith a package.Note that :- is a left-associative operator. If S is a submodule of amodule P, and the name e is exported by S, then the notation P:-S:-e isparsed as (P:-S):-e, and so it refers to the instance of e local to S. Thisfact is important to reference members of subpackages. For example,> m := Matrix(2,2,[[1-x,2-x],[3-x,4-x]],> ’datatype’ = ’polynom(integer)’ );[ ]1 − x 2 − xm :=3 − x 4 − x> LinearAlgebra:-LA_Main:-Norm( m, 1, conjugate = false );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!