我通過Matlab編碼器創建了一個名爲implicit_enumeration.cpp的C++程序,它採用矩陣A和向量b作爲輸入,並返回向量zstar和概率值Vstar。我現在努力初始化主要功能:初始化Matlab編碼器的主函數
// Include Files
#include "stdafx.h"
#include "implicit_enumeration.h"
#include "main.h"
// Function Declarations
static void argInit_4x1_real_T(double result[4]);
static void argInit_4x9_real_T(double result[36]);
static void main_implicit_enumeration();
// Function Definitions
static void argInit_4x1_real_T(double result[4])
{
int idx0;
// Loop over the array to initialize each element.
for (idx0 = 0; idx0 < 4; idx0++) {
// Set the value of the array element.
// Change this value to the value that the application requires.
result[idx0] = 1;
}
}
static void argInit_4x9_real_T(double result[36])
{
int idx0;
int idx1;
// Loop over the array to initialize each element.
for (idx0 = 0; idx0 < 4; idx0++) {
for (idx1 = 0; idx1 < 9; idx1++) {
// Set the value of the array element.
// Change this value to the value that the application requires.
if (idx0 == 0) {
if (idx1 == 0) { result[idx0 + (idx1 << 2)] = 1; }
else if (idx1 == 1) { result[idx0 + (idx1 << 2)] = 1; }
else { result[idx0 + (idx1 << 2)] = 0; }
}
else if (idx0 == 1) {
if (idx1 == 2) { result[idx0 + (idx1 << 2)] = 1; }
else if (idx1 == 3) { result[idx0 + (idx1 << 2)] = 1; }
else if (idx1 == 4) { result[idx0 + (idx1 << 2)] = 1; }
else { result[idx0 + (idx1 << 2)] = 0; }
}
else if (idx0 == 2) {
if (idx1 == 5) { result[idx0 + (idx1 << 2)] = 1; }
else { result[idx0 + (idx1 << 2)] = 0; }
}
else {
if (idx1 == 6) { result[idx0 + (idx1 << 2)] = 1; }
else if (idx1 == 7) { result[idx0 + (idx1 << 2)] = 1; }
else if (idx1 == 8) { result[idx0 + (idx1 << 2)] = 1; }
else { result[idx0 + (idx1 << 2)] = 0; }
}
}
}
}
static void main_implicit_enumeration()
{
double dv0[36];
double dv1[4];
double zstar[9];
double Vstar;
// Initialize function 'implicit_enumeration' input arguments.
// Initialize function input argument 'A'.
// Initialize function input argument 'b'.
// Call the entry-point 'implicit_enumeration'.
argInit_4x9_real_T(dv0);
argInit_4x1_real_T(dv1);
implicit_enumeration(dv0, dv1, zstar, &Vstar);
}
int main(int argc, const char * const argv[])
{
// Initialize the application.
// You do not need to do this more than one time.
// Invoke the entry-point functions.
// You can call entry-point functions multiple times.
main_implicit_enumeration();
return 0;
}
具體而言,我想知道如何初始化的argv []作爲基質A和矢量b。即使我已經通過函數argInit_4x9_real_T()和argInit_4x1_real_T()初始化矩陣A和向量b,是否需要設置命令參數?如果是,如何將矩陣和向量包含爲命令參數?我檢查的例子總是顯示單個整數或實數值,但不是矩陣或向量。 提前謝謝!
+0
'argv []'沒有用在代碼中。不清楚你的意思是「初始化主要功能」 –