Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner 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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106