Programming Facilities Changes in Maple 8
Maple 8 includes the following changes to programming facilities.
System Changes
Higher Order Procedures
Verifications
Changes to the Type System
New and Improved Conversions
Packages with Programming Enhancements
Java External Call
Using the same mechanism for calling C and Fortran programs, Maple can now call static functions in a JavaTM class. Declare the function and argument types in define_external the same way you would when calling C or Fortran procedures, plus add the keyword JAVA, CLASSPATH=, and CLASS= to fully specify your function. Maple returns a procedure that automatically converts data into Java types and calls the Java function making it seem like the Java function was a built-in Maple procedure.
Named Repository Support
Maple repositories can now be uniquely named, and many can be saved in the same directory. Access to repositories is still controlled by the variable, libname, which can now specify either a directory, or an individual .lib file, or a mixture of both. The built-in march command lets you control the order of repositories in a directory by setting a priority attribute on the repositories. Libraries can also be marked as ``read-only''.
Directory Access Routines
Two new procedures, isdir, and listdir, help users manage files in directories, by providing the ability to list the contents of a directory. When iterating through the contents of a directory, isdir() helps to distinguish between subdirectories and regular files.
The new kernel option pathsep, helps write code that makes use of explicit path names in a platform independent way. The kernel option datadir provides a standard location for system and user data.
Debugging Modules
kernelopts(opaquemodules=false) makes it easier to debug code that uses modules. The effect of this command is to make local members of a module accessible outside the module. Normally only exported module members are accessible outside the module in order to provide encapsulation and data hiding. During code development and debugging however, it is often convenient to be able to inspect local members as well.
New Include Files
The new Maple include file userinfo.mi is provided in this release. It defines the macros `UI_INFO', `UI_TRACE' and `UI_DEBUG'. These macro names define the standard information levels used in the library for userinfo messages.
andmap and ormap
Two new built-in procedures andmap and ormap have been implemented. They allow you to determine, respectively, whether a predicate holds for each, or for some member or operand of an expression.
andmap( isprime, { seq( i, i = 2 .. 19 ) } );
false
andmap( type, { seq( i, i = 2 .. 19 ) }, 'integer' );
true
ormap( isprime, { seq( i, i = 2 .. 19 ) } );
ormap( type, { seq( 2*i, i = 2 .. 19 ) }, 'odd' );
member
The member procedure now accepts functions as a second argument as well as sets, lists, and modules.
member(3, F(2, 3), 'p');
p;
2
membertype
The new membertype function behaves in a manner similar to the member function, except that the first argument is a type and it checks whether or not an object of the given type exists in the second argument. If a match is found and a third argument is given, that argument must be a name, and the name is assigned the position of the first occurrence of an object of the given type in the second argument.
membertype(integer, F(a, b, 1/2, 3), 'p');
4
membertype(fraction, [a, b, 1/2, 3], 'p');
3
membertype(string, {a, b, 1/2, 3}, 'p');
maptype
The maptype function is similar to the map command, but takes an additional first argument that specifies a type. The expression maptype⁡T,F,E is equivalent to map⁡F,E when type⁡E,T is true, and is equal to F⁡E otherwise.
map( f, b*c );
f⁡b⁢f⁡c
maptype( `+`, f, b*c );
f⁡b⁢c
map( f, a + b*c );
f⁡b⁢c+f⁡a
maptype( `+`, f, a + b*c );
evalindets
The new evalindets procedure is similar to subsindets, but uses the two-argument form of eval (evaluation at a point) in place of subs.
The verification plot has been added for comparing 2-D plot data structures. By default, it is extremely strict, but options may be given to allow variations.
The verifications verify,function_shells and verify,function_bounds provide you with methods of comparing two plot data structures assumed to have come from the plots of functions. The first checks if each plot falls within an epsilon shell of the other, and the second checks that the union of the points of the plots have no more and no fewer extrema or constant regions than the individual plots.
P := plot(sin(x), x=0..10):
Q := plot(sin(x), x=0..10, numpoints=100):
verify(P, Q, 'plot(curves=function_shell(0.1))');
TypeTools
Maple's type system is now ``module-aware''. The old method of introducing new types by assigning a type definition to a name of the form `type/foo` (which defines the type `foo') is deprecated in favor of the new method that uses the new TypeTools package. See TypeTools and updates/Maple8/packages for more information about the TypeTools package.
To define a new type `foo' in Maple, use the procedure TypeTools:-AddType. It takes the name of the type as its first argument, and a type definition as the second argument. The type definition may be a structured type or a procedure that implements a predicate (returning either true or false).
The name of a type need not be global.
with( TypeTools );
AddType,Exists,GetType,GetTypes,RemoveType,Type
AddType( 'oddprime', 'And( odd, prime )' );
type( 2, 'oddprime' );
type( 3, 'oddprime' );
type( 4, 'oddprime' );
m := module() export oddprime, evenprime; local deftypes; option package, load = deftypes; deftypes := proc() use TypeTools in AddType( evenprime, 2 ); AddType( oddprime, proc( expr ) print("local oddprime"); expr <> 2 and type( expr, 'prime' ) end ) end use end proc; deftypes(); end module;
m:=moduleoptionpackage,load=deftypes;localdeftypes;exportoddprime,evenprime;end module
with( m );
evenprime,oddprime
GetTypes();
DGtransformation,AtProcedure,ExtendedProjectorKind,TensorInternalRepresentation,ac_symbol_local,HermitianOperator,ℂ,AnnihilationCreationOperator,PhysicsTensor,NegativePower,Covariant,ProjectorCore,c_var,DGbiform,DGform,EntirelyNotNestedIntegral,Physics:−Vectors:−`.`,P_suffixed,ProjectorSum,su3matrixindex,x_mu,ExtendedDifferentialOperatorIndexed,Physics:−Bra,ProjectorKindStar,DiracSpinorWithoutIndices,EuclideanTensor,TensorQuantumOperator,LiteralSubscript,PhysicsMatrix,DGscalar,Assumable,FeynmanDiagramsTensors,SpaceTimeVectorApplied,DGalgebra,VectorOperatorApplied,HalfInteger,DifferentialOperator,p_P_indexed,DGobject,DGLiealgebraWithCoeff,Tensor,ExtendedTensor,TensorWithoutIndices,VectorDifferentialOperatorCreated,nc_symbol,DGinvmetric,Name,parameter,ProjectorKind,ExtendedBra,TensorStructure,p_indexed,Procedure,spinorindex,DGdiffeq,dg_dg,ac_var,InertSymbol,Physics:−D_,DGconnection,Polynomial,ExtendedKet,FermionAnnihilationOperator,PhysicsD_2,Physics:−`.`,DGmoving_frame,ExtendedDifferentialOperator,PhysicsMatrixWithMatrixIntegerIndices,MinusTimes,DGbftv,ac_var_local,tetradindex,Physics:−Vectors:−`+`,SumOfNegatives,PhysicsD3_2,X_mu,oddprime,NotNestedIntegral,PhysicsVectors,FermionCreationOperator,Spinor,FeynmanDiagramsTensorsIndexed,c_symbol_local,ExtendedQuantumOperator,DiracSpinor,UnitaryOperator,SpinorWithoutIndices,ExtendedMatrix,DGmetric,c_var_local,FermionAnnihilationCreationOperator,QuantumObject,QuantumOperatorFunction,LeviCivitaNonGalilean,Physics:−`^`,DGtensor,BosonCreationOperator,Physics:−Projector,ExpandableProduct,VectorOperator,noncommutative,EuclideanIndex,ExtendedDifferentialOperatorSymbol,Vectorial,Physics:−Bracket,commutative,DGframemame,DGinhomogeneousform,evenprime,Physics:−Vectors:−TripleProduct,DifferentialOperatorSymbol,NumericalIndex,ac_symbol,TensorAllowWithoutIndices,PrettyPrintedBra,su2matrixindex,TensorWithNumericalIndices,Physics:−`*`,AnnihilationOperator,spacetimeindex,TypesettingStructureNeedsMfence,p_suffixed,ExtendedVectorDifferentialOperator,anticommutative,NonTensorFunction,QuantumOperator,ProjectorKindDot,IdentityMatrix,Physics:−d_,LeviCivitaTensor,DGrepresentation,spaceindex,IdenticalTo,c_symbol,Procedure,su2index,SpacetimeNumericalIndex,TensorIndex,AppliedQuantumOperator,TensorVector,DoublyIndexedPhysicsMatrix,P_indexed,nc_var,Physics:−Ket,LinearOperatorFunction,QuantumNumber,NonCommutativeProduct,BosonAnnihilationCreationOperator,VectorDifferentialOperator,PhysicsFunction,TensorWithIndices,PhysicsKnownFunction,TensorialExpression,ContravariantGreek,PrettyPrintedKet,CommutativeMapping,CreationOperator,p_P_suffixed,SpacetimeMetric,SpaceNumericalIndex,NeedsMfence,DGLiealgebra,AppliableProcedure,ExtendedProjector,ExtendedMatrixRequiringEval,oddprime,DGinhomogeneoustensor,FullyCommutative,DGvector,DGmultivector,TensorWithAbstractIndices,SpaceTimeVectorComponentApplied,Physicsd_2,CompositeDifferentiationOperator,ExtendedPhysicsMatrix,PhysicsMatrixWithMatrixIndices,ProjectorInt,nc_symbol_local,BosonAnnihilationOperator,su3index,DifferentialOperatorIndexed,DiscardableAssumption,TensorInCurrentCoordinates,nc_var_local,name,genericindex,SymbolicTensorIndex,Contravariant,MathematicalFunctions:−Region
local oddprime
type( 3, ':-oddprime' );
andmap( type, [ 2, 3, 5, 7 ], 'oddprime' );
ormap( type, [ 2, 3, 5, 7 ], 'evenprime' );
andmap( type, [ 3, 5, 7 ], 'oddprime' );
As the examples above show, it is possible to shadow a global type name with a local type name using the new mechanism.
The older method of defining new types by means of symbol concatenation is still supported in this release.
Type assignable
A new type which determines whether or not the object can be assigned to using either the assignment operator or the assign function.
type(f(x), 'assignable');
type(f[x], 'assignable');
protect(f):
unprotect(f):
type((f+g)[3], 'assignable');
float
The conversion convert,float now accepts an option that specifies the setting of digits at which the conversion is to take place.
convert(Pi, 'float');
3.141592654
convert(Pi, 'float', 3);
3.14
compose
The new conversion convert,compose composes any number of conversions on the expression, applying them in order.
convert(sin(1), 'compose', 'list', 'float'(3));
1.
convert([1, 2, exp(2)], 'compose', 'list', 'float'(4));
1.,2.,7.389
iupac
The new conversion convert/iupac converts from and to the atomic number of a chemical element of the Periodic Table, and its temporary IUPAC name or symbol.
convert(114, iupac);
ununquadium
convert(114, iupac, symbol);
Uuq
parfrac,fullparfrac
See updates/Maple8/efficiency and convert/fullparfrac for information on efficiency improvements made in these conversions.
Elementary and Special Functions
A major overhaul of the network of conversions among the elementary and basic special functions has been undertaken for this release. See updates,Maple8,symbolic for more information.
ListTools
The routine ListTools,Enumerate converts the operands of a list into a list of pairs of the form pos,expr, one for each expression expr in the input list. The first entry pos of each pair is the position of expr in the list, while the second entry is the expression expr itself.
L := [a, b, c, d, e, f]:
ListTools[Enumerate](L);
1,a,2,b,3,c,4,d,5,e,6,f
ListTools[Enumerate](L, 0);
0,a,1,b,2,c,3,d,4,e,5,f
Subpackage for linear algebra mod m
See updates/Maple8/packages
Download Help Document