
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    if (nrhs != {{InNum}})
    {
        mexErrMsgIdAndTxt("nrhs:", "{{InNum}} outputs required.");
    }

    if (nlhs != {{OutNum}})
    {
        mexErrMsgIdAndTxt("nrhs:", "{{OutNum}} inputs required.");
    }

    {%for k in range(OutNum)%}
    plhs[{{loop.index0}}] = mxCreateDoubleMatrix({{OutSize[loop.index0]}}, 1, mxREAL);{%endfor%}

    double {%for k in range(InNum-1)%}*{{InName[loop.index0]}}, {%endfor%}*{{InName[InNum-1]}};

    double {%for k in range(OutNum-1)%}*{{OutName[loop.index0]}}, {%endfor%}*{{OutName[OutNum-1]}};

    {%for k in range(InNum)%}
    {{InName[loop.index0]}} = mxGetPr(prhs[{{loop.index0}}]);{%endfor%}

    {%for k in range(OutNum)%}
    {{OutName[loop.index0]}} = mxGetPr(plhs[{{loop.index0}}]);{%endfor%}

    {{FuncCall}}({%for k in range(InNum)%}{{InName[loop.index0]}}, {%endfor%}{%for k in range(OutNum-1)%}{{OutName[loop.index0]}}, {%endfor%}{{OutName[OutNum-1]}});
}