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
Algebraic.unique - get the unique representation of a Maple expression
Calling Sequence
Algebraic unique() throws MapleException
Description
The unique function returns the unique representation of the current Maple expression.
Most Maple expressions have a unique representation within Maple. Sometimes working with the unique representation is useful (two expressions can be compared very efficiently, see dagEquals) and sometimes it is not (while adding elements to a list or expression sequence it is very inefficient to unique each intermediate stage). Most functions in Java OpenMaple return objects already using their unique representation; however, in some cases the object returned is not unique.
The Algebraic objects returned by newList and newExpseq are not in their unique representation. Once they have been initialized, unique should be called on them to obtain the unique representation. Failing to do so can lead to unpredictable results.
The current Algebraic object is unchanged by this call.
Calling unique on an Algebraic that already stores a unique representation returns a reference to the same Algebraic object.
If a unique representation for the current Maple expression does not exist, the current Maple expression becomes that unique representation. Therefore the Algebraic returned by unique may refer to the same Maple object as the original. The dagEquals function can be used to determine if they refer to the same Maple object.
Examples
import com.maplesoft.openmaple.*;
import com.maplesoft.externalcall.MapleException;
class Example
{
public static void main( String notused[] ) throws MapleException
String mapleArgs[];
Engine engine;
List original, unique, global;
mapleArgs = new String[1];
mapleArgs[0] = "java";
engine = new Engine( mapleArgs, new EngineCallBacksDefault(),
null, null );
global = (List)engine.evaluate( "[100]:" );
original = engine.newList( 1 );
original.assign( 1, engine.newNumeric( 100 ) );
unique = (List)original.unique();
if ( !original.dagEquals( unique ) )
System.out.println( "unique not equal to original" );
}
if ( !original.dagEquals( global ) )
System.out.println( "global not equal to original" );
if ( unique.dagEquals( global ) )
System.out.println( "unique and global are equal" );
Executing this code produces the following output.
unique not equal to original
global not equal to original
unique and global are equal
See Also
ExternalCalling/Java/MapleException, OpenMaple, OpenMaple/C/MapleUnique, OpenMaple/Java/Algebraic, OpenMaple/Java/Algebraic/dagEquals, OpenMaple/Java/API, OpenMaple/Java/Engine/newExpseq, OpenMaple/Java/Engine/newList
Download Help Document