Algebraic.unique
get the unique representation of a Maple expression
Calling Sequence
Description
Examples
Algebraic unique() throws MapleException
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.
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 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