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
MapleUnique - return unique copy of an object in external code
Calling Sequence
MapleUnique(kv, s)
Parameters
kv
-
kernel handle of type MKernelVector
s
type ALGEB object
Description
This function can be used in external code with OpenMaple or define_external.
The MapleUnique function processes the Maple expression, s, and returns the unique normalized copy of that expression. For example, if you create the number num = one-billion, and then compute the number val = 2*500-million, an address comparison of num and val does not indicate equality. After calling num = MapleUnique(kv,num);, both num and val point to the same memory.
Because Maple maintains a table of unique elements, only one copy of most objects exists in memory. The expression contains two references to , but both point to the same object. Similarly, contains two sublists, . The surrounding list maintains two pointers to the same sublist. It is usually not safe to directly modify any object that has been processed by Maple. For example, if the sublist were changed from to , the parent list also changes. In fact, all references to the list in Maple would then point to . This would cause many problems. For example, table lookups of the element would be changed to look up the element. It is safe to directly modify only data blocks of mutable objects like rtables and tables. Never change strings returned by MapleToString, or expression sequences like the args object given to the external entry point.
Examples
#include "maplec.h"
ALGEB M_DECL MyGuessList( MKernelVector kv, ALGEB *args )
{
static ALGEB mylist = NULL;
if( !mylist ) {
mylist = MapleListAlloc(kv,2);
MapleListAssign(kv,mylist,1,ToMapleInteger(kv,rand()%2));
MapleListAssign(kv,mylist,2,ToMapleInteger(kv,rand()%2));
mylist = MapleUnique(kv,mylist);
MapleGcProtect(kv,mylist);
}
if( MapleNumArgs(kv,(ALGEB)args) > 0 && args[1] == mylist ) {
return( ToMapleBoolean(kv,TRUE) );
return( ToMapleBoolean(kv,FALSE) );
Execute the external function from Maple.
See Also
CustomWrapper, define_external, OpenMaple, OpenMaple/C/API, OpenMaple/C/Examples
Download Help Document