Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
Printer:-AddFunction - add function definition to Printer module
Printer:-AddFunctions - add functions
Printer:-GetFunction - get function definition from Printer module
Calling Sequence
Printer:-AddFunction(fname, signature, translation, libs, opts)
Printer:-AddFunctions(list1, list2, ...)
Printer:-GetFunction(fname, signature)
Parameters
Printer
-
Printer module
fname
string; name of function
signature
type signature for function fname
translation
string or procedure; translation for function fname
libs
(optional) equation of the form library=l
opts
(optional) equations of the form integer=iprec, numeric=nprec
list1, list2, ...
lists of the form [fname, signature, translation, libs, opts], with fname, signature, translation, libs, opts as defined above
Description
The AddFunction command defines an equivalent in a target language for a Maple function with name fname and function signature signature. The AddFunctions command defines multiple targets in a single calling sequence.
The GetFunction command returns a previously-defined target language equivalent for fname.
The optional parameter libs is an equation of the form library=l, where l is a string or list of strings corresponding to libraries needed for translation to function properly in the target language. This is identical in effect to writing translation as a procedure, and including AddLibrary commands for each of the libraries in l in the body of translation.
Function Signatures
A function signature is an expression which is either a type, a expression of the form , or an expression of the form anything::type0. The meaning associated with each of these is as follows.
A type - This indicates that fname is a special constant (for example, Pi) with type signature.
An expression of the form - This indicates that fname is a function accepting arguments, with types given by type1 to typen respectively, with return type type0.
An expression of the form anything::type0 - This indicates that fname is a function accepting an arbitrary number of arguments of any type, with return type type0.
Using Multiple Function Signatures
There can be multiple function signatures for a function name fname. If so, CodeGeneration attempts to match a given function call with the most appropriate signature, based on context.
Note: Maple uses the set of recognized type signatures in its type deductions, so it is useful to include as many type signatures as possible, even when one type signature is a special case of another. For example, suppose an implementation of abs function can accept both integer and float input (returning integer or float output respectively). This is equivalent to the function signatures and . To avoid needless type coercions, both of these type signatures should be explicitly specified in the language definition.
Examples
Define target-language equivalents for the sin and csc functions.
Printer:-AddFunction("csc", [numeric]::numeric, proc(a) Printer:-Print("1.0/sin(",a,")") end proc, numeric='double');
See Also
AddLibrary, Printer
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com