Is there an equivalent to the MATLAB parameter nargin
that can be used in AceGen?
For example, consider a function that takes in two vectors and an optional scalar. If only two vectors are inputted then the output is the dot product of the vectors. If three parameters are inputted then the output is the dot product of the vectors multiplied by the inputted scalar.
The example below illustrates the question.
(* LAUNCH ACEGEN *)
<< AceGen`;
(* INITIALIZE ACEGEN SESSION *)
SMSInitialize["ExampleFunction", "Language" -> "Matlab",
"Mode" -> "Optimal"];
SMSModule["ExampleFunction",
Real[Vec1$$[2], Vec2$$[2], Scalar$$, Output$$[2]],
"Input" -> {Vec1$$, Vec2$$, Scalar$$},
"Output" -> {Output$$}
];
(* EXTRACT INPUT DATA *)
{Vec1, Vec2, Scalar} \[DoubleRightTee] {SMSReal[{Vec1$$}],
SMSReal[{Vec2$$}], SMSReal[{Scalar$$}]};
Vec1 \[DoubleRightTee] SMSReal[Table[Vec1$$[i], {i, 1, 2}]];
Vec2 \[DoubleRightTee] SMSReal[Table[Vec2$$[i], {i, 1, 2}]];
Scalar \[DoubleRightTee] FromDigits[Scalar];
(* PERFORM CALCULATION *)
NumberOfInputArguments = 2; (* How do I determine this? *)
If[NumberOfInputArguments == 2,
Output \[DoubleRightTee] (Vec1 . Vec2);,
Output \[DoubleRightTee] Scalar (Vec1 . Vec2);];
(* EXPORT DATA *)
SMSExport[Output, Output$$];
SMSWrite[];