create lookup table - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : compiletable

compiletable - create lookup table

tablelook - perform table lookup

insertpattern - append to lookup table

Calling Sequence

compiletable([pattern1=entry1, pattern2=entry2, ...])

tablelook(expr, pattree)

insertpattern(pattern=entry, pattree)

Parameters

pattern, pattern1, pattern2, ...

-

pattern to match

entry, entry1, entry2, ...

-

table entry corresponding to a pattern

expr

-

expression to be matched

pattree

-

pattern match tree returned by compiletable or insertpattern

Description

• 

The compiletable([pattern1=entry1, pattern2=entry2, ...]) calling sequence creates an efficient lookup table by merging patterns (with parameters) into a tree that the pattern matcher (tablelook command) can search in logarithmic time. For example, you can create an integration table in which each pattern is an integrand and the corresponding entry its integral.

  

Each table entry is of the form pattern=entry. For information on the format, see patmatch.

• 

The tablelook(expr, pattree) calling sequence compares expr to patterns in pattree. If tablelook finds a match, it returns the corresponding entry with parameter values substituted. Otherwise, it returns FAIL.

• 

The insertpattern(pattern=entry, pattree) calling sequence appends pattern=entry to the end of pattree.

Examples

tab:=lna::radnum_X+b::radnum=lnax+bx+1lnax+bbax1ba,ⅇa::radnum_X=1ⅇaxa,ⅇa::radnum_X2+b::radnum=1π12erfa12xⅇb2a12,cosa::radnum_X=1sinaxa,sina::radnum_X2=1212π12FresnelS212a12xπ122a12,sina::radnum_X=1cosaxa,_X1+sin_X=xcosx+xtanx+lncosx+lnsecx+tanx,_X1sin_X=xcosx+xtanx+lncosxlnsecx+tanx,a::radnum_X+b::radnum=ax22+bx,_X+a::radnum1=lnx+a,a::radnum_Xn::integer=axn+1n+1:

tab:=subs_X=x::name,tab:

p:=compiletabletab:

Now we can use the table:

tablelookcos2x,p

12sin2x

(1)

tablelookln2z,p

ln2zzz

(2)

tablelookⅇ2x23,p

14π2erf2xⅇ3

(3)

maptablelook,1x52+3x2x+1x+2,p

112x6+x312x2+lnx+2

(4)

See Also

patmatch


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam