|
Tips & Techniques
Connecting and Extending Maple
Maple 6 is changing the way people work with mathematical information and technical data. As a stand-alone environ-ment, Maple 6 lets you automate many mathematical tasks that used to literally take days or months. More recently, in the world of technical computing, there has been a greater emphasis put on the ability and need to be able to interact effortlessly between various software packages and languages. As a result, Maple 6 has added to its arsenal of connectivity features. New connectivity features to Maple 6 include:
- The Maple add-in to Excel 2000
- External Calling to incorporate C and FORTRAN routines in your Maple work
- Export to more file formats: RTF, DXF, WMF, BMP, POV-Ray
- Import and export data in various formats: MATLAB, ASCII, Matrix Market
Maple 6 also includes import, export, and connectivity features that were introduced in earlier versions of Maple, such as:
- The MATLAB Link
- Export to HTML
- Export to LaTeX
- C and FORTRAN code generation
More information on all of these features can be found in the Maple help pages. The following examples demonstrate two key connectivity features, in particular export to DXF and external calling.
For an example of an application of the add-in to Excel 2000, see page 10.
Export to DXF:
Using Maple as a graphic generator for CAD models
With Maple 6, you now have the ability to export graphics to multiple formats. In particular, one of the new formats is ñDXFî which is the standard CAD image file format. This allows you to create meaningful surfaces in Maple 6 and integrate them with your CAD drawings. To do this:
- Create a 3-D image in Maple 6
- Open the context-sensitive menu for the image (to do this, move your mouse over the image and click the right-mouse button, this is Option-click on a Macintosh) and select Export As -> Drawing Exchange Format (DXF)ƒ and save the file to an appropriate file
- From your CAD program, import the DXF file into your model
The following example is a CAD model with an image that was created in Maple 6 and exported to DXF as described earlier.
Export to POV-ray:
Export Maple graphics to POV-ray and create stunning, professional quality ray-traced graphics:
POV-ray, Persistence of Vision ray tracer, is a 3-dimensional ray-tracing engine. It takes information you supply and simulates the way light interacts with the objects you've defined to create stunning, professional quality 3D images. POV, the file extension for a POV-ray image, is another graphic format to export to from Maple. To export a graphic to POV in Maple, follow the same steps as exporting to DXF replacing DXF with POV. This image is a 3D graphic created in Maple, exported to POV-ray and then rendered in a POV-ray freeware package:
External Calling:
Incorporating legacy work with your new Maple work
This is probably one of the most significant new features of Maple 6 as it allows unprecedented extensibility of the system. Routines that are written in C (or in any language that exports a C interface) and are found in a library (shared library in UNIX, DLL in Windows) can now be linked into Maple dynamically, and then called as though they were native Maple routines. Additionally, external routines that take a function as an argument can be passed a Maple function. All data translations between Maple types and external data types are handled automatically.
So, if you have developed one or several routines in C or FORTRAN, you can continue to use them by integrating them with your Maple 6 work.
To demonstrate this, consider the existence of a C function mat_mult that calls two matrices as input and computes the product of those two matrices. Once a library has been created, you can call it into Maple 6 with the following commands:
> mat_mult :=
define_external('mat_mult',
a::ARRAY(1..i,1..j,float[8]),
b::ARRAY(1..j,1..k,float[8]),
c::REF(ARRAY(1..i,1..k, float[8]),RETURN_ONLY),
i::integer[4],
j::integer[4],
k::integer[4],
LIB="c:\\mat_mult\\mat_mult.dll");
Now mat_mult is a Maple routine and can be applied to Maple data:
> A := RandomMatrix(400, datatype=float[8],order=C_order):
> B := RandomMatrix(400, datatype=float[8],order=C_order):
> mat_mult(A,B,C,400,400, 400); C;
Summary
There are a variety of ways to extend the Maple system of which only a few were presented here. If you are ever in doubt of whether Maple can be applied to any given problem, the answer is almost always ñyes, it canî. Maple 6 is a very general, horizontal tool and, as a result, has the depth of power and breadth of functionality to be applied to literally every technical problem in some way, shape or form.
|
|