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 錦囊妙計
690
|
第十七章
17.4 呼叫 C C++ 函式
問題點
你想從 Mathematica 呼叫 C 語言的函式。
解決方案
以下將介紹如何由 Mathematica 呼叫 C 語言建立的函式。本範例使用 Microsoft Visual
C++ 2005 版本,其他程式設計環境請參考「延伸資訊」。Mathematica C 語言進行溝
通的最簡單方式是透過 mprep 處理器,它藉由 C 函式的樣板描述檔案產生黏合程式碼
glue code),作為 Mathematica C 函式溝通的介面,以下是一個 mprep 的樣板描述
檔案範例,檔案中包含 3 C 函式。[Page-695]
以下是相對應的 C 語言程式碼。需注意 Mathematica 串列是以 C 陣列指標的方式傳入
C 函式,而且 C 陣列的長度也需定義額外引數傳入函式。下列程式碼中的
WinMain
Microsoft Visual Studio Windows 程式必須具備的,
WinMain
函式內容是固定的,可以
ch17.indd 690 2014/4/2 下午 04:27:19
17.4 呼叫 C C++ 函式
|
691
直接複製到自己的專案中,至於這些函式的內容並非一定得用 C 語言實作不
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