Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
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