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 錦囊妙計
30
|
第二章
而另一種定義方式稍嫌冗長,但當 upvalue 的歸屬權模糊不清的情況下,還蠻方便的。
例如:定義四元數與複數的加法時,若使用前述第一種方式定義 upvalue,此時 upvalue
應屬於四元數或複數並未清楚界定,則可使用
TagSet
TagSetDelayed
語法明確指定屬
四元數
quaternion
upvalue,而非複數
Complex
[Page-029]
upvalue 的語 解決 兩個 題:首 先,你 必解 保護 Mathematica 的內 建指 令;
其次,設定 upvalue 可以避免 Mathematica 每次執行更改過的內建指令時(如
Plus
Times
指令),均優先檢查自訂定義,而導致效能變差的情況。藉由新物件的 upvalue
設定,Mathematica 在新 件出 的情 下才 考慮 操作 義,當 upvalue
downvalue 同時存在的情況下,upvalue 有較高的優先權,但你應盡量避免這種情況。
函數屬性
Mathematica 根據一組事先規範的函數屬性控制函數行為,使用者應熟悉這些屬性,
合。
Attributes[f]
SetAttributes[f,attr]
ClearAttributes[f,attr]
f
詢、設定
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