Contents Previous Next Index
|
Internal Representation
|
|
The table below lists the structures that are currently implemented in Maple.
Each structure, along with the constraints on its length and contents, is described in the sections that follow.
Table appendix 1.1: Maple Structures |
AND
|
ASSIGN
|
BINARY
|
BREAK
|
CATENATE
|
COMPLEX
|
CONTROL
|
DCOLON
|
DEBUG
|
EQUATION
|
ERROR
|
EXPSEQ
|
FLOAT
|
FOR
|
FOREIGN
|
FUNCTION
|
GARBAGE
|
HASH
|
HASHTAB
|
HFLOAT
|
IF
|
IMPLIES
|
INEQUAT
|
INTNEG
|
INTPOS
|
LESSEQ
|
LESSTHAN
|
LEXICAL
|
LIST
|
LOCAL
|
MEMBER
|
MODDEF
|
MODULE
|
NAME
|
NEXT
|
NOT
|
OR
|
PARAM
|
POLY
|
POWER
|
PROC
|
PROD
|
RANGE
|
RATIONAL
|
READ
|
RETURN
|
RTABLE
|
SAVE
|
SERIES
|
SET
|
SDPOLY
|
STATSEQ
|
STOP
|
STRING
|
SUM
|
TABLE
|
TABLEREF
|
TRY
|
UNEVAL
|
USE
|
XOR
|
ZPPOLY
|
|
|
|
|
|
Internal Functions
|
|
The internal functions in Maple are divided into five groups:
|
Evaluators
|
|
The evaluators are the main functions responsible for evaluation. There are six types of evaluations: statements, algebraic expressions, Boolean expressions, name forming, arbitrary precision floating-point arithmetic, and hardware floating-point arithmetic. The user interface calls only the statement evaluator, but thereafter there are many interactions between evaluators. For example, the statement
if a > 0 then b||i := 3.14/a end if;
|
|
|
is first analyzed by the statement evaluator, which calls the Boolean evaluator to resolve the if condition. Once completed (for example, a true result is returned), the statement evaluator is invoked again to perform the assignment, for which the name-forming evaluator is invoked with the left-hand side of the assignment, and the expression evaluator with the right-hand side. Since the right-hand side involves floating-point values, the expression evaluator calls the arbitrary precision floating-point evaluator.
Normally, you do not specifically call any of the evaluators. However, in some circumstances, when a nondefault type of evaluation is needed, you can directly call evalb (the Boolean evaluator), evaln (the name-forming evaluator), evalf (the arbitrary precision floating-point evaluator), or evalhf (the hardware floating-point evaluator).
|
|
Algebraic Functions
|
|
Algebraic functions are commonly called basic functions. Some examples are taking derivatives (diff), dividing polynomials (divide), finding coefficients of polynomials (coeff), computing series (series), mapping a function (map), expanding expressions (expand), and finding indeterminates (indets).
|
|
Algebraic Service Functions
|
|
These functions are algebraic in nature, but serve as subordinates of the functions in the previous group. In most cases, these functions cannot be explicitly called. Examples of such functions are the internal arithmetic packages, the basic simplifier, and retrieval of library functions.
|
|
Data Structure Manipulation Functions
|
|
These are similar to the algebraic functions, but instead of working on mathematical objects, such as polynomials or sets, they work on data structures, such as expression sequences, sums, products, or lists. Examples of such functions are operand selection (op), operand substitution (subsop), searching (has), and length determination (length).
|
|
General Service Functions
|
|
Functions in this group are at the lowest hierarchical level. That is, they can be called by any other function in the system. They are general purpose functions, and not necessarily specific to symbolic or numeric computation. Some examples are storage allocation and garbage collection, table manipulation, internal I/O, and exception handling.
|
|
|
Flow of Control
|
|
The flow of control does not need to remain internal to the Maple kernel. In many cases, where appropriate, a decision is made to call functions that are written in Maple and are a part of the Maple library. For example, many uses of the expand function are handled in the kernel. However, if an expansion of a sum to a large power is required, the internal expand function calls the external Maple library function 'expand/bigpow' to resolve it. Functions such as diff, evalf, series, and type make extensive use of this feature.
Therefore, for example, the basic function diff cannot differentiate any function. All of that functionality is included in the Maple library in procedures named 'diff/functionName'. This is a fundamental feature of Maple since it permits:
•
|
Flexibility (the ability to change the Maple library)
|
•
|
Customization (by defining your refined handling functions)
|
•
|
Readability (much of the Maple functionality is visible at the user level)
|
Maple allows the kernel to remain small by offloading nonessential functions to the library.
|
|
Internal Representations of Data Types
|
|
The parser and some internal functions build all of the data structures used internally by Maple. All of the internal data structures have the same general format:
Header
|
|
...
|
|
|
|
The header field, stored in one or more machine words, encodes the length of the structure and its type. Additional bits are used to record simplification status, garbage collection information, persistent store status, and various information about specific data structures (for example, whether a for loop contains a break or next statement).
The length is encoded in 26 bits on 32-bit architectures, resulting in a maximum single object size of 67,108,863 words (268,435,452 bytes, or 256 megabytes). On 64-bit architectures, the length is stored in 32 bits, for a maximum object size of 4,294,967,295 words (34,359,738,360 bytes or 32 gigabytes).
Every structure is created with its own length, and that length does not change during the existence of the structure. Furthermore, the contents of most (but not all) data structures are never changed during execution because it is unpredictable how many other data structures are referring to them and relying on them not to change. The normal process for modifying a structure is to copy it and then to modify the copy. Structures that are no longer used are eventually reclaimed by the garbage collector.
The following sections describe each of the structures currently implemented in Maple, along with the constraints on their lengths and contents. The 6-bit numeric value identifying the type of structure is of little interest, so symbolic names will be used.
The notation ^something in the data structure depictions indicates that the value stored in that field of the structure is a pointer to the value (something), rather than being the something itself.
|
AND: Logical AND
|
|
Maple syntax: expr1 and expr2
Length: 3
|
|
ASSIGN: Assignment Statement
|
|
ASSIGN
|
^name-seq
|
^expr-seq
|
|
|
Maple syntax: name1, name2, ... := expr1, expr2, ...
Length: 3
The left-hand side name entries must evaluate to assignable objects: NAME, FUNCTION, MEMBER or TABLEREF structures, or a sequence thereof. If the left-hand side is a sequence, the right-hand side must be a sequence of the same length.
|
|
BINARY: Binary Object
|
|
Maple syntax: none
Length: arbitrary
The BINARY structure can hold any arbitrary data. It is not used directly as a Maple object, but is used as storage for large blocks of data within other Maple objects (currently only RTABLE structures). It is also sometimes used as temporary storage space during various kernel operations.
|
|
BREAK: Break Statement
|
|
Maple syntax: break
Length: 1
|
|
CATENATE: Name Concatenation
|
|
Maple syntax: name || expr
Length: 3
•
|
If the name entry is one of NAME, CATENATE, LOCAL, or PARAM, and if the expr entry evaluates to an integer, NAME, or STRING, the result is a NAME.
|
•
|
If the name entry is a STRING or CATENATE that resolves to a STRING, and if the expr entry evaluates to an integer, NAME, or STRING, the result is a STRING.
|
•
|
If expr is a RANGE, the result is to generate an EXPSEQ of the NAME or STRING structures.
|
|
|
COMPLEX: Complex Value
|
|
Maple syntax: Complex(re,im), Complex(im), re + im * I or im * I
Length: 2 or 3
The re and im fields must point to INTPOS, INTNEG, RATIONAL, or FLOAT structures, one of the NAMEs infinity or undefined, or a SUM structure representing -infinity. In the length 3 case, if either re or im is a FLOAT, the other must be a FLOAT as well.
|
|
CONTROL: Communications Control Structure
|
|
Maple syntax: none
Length: 2
This is an internal structure used for communication between the kernel and user interface. Such a structure never reaches the user level, or even the mathematical parts of the kernel.
|
|
DCOLON: Type Specification or Test
|
|
Maple syntax: expr :: typeExpr
Length: 3
This structure has three interpretations depending on the context in which it is used. When it appears in the header of a procedure definition, it is a parameter declaration that has a type. When it appears in the local section of a procedure or on the left-hand side of an assignment, it is a type assertion. When it appears elsewhere (specifically, in a conditional expression), it is a type test.
|
|
DEBUG: Debug
|
|
Maple syntax: none
Length: 2 or more
This is another structure that is only used internally. It is used by the kernel when printing error traceback information to transmit that information up the call stack.
|
|
EQUATION: Equation or Test for Equality
|
|
Maple syntax: expr1 = expr2
Length: 3
This structure has two interpretations depending on the context in which it is used. It can be either a test for equality, or a statement of equality (not to be confused with an assignment).
|
|
ERROR: Error Statement
|
|
Maple syntax: error "msg", arg, ... arg
Length: 2
This structure represents the Maple error statement. The expr is either a single expression (if only a message is specified in the error statement), or an expression sequence (if arguments are also specified). The actual internal tag used for the ERROR structure is MERROR to prevent a conflict with a macro defined by some C compilers.
|
|
EXPSEQ: Expression Sequence
|
|
Maple syntax: expr1, expr2, ...
Length: 1 or more
An expression sequence is an ordered sequence of expressions. It is most commonly used to construct lists, sets, and function calls. Extracting an expression sequence from a list or set L can be done by using the command op(L). This operation is very efficient as it does not involve creation of a new structure. Similarly, if E is an expression sequence, then constructing a list using [E] involves almost no work and is also very efficient. Constructing a set using {E} requires E to be sorted. A function call data structure is made up of the function name plus the expression sequence of arguments. During evaluation of a function call, the argument sequence gets flattened into one expression sequence. That is, f(E1,E2) is turned into f(e11,e12,...e1n,e21,e22,...e2m) where e1i constitutes the members of the expression sequence E1, and e2i constitutes the members of the expression sequence E2. Thus it is not possible to pass raw expression sequences as arguments to functions. Typically sequences are wrapped in lists, as f([E1],[E2]) in order to keep the element groupings intact. The special value NULL is represented by an empty expression sequence. Thus, [NULL] is equivalent to [], and f(NULL) is equivalent to f().
|
|
FLOAT: Software Floating-Point Number
|
|
FLOAT
|
^integer1
|
^integer2
|
^attrib-expr
|
|
|
Maple syntax: 1.2, 1.2e3, Float(12,34), Float(infinity)
Length: 2 (or 3 with attributes)
A floating-point number is interpreted as integer1 * 10^integer2. A floating-point number can optionally have attributes, in which case, the length of the structure is 3 and the third word points to a Maple expression. This means that several floating-point numbers with the same value but different attributes can exist simultaneously.
The integer2 field can optionally be one of the names, undefined or infinity, in which case the FLOAT structure represents an undefined floating-point value (not-a-number, or NaN, in IEEE terminology), or a floating-point infinity. When integer2 is undefined, integer1 can accept different small integer values, allowing different NaN values to exist. When integer2 is infinity, integer1 must be 1 or -1.
|
|
FOR: For/While Loop Statement
|
|
FOR
|
^name
|
^from-expr
|
^by-expr
|
^to-expr
|
^cond-expr
|
^stat-seq
|
|
|
FOR
|
^name
|
^in-expr
|
^cond-expr
|
^stat-seq
|
|
|
Maple syntax:
for name from fromExpr by byExpr to toExpr
while condExpr do
statSeq
end do
|
|
|
Maple syntax:
for name in inExpr
while condExpr do
statSeq
end do
|
|
|
Length: 7 or 5
The name follows the same rules as the name field of the ASSIGN structure, except that it can also be the empty expression sequence (NULL), indicating that there is no controlling variable for the loop.
The from-expr, by-expr, to-expr, and cond-expr entries are general expressions. All are optional in the syntax of for loops and can therefore be replaced with default values (1, 1, NULL, and true respectively) by the parser.
The stat-seq entry can be a single Maple statement or expression, a STATSEQ structure, or NULL indicating an empty loop body. An additional bit in the header of the FOR structure is used to indicate whether the stat-seq entry contains any break or next statements.
|
|
FOREIGN: Foreign Data
|
|
Maple syntax: none
Length: 1 or more
This structure is similar to the BINARY structure, except that it is for use by Maple components outside the kernel, such as the user interface. A FOREIGN structure is exempt from garbage collection, and the external component is responsible for freeing this structure when it is finished using it.
FOREIGN data structures can be created and managed in external code by using the MaplePointer API functions. For more information, refer to the OpenMaple,C,MaplePointer help page.
|
|
FUNCTION: Function Call
|
|
FUNCTION
|
^name
|
^expr-seq
|
^attrib-expr
|
|
|
Maple syntax: name( exprSeq )
Length: 2 (or 3 with attributes)
This structure represents a function invocation (as distinct from a procedure definition that is represented by the PROC structure). The name entry follows the same rules as in ASSIGN, or it can be a PROC structure. The expr-seq entry gives the list of actual parameters; this entry is always an expression sequence (possibly of length 1, which indicates that no parameters are present).
|
|
GARBAGE: Garbage
|
|
Maple syntax: none
Length: 1 or more
This structure is used internally by the Maple garbage collector as a temporary object type for free space.
|
|
HFLOAT: Hardware Float
|
|
HFLOAT
|
floatword
|
floatword
|
|
|
Maple syntax: none
Length: 2 on 64-bit architectures; 3 on 32-bit architectures
This structure is used to store a hardware floating-point value. The one or two words (always 8 bytes) after the header store the actual double-precision floating-point value. HFLOAT objects can appear as the result of floating-point computations, I/O operations, or by extracting elements from hardware floating-point RTABLE structures. They look like and are treated as indistinguishable from software FLOAT objects.
|
|
IF: If Statement
|
|
IF
|
^cond-expr1
|
^stat-seq1
|
^cond-expr2
|
^stat-seq2
|
...
|
...
|
^stat-seqN
|
|
|
Maple syntax:
if condExpr1 then
statSeq1
elif condExpr2 then
statSeq2
...
else statSeqN
end if
|
|
|
Length: 3 or more
This structure represents the if ... then ... elif ... else ... end if statements in Maple. If the length is even, the last entry is the body of an else clause. The remaining entries are interpreted in pairs, where each pair is a condition of the if or elif clause, followed by the associated body.
|
|
IMPLIES: Logical IMPLIES
|
|
Maple syntax: expr1 implies expr2
Length: 3
|
|
INEQUAT: Not Equal or Test for Inequality
|
|
Maple syntax: expr1 < > expr2
Length: 3
This structure has two interpretations, depending on the context in which it is used. It can be either a test for inequality or an inequality statement.
|
|
INTNEG: Negative Integer
|
|
Maple syntax: -123
Length: 2 or more
This data structure represents a negative integer of arbitrary precision. For a complete description of the integer representation, including positive integers, see the following section.
|
|
INTPOS: Positive Integer
|
|
Maple syntax: 123
Length: 2 or more
This data structure represents a positive integer of arbitrary precision. Integers are represented internally in a base equal to the full word size of the host machine. On 32-bit architectures, this base is . On 64-bit architectures, the base is 2^64. Integers in this range use the GNU Multiple Precision Arithmetic (GMP) library for integer arithmetic.
Small integers are not represented by data structures. Instead of a pointer to an INTPOS or INTNEG structure, a small integer is represented by the bits of what would normally be a pointer. The least significant bit is 1, which makes the value an invalid pointer (since pointers must be word-aligned). Such an integer is called an immediate integer.
The range of integers that can be represented in this way is -1,073,741,823 to 1,073,741,823 (that is, about +-10^9) on 32-bit architectures, and -4,611,686,018,427,387,903 to 4,611,686,018,427,387,903 (that is, about +-410^18) on 64-bit architectures. (Note that the maximum (non-immediate) integer magnitude in Maple is about 2^2,147,483,488 on 32-bit architectures and 2^274,877,906,688 on 64-bit architectures.)
|
|
LESSEQ: Less Than or Equal
|
|
Maple syntax: expr1 <= expr2, expr2 >= expr1
Length: 3
This structure has two interpretations, depending on the context. It can be interpreted as a relation (that is, an inequation) or as a comparison (for example, in the condition of an if statement, or the argument to a call to evalb). Maple does not have a greater-than-or-equal structure. Any input of that form is stored as a LESSEQ structure.
|
|
LESSTHAN: Less Than
|
|
Maple syntax: expr1 < expr2, expr2 > expr1
Length: 3
Similar to the LESSEQ structure above, this structure has two interpretations, depending on the context. It can be interpreted as a relation (that is, an inequation), or as a comparison (for example, in the condition of an if statement, or the argument to a call to evalb).
Maple does not have a greater-than structure. Any input of that form is stored as a LESS structure.
|
|
LEXICAL: Lexically Scoped Variable within an Expression
|
|
Maple syntax: name
Length: 2
This represents an identifier within an expression in a procedure or module that is not local to that procedure, but is instead declared in a surrounding procedure or module scope. The integer field identifies which lexically scoped variable of the current procedure is being referred to. The integer, multiplied by 2, is an index into the lexical-seq structure referred to by the PROC DAG of the procedure. Specifically, |integer| * 2 - 1 is the index to the NAME of the identifier, and |integer| * 2 is the index to a description (LOCAL, PARAM, or LEXICAL) relative to the surrounding scope. The value of integer can be positive or negative. If integer is a positive value, the original identifier is a local variable of a surrounding procedure; if integer is a negative value, it is a parameter of a surrounding procedure.
|
|
LIST: List
|
|
LIST
|
^expr-seq
|
^attrib-expr
|
|
|
Maple syntax: [ expr, expr, ... ]
Length: 2 (or 3 with attributes)
The elements of the expr-seq are the elements of the list. The list can optionally have attributes.
|
|
LOCAL: Local Variable within an Expression
|
|
Maple syntax: name
Length: 2
This structure indicates a local variable when it appears within an expression in a procedure or module. The integer is an index into the procedure local-seq. At procedure execution time, it is also an index into the internal data structure storing the active locals on the procedure activation stack, and stores private copies of the NAMEs of the local variables (private copies in the sense that these NAMEs are not the same as the global NAMEs of the same name).
|
|
MEMBER: Module Member
|
|
Maple syntax: module:-name
Length: 3
This structure represents a module member access in an expression. MEMBER objects typically do not persist when a statement is simplified. Instead, they are replaced by the actual member that they refer to (an instance of a NAME).
|
|
MODDEF: Module Definition
|
|
MODDEF
|
param-seq
|
local-seq
|
option-seq
|
export-seq
|
stat-seq
|
desc-seq
|
|
|
global-seq
|
lexical-seq
|
mod-seq
|
static local-seq
|
static export-seq
|
static name-seq
|
|
|
Maple syntax:
module modName ( )
\011 description d1, d2, ...;
\011 local l1, l2, ...;
\011 local sl1::static, sl2::static, ...;
\011 export e1, e2, ...;
\011 export se1::static, se2::static, ...;
\011 global g1, g2, ...;
\011 option o1, o2, ...;
\011 statSeq
end module
|
|
|
Length: 13
The parameter sequence (param-seq), which occurs between the parentheses after modName, points to an expression sequence describing the formal parameters of the module. Currently, Maple does not support parameterized modules, so this field always points to the sequence containing only an instance of the name thismodule.
The local sequence (local-seq) points to an expression sequence listing the explicitly and implicitly declared local variables. Each entry is a NAME. The explicitly declared variables appear first. Within the module, locals are referred to by LOCAL structures, the local variable number being the index into the local sequence. The instances of these names appear in the MODULE structure.
The export sequence (export-seq) points to an expression sequence listing the exported module members. Each entry is a NAME. Within the module, exports are referred to by LOCAL structures, the local variable number being the number of elements in the local sequence, plus the index into the export sequence. The instances of these names appear in the MODULE structure.
The option sequence (option-seq) points to an expression sequence of options to the module (for modules, options are the same as attributes). Each entry is a NAME or EQUATION specifying an option. Typical options are package, load=... and unload=...
The statement sequence (stat-seq) field points to a single statement or a statement sequence (STATSEQ). If the module has an empty body, this is a pointer to NULL instead.
The description sequence (desc-seq) field points to an expression sequence of NAMEs or STRINGs. These sequences are meant to provide a brief description of what the module does and are displayed even when the value of interface(verboseproc) is less than 2.
The global sequence (global-seq) field points to a list of the explicitly declared global variables in the module (those that appeared in the global statement). This information is never used at run time, but is used when simplifying nested modules and procedures to determine the binding of lexically scoped identifiers (for example, an identifier on the left-hand side of an assignment in a nested procedure can be global if it appears in the global statement of a surrounding context). This information is also used at printing time, so that the global statement contains exactly the global identifiers that were declared originally.
The lexical sequence (lexical-seq) field points to an expression sequence of links to identifiers in the surrounding scope, if any. The sequence consists of pairs of pointers. The first pointer of each pair is to the globally unique NAME of the identifier; this is needed at simplification and printing time. The second pointer is a pointer to a LOCAL, PARAM, or LEXICAL structure which is understood to be relative to the surrounding scope. When a module definition is evaluated, the lexical sequence is updated by replacing each of the second pointers with a pointer to the actual object represented. The name pointers are not modified, so that the actual identifier names are still available. The lexical-seq for a module contains entries for any surrounding-scope identifiers used by that module or by any procedures or modules contained within it.
The module name (mod-name) field points to the optional name of the module. If a module name is specified when the module is declared, the name appears there. If no module name is specified, this field will contain a value of NULL.
The static local-seq points to an expression sequence listing the local variables that were explicitly declared as :static. Each entry is a NAME. Within the module, static locals are referred to by LOCAL structures, the local variable number being the index into the static local-seq minus the number of nonstatic locals and exports. A static local shares its value among all instances of a class.
The static export-seq points to an expression sequence listing the exported module members declared as static. Each entry is a NAME. Within the module, exports are referred to by LOCAL structures, the local variable number being the number of elements in the local-seq, static local-seq, and export-seq, plus the index into the static export-seq.
The static name-seq stores the instances of the static locals and exports. It appears in the MODDEF structure as these static variables are shared among all modules with the same definition.
|
|
MODULE: Module Instance
|
|
MODULE
|
^export-seq
|
^mod-def
|
^local-seq
|
|
|
Maple syntax: none
Length: 4
Executing a module definition (MODDEF) results in a module instance. Each local or exported member of the module is instantiated and belongs to that instance of the module. The export-seq field points to an expression sequence of names of the instantiated exports (as opposed to the global names, as stored in the module definition). The mod-def field points back to the original module definition. The local-seq field points to an expression sequence of names of the instantiated local variables of the module.
|
|
NAME: Identifier
|
|
NAME
|
^assigned-expr
|
^attrib-expr
|
characters
|
characters
|
...
|
|
|
Maple syntax: name
Length: 4 or more
The assigned-expr field points to the assigned value of the name. If the name has no assigned value, this field is a null pointer (not a pointer to NULL). The next field points to an expression sequence of attributes of the name. If there are no attributes, this field points to the empty expression sequence (NULL). The remaining fields contain the characters that form the name, stored 4 or 8 for each machine word (for 32-bit and 64-bit architectures respectively). The last character is followed by a zero-byte. Any unused bytes in the last machine word are also zero. The maximum length of a name is 268,435,447 characters on 32-bit architectures and 34,359,738,351 characters on 64-bit architectures.
|
|
NEXT: Next Statement
|
|
Maple syntax: next
Length: 1
|
|
NOT: Logical NOT
|
|
Maple syntax: not expr
Length: 2
|
|
OR: Logical OR
|
|
Maple syntax: expr1 or expr2
Length: 3
|
|
PARAM: Procedure Parameter in an Expression
|
|
Maple syntax: name
Length: 2
This structure indicates a parameter when it appears in a procedure. The integer is an index into the procedure param-seq. Several special PARAM structures exist:
This structure represents the Maple symbol _npassed (formerly nargs), the number of arguments passed when the procedure was called.
This structure represents the Maple symbol _passed (formerly args), the entire sequence of arguments passed when the procedure was called.
This structure represents the Maple symbol procname, referring to the currently active procedure.
This structure represents the Maple symbol _nresults, the number of results expected to be returned from the procedure.
This structure represents the Maple symbol _params, the sequence of declared positional arguments passed when the procedure was called.
This structure represents the Maple symbol _nparams, the number of declared positional arguments passed when the procedure was called.
This structure represents the Maple symbol _rest, the sequence of undeclared arguments passed when the procedure was called.
This structure represents the Maple symbol _nrest, the number of undeclared arguments passed when the procedure was called.
This structure represents the Maple symbol _options, the sequence of options in the procedure.
This structure represents the Maple symbol _noptions, the number of options in the procedure.
This structure represents the Maple symbol thisproc, referring to the instance of the currently active procedure.
At procedure execution time, the integer (if positive) is used as an index into the internal data structure Actvparams, which is part of the Maple procedure activation stack, and stores pointers to the values (which are also Maple structures) of the actual parameters passed to the procedure.
|
|
POLY: Multivariate Polynomials with Integer Coefficients
|
|
POLY
|
^indet_seq
|
m[i] degrees
|
m[i] coeff
|
m[i+1] degrees
|
m[i+1] coeff
|
...
|
|
|
Maple syntax:
newpoly := proc(a) proc()
option builtin=sdmpoly;
end proc("create",a) end proc;
newpoly(2*y^3+4*x*y+4);
|
|
|
Length: 2*(number of monomials) + 2
This is an internal representation for multivariate polynomials of limited degree and integer coefficients.
Each degree word stores the total degree of the monomial and each individual degree. For example, 5*x^2*y^3 is a two-variable polynomial with total degree 5 and degree 2 on the x term, and degree 3 on the y term. The numbers 5, 2, and 3 are packed into a single degree word. The packing depends on the number of variables in the polynomial. Because the packing must fit in one word of memory, not all polynomials can be represented in this way. The most common polynomials can be stored in this data structure, which can be operated on efficiently.
Each coefficient word must be an integer data structure.
The indet_seq is the sequence of indeterminates that occur in the polynomial. The indeterminates must be simple NAMEs.
The polynomial is always stored in one of three sorted orders.
•
|
PLEX: Monomials are compared first by their degree in vars[1], with ties broken by degree in vars[2], and so on.
|
•
|
GRLEX: Monomials are compared first by their total degree, with ties broken by degree of vars[i]
|
•
|
TDEG: Monomials are compared first by their total degree, with ties broken by reverse lexicographic order, that is, by smallest degree in x[n], x[n-1], and so on.
|
|
|
POWER: Power
|
|
Maple syntax: expr1 ^expr2
Length: 3
This structure is used to represent a power when the exponent is not an integer, rational, or floating-point value. When the exponent is numeric, the POWER structure is converted to a length 3 PROD structure.
|
|
PROC: Procedure Definition
|
|
PROC
|
^param-seq
|
^local-seq
|
^option-seq
|
^rem-table
|
^stat-seq
|
^desc-seq
|
|
|
^global-seq
|
^lexical-seq
|
^eop
|
^return-type
|
|
|
Maple syntax:
proc ( paramSeq ) :: returnType;
\011\011description descSeq;
\011local localSeq;
\011export exportSeq;
\011global globalSeq;
\011option optionSeq;
\011statSeq
end proc
|
|
|
Length: 10 or 11 (the return type is optional)
The param-seq points to an expression sequence describing the formal parameters of the procedure. Each entry is either a NAME or a DCOLON (which, in turn, contains a NAME and an expression specifying a type). Within the procedure, parameters are referred to by PARAM structures, the parameter number being the index into the param-seq.
The local-seq points to an expression sequence listing the explicitly and implicitly declared local variables. Each entry is a NAME. The explicitly declared variables appear first. Within the procedure, locals are referred to by LOCAL structures, the local variable number being the index into the local-seq.
The option-seq field points to an expression sequence of options to the procedure (for procedures, options are the same as attributes). Each entry is a NAME or EQUATION specifying an option. Commonly used options are cache, operator, and `Copyright ...`.
The rem-table field points to a hash table containing remembered values of the procedure. Entries in the table are indexed by the procedure arguments, and contain the resulting value. If there is no remember table, this field contains a pointer to NULL, which is the empty expression sequence.
The stat-seq field points to a single statement or a statement sequence (STATSEQ). If the procedure has an empty body, this is a pointer to NULL instead. For each procedure that is built into the kernel, there is a wrapper PROC that has the option builtin in its option-seq, and a single Maple integer pointed to by its stat-seq. The integer gives the built-in function number.
The desc-seq field points to an expression sequence of NAMEs or STRINGs. These are meant to provide a brief description of what the procedure does, and are displayed even when the interface(verboseproc) command is less than 2.
The global-seq field points to a list of the explicitly declared global variables in the procedure (those that appeared in the global statement). This information is never used at run time, but it is used when simplifying nested procedures to determine the binding of lexically scoped identifiers. For example, an identifier on the left-hand side of an assignment in a nested procedure can be global if it appears in the global statement of a surrounding procedure. This information is also used at procedure printing time, so that the global statement will contain exactly the same global identifiers that were declared in the first place.
The lexical-seq field points to an expression sequence of links to identifiers in the surrounding scope, if any. The sequence consists of pairs of pointers. The first pointer of each pair is to the globally unique NAME of the identifier; this is needed at simplification and printing time. The second pointer is a pointer to a LOCAL, PARAM, or LEXICAL structure which is understood to be relative to the surrounding scope. When a procedure is evaluated (not necessarily called), the lexical-seq is updated by replacing each of the second pointers with a pointer to the actual object represented. The name pointers are not modified, so that the actual identifier names are still available. The lexical-seq for a procedure contains entries for any surrounding-scope identifiers used by that procedure or by any procedures contained within it.
The eop field is BINARY. The first entry specifies the number of positional parameters of the procedure. The remaining entries, if any, specify the evaluation order permutation for the procedure (that is, an evaluation order for the arguments that is consistent with any dependencies among the parameter specifications).
The return-type field is present only if a return type has been specified for the procedure. A return type is an assertion about the type of the value returned by the procedure; if kernelopts(assertlevel) is set to 2, then this type is checked as the procedure returns.
|
|
PROD: Product, Quotient, Power
|
|
PROD
|
^expr1
|
^expon1
|
^expr2
|
^expon2
|
...
|
...
|
|
|
Maple syntax: expr1 ^ expon1 * expr2 ^ expon2 ...
Length: 2n + 1
This structure is interpreted as pairs of factors and their numeric exponents. Rational or integer expressions to an integer power are expanded. If a rational constant is in the product, this constant is moved to the first entry by the simplifier. A simple power, such as , is represented as a PROD structure. More complex powers involving non-numeric exponents are represented as POWER structures.
|
|
RANGE: Range
|
|
Maple syntax: expr1 .. expr2
Length: 3
|
|
RATIONAL: Rational
|
|
RATIONAL
|
^integer
|
^pos-integer
|
|
|
Maple syntax: 1/2
Length: 3
This structure is one of the basic numeric objects in Maple. Note that this is not a division operation, but only a representation for rational numbers. Both fields must be integers (INTPOS, INTNEG, or an immediate integer) and the second must be positive.
|
|
READ: Read Statement
|
|
Maple syntax: read expr
Length: 2
The Maple read statement. The expression must evaluate to either a string or symbol (STRING or NAME structure), and specifies the name of the file to read.
|
|
RETURN: Return Statement
|
|
Maple syntax: return expr1, expr2, ...
Length: 2
The Maple return statement. The expression sequence is evaluated, giving the value(s) to return.
|
|
RTABLE: Rectangular Table
|
|
RTABLE
|
^data
|
^maple-type
|
^index-func
|
^attrib
|
flags
|
num-elems
|
|
|
Maple syntax: rtable(...)
Length: 2n + p where n is the number of dimensions (0 to 63), and p is 0, 1, or 2, depending on the number of parameters.
The data field points to either a block of memory (for dense and NAG-sparse RTABLEs), or to a HASHTAB structure (for Maple-sparse RTABLEs). The data block is either an object of type BINARY, or memory allocated directly from the storage manager of the operating system when the block is too large to be allocated as a Maple data structure. If the data block is a BINARY object, the data pointer points to the first data word, not to the object header.
The maple-type field points to a Maple structure specifying the data type of the elements of an RTABLE of Maple objects. If the RTABLE contains hardware objects, the maple-type field points to the Maple NAME anything.
The index-func field points to either an empty expression sequence (NULL), or an expression sequence containing at least one indexing function and a pointer to a copy of the RTABLE structure. The copy of the RTABLE is identical to the original structure, except that its index-func field refers to one less indexing function (either NULL, or another expression sequence containing at least one indexing function and a pointer to another copy of the RTABLE with one less indexing function again).
The attrib field points to an expression sequence of zero or more arbitrary attributes, which can be set by the setattribute command and queried by using the attributes command.
The flags field is a bit field containing the following subfields.
•
|
data type - 5 bits - indicates that one of several hardware data types or a Maple data type (as specified by maple-type) is being used.
|
•
|
subtype - 2 bits - indicates if the RTABLE is an Array, Matrix, or Vector.
|
•
|
storage - 4 bits - describes the storage layout (for example, sparse, upper triangular, and so on)
|
•
|
order - 1 bit - indicates C or Fortran ordering of RTABLE elements.
|
•
|
read only - 1 bit - indicates that the RTABLE is to be read-only once created.
|
•
|
foreign - 1 bit - indicates that the space pointed to by the data field does not belong to Maple, so Maple should not garbage collect it.
|
•
|
eval - 1 bit - indicates if full evaluation should occur on lookup. For more information, refer to the rtable_eval help page.
|
| | | |