c++ - Initializing main function from Matlab Coder -
i created c++ program through matlab coder called implicit_enumeration.cpp takes matrix , vector b input , returns vector zstar , probability value vstar. struggling initialize main function:
// 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 on array initialize each element. (idx0 = 0; idx0 < 4; idx0++) { // set value of array element. // change value value application requires. result[idx0] = 1; } } static void arginit_4x9_real_t(double result[36]) { int idx0; int idx1; // loop on array initialize each element. (idx0 = 0; idx0 < 4; idx0++) { (idx1 = 0; idx1 < 9; idx1++) { // set value of array element. // change value value 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 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 application. // not need more 1 time. // invoke entry-point functions. // can call entry-point functions multiple times. main_implicit_enumeration(); return 0; }
specifically, wondering how initialize argv[] matrix , vector b. necessary set command arguments though initialized matrix , vector b through functions arginit_4x9_real_t() , arginit_4x1_real_t()? if yes, how include matrix , vector command arguments? examples checked show single integer or real values, not matrix or vectors. thank in advance!
actually, done.
in main(int argc, const char * const argv[]): argc number of of command line arguments, argv contains these command line arguments.
example: if call test.ext something
, argc 2, argv[0] "test.exe", argv[1] "something".
your initialization done in main_implicit_enumeration()
- dv0 matrix (4*9 matrix -> 36 elements), , initialized in arginit_4x9_real_t()
- dv1 vector b (4 vector -> 4 elements), , initialized in arginit_4x1_real_t
- zstar return vector
- vstar skalar return
question is: how want pass values program? load values file? use format test.ext a=1,2,3;4,5,6 b=8,9
?
Comments
Post a Comment