Skip to Main Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate content levelBeginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
19.4 以 Trace 指令擷取有用的除錯資訊
|
749
輸出仍是相當原始的資料,但相較之下此結果已十分易於閱讀與操作了!
討論說明
一旦將
Trace
輸出線性化之後,擷取部分執行步驟或以模式擷取特定形式的資料便容易
多了! [Page-752]
ch19.indd 749 2014/4/2 下午 05:10:39
750
|
第十九章
以下使用
ReplaceList
指令找出所有
A
函數的呼叫,其中第一個引數為 0,並將其執行
前與執行後的表示式均擷取出來。
更重要地,我們要找出
"bug"
之處,並擷取其前後表示式。
但很明顯地,有些
Trace
所輸出的原始資訊在線性化動作中失去了,這些失去的資訊紀
錄著表示式的巢狀呼叫結構,但就除錯角度而言(或從嘗試了解複雜資料的角度),判
斷錯誤發生的區域才是重點。找到錯誤處之後,接下來就可放置除錯程式碼或
Print
令以進一步除錯與修正。
還有另一個與本方式極為相似的方法,使用
Trace
相關指令
TraceScan
並搭配
Reap
Sow
,差別在於此方法會輸出更詳細的資訊,包含所有符號與常數的計算。以下使用
Short
指令省略部分輸出。[Page-753]
延伸資訊
Trace
途, Mathematica
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9789863470106