Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
rtable_eval - evaluate the entries of an rtable under certain conditions
Calling Sequence
rtable_eval(A,inplace)
Parameters
A
-
rtable object
inplace
(optional) BooleanOpt(inplace); specifies if output overwrites input
Description
The rtable_eval(A) command, where A is an Array, Matrix, or Vector, returns either a copy of A, or the original input A depending if evaluation is needed. It also changes the way elements are evaluated when the returned rtable is subsequently referenced.
Evaluation is needed provided the following two conditions are met. Firstly, eval(A[i],1) <> eval(A[i]) for a given element . Secondly, full evaluation must have been applied to A prior to calling rtable_eval(A).
Applying eval() to an rtable returns immediately without changing the given rtable. This is unlike a list, which maps eval() onto each element and returns a copy. Evaluation of rtable elements is normally deferred until elements are referenced. If the same elements are repeatedly referenced, evaluation of those elements is also repeated. The rtable_eval(A) command provides a way to evaluate every element once so that future references can bypass evaluation, without necessarily making a copy.
Applying rtable_eval to any rtable with a hardware datatype always returns the input rtable unchanged.
Applying rtable_eval to any rtable with a user defined indexing-function always returns the input rtable unchanged.
The result of rtable_eval is an rtable with the same attributes as the input rtable, including shape, storage, and datatype.
If the optional second argument, inplace is specified, the input rtable is changed if necessary. No copy is made.
Thread Safety
The rtable_eval command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Examples
Create an rtable that prints something when an element is referenced.
p := proc(i) printf("eval element %d\n",i); end proc:
Reference the first element 4 times. This generates 4 eval()'s.
f := proc(V) V[1]; V[1]; V[1]; V[1]; end proc:
eval element 1 eval element 1 eval element 1 eval element 1
Use rtable_eval() to evaluate every element initially. Subsequent references will already contain the results of evaluating, so V[1] does not print anything.
f := proc(VV) local V; V := rtable_eval(VV); V[1]; V[1]; V[1]; V[1]; end proc:
eval element 1 eval element 3 eval element 2
Generate a Matrix containing polynomials that are expensive to evaluate.
F := proc(n) option remember; if n <= 2 then n else x*F(n-1)+F(n-2); end if; end proc:
Compare the cost of an O(N^3) operation with and without rtable_eval().
dostuff1 := proc(M) local i, j, k, y; for i from 1 to op([1,1],M) do for j from 1 to op([1,2],M) do for k from 1 to op([1,2],M) do y := M[i,j]; end do; end do; end do; end proc:
dostuff2 := proc(M) local i, j, k, y; rtable_eval(M,'inplace'); for i from 1 to op([1,1],M) do for j from 1 to op([1,2],M) do for k from 1 to op([1,2],M) do y := M[i,j]; end do; end do; end do; end proc:
See Also
Array, eval, Matrix, rtable, Vector
Download Help Document