Algebraic.uniqueget the unique representation of a Maple expression
Calling SequenceDescriptionExamples
<Text-field style="Heading 2" layout="Heading 2" bookmark="usage">Calling Sequence</Text-field>
Algebraic unique() throws MapleException
<Text-field style="Heading 2" layout="Heading 2" bookmark="info">Description</Text-field>
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.
<Text-field style="Heading 2" layout="Heading 2" bookmark="examples">Examples</Text-field>
import com.maplesoft.openmaple.*;import com.maplesoft.externalcall.MapleException;class Example{ public static void main( String notused[] ) throws MapleException { String[] mapleArgs = { "java" }; Engine engine = new Engine( mapleArgs, new EngineCallBacksDefault(), null, null ); List global = (List)engine.evaluate( "[100]:" ); List original = engine.newList( 1 ); original.assign( 1, engine.newNumeric( 100 ) ); List 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 originalglobal not equal to originalunique and global are equal
See AlsoExternalCalling/Java/MapleExceptionOpenMapleOpenMaple/C/MapleUniqueOpenMaple/Java/AlgebraicOpenMaple/Java/Algebraic/dagEqualsOpenMaple/Java/APIOpenMaple/Java/Engine/newExpseqOpenMaple/Java/Engine/newList