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
CodeGeneration[VisualBasic] - Maple コードの Visual Basic コードへの変換
使い方
VisualBasic(x, cgopts)
パラメータ
x - 数式、リスト、配列、rtable、手続き、またはモジュール
cgopts - (オプション) 1つまたはそれ以上の CodeGeneration オプション
説明
VisualBasic 関数は、Maple のコードを Visual Basic コードに変換します。
- パラメータ x が代数式の場合、その数式に1つの変数を割り当てる形で1つの Visual Basic の命令文が生成されます。
- パラメータ x が代数式のリスト、rtable または Maple の配列の場合、それら要素をVisual Basic 配列に割り当てる形で、 Visual Basic の命令文の列が作成されます。rtable または Maple の配列では、初期化された要素だけが変換されます。
- パラメータ x が nm=expr の形のリスト(ここで nm 名前、expr は代数式を表す)である場合、x は割り当てられた命令文の列を意味するものとして解釈されます。 この場合、等価な意味を持つ Visual Basic の割り当て命令文の列が生成されます。
- パラメータ x が Maple の手続きである場合、 その手続きと等価な関数を含む Visual Basic モジュールが必要な import 文とともに生成されます。
- パラメータ x がモジュールである場合、 VisualBasicDetails に述べるように、Visual Basic モジュールが生成されます。
パラメータ cgopts は、1つまたはそれ以上の CodeGeneration のオプションを含みます。オプションについては、CodeGenerationOptions に記述されています。
CodeGeneration パッケージが Maple のコードを他の言語にどのように変換するかに関する詳細な情報は、CodeGenerationDetails を参照して下さい。 特に VisualBasic への変換に関する詳細な情報を得たい場合には、 VisualBasicDetails を参照して下さい。
例
以下の例で使用されているオプションの記述方法については、CodeGenerationOptions を参照して下さい。
with(CodeGeneration):
Warning, the protected name Matlab has been redefined and unprotected
単純な数式を変換し、目的のコード内の名前``w'' に割り当てます。
VisualBasic(x+y*z-2*x*z, resultname="w");
w = x + y * z - 2 * x * z
リストを変換し、目的のコード内の名前``w'' の配列に割り当てます。
VisualBasic([[x, 2*y], [5, z]], resultname="w");
w(0,0) = x w(0,1) = 2 * y w(1,0) = 5 w(1,1) = z
計算の列を変換します。入力をまず最初に最適化します。
cs := [s=1.0+x, t=ln(s)*exp(-x), r=exp(-x)+x*t]: VisualBasic(cs, optimize);
s = 0.10E1 + x t1 = Log(s) t2 = Exp(-x) t = t1 * t2 r = t2 + x * t
x が浮動小数点数、 y が整数であることを宣言します。結果が文字列内に返されます。
s := VisualBasic(x+y+1, declare=[x::float, y::integer], output=string);
手続きを変換します。型宣言されていない変数全てが、整数型 integerであると仮定します。
f := proc(x, y, z) return x*y-y*z+x*z; end proc: VisualBasic(f, defaulttype=integer);
Public Module CodeGenerationModule Public Function f( _ ByVal x As Integer, _ ByVal y As Integer, _ ByVal z As Integer) As Integer Return x * y - y * z + x * z End Function End Module
間接的な戻り値を含む手続きを変換します。戻り値を保持するための新しい変数が作成されます。
f := proc(n) local x, i; x := 0.0; for i to n do x := x + i; end do; end proc: VisualBasic(f);
Public Module CodeGenerationModule Public Function f(ByVal n As Integer) As Double Dim x As Double Dim i As Integer Dim cgret As Double x = 0.0E0 For i = 1 To n x = x + CDbl(i) cgret = x Next Return cgret End Function End Module
配列をパラメータとして受け入れている手続きを変換します。 Visual Basic の配列がインデックス 0 から始まるように、添え字の番号は付け直されます。
f := proc(x::Array(numeric, 5..7)) return x[5]+x[6]+x[7]; end proc: VisualBasic(f);
Public Module CodeGenerationModule Public Function f(ByVal x() As Double) As Double Return x(0) + x(1) + x(2) End Function End Module
エクスポートプロシージャとローカルプロシージャをもつモジュールを変換します。
m := module() export p; local q; p := proc(x,y) if y>0 then trunc(x); else ceil(x); end if; end proc: q := proc(x) sin(x)^2; end proc: end module: VisualBasic(m, resultname=t0);
Imports System.Math Public Module m Public Function p(ByVal x As Double, ByVal y As Integer) As Integer If (0 < y) Then Return Fix(x) Else Return Ceiling(x) End If End Function Private Function q(ByVal x As Double) As Double Return Pow(Sin(x), 0.2E1) End Function End Module
双曲三角関数の線形結合を変換します。
VisualBasic(2*cosh(x)-7*tanh(x));
cg0 = 0.2E1 * Cosh(x) - 0.7E1 * Tanh(x)
戻り値を持たない、出力命令文 printf を含んだ手続きを変換します。
f := proc(a::integer, p::integer) printf("The integer remainder of %d divided by %d is: %d\n", a, p, irem(a, p)); end proc: VisualBasic(f);
Public Module CodeGenerationModule Public Sub f(ByVal a As Integer, ByVal p As Integer) System.Console.WriteLine("The integer remainder of " & a & " divided by " & p & " is: " & a Mod p) End Sub End Module
参照
CodeGeneration, CodeGenerationDetails, CodeGenerationOptions, trademarks, VisualBasicDetails
Download Help Document