Lapacke in level-2 C S-function

2 Ansichten (letzte 30 Tage)
Wouter van Dijk
Wouter van Dijk am 14 Mai 2019
Kommentiert: Wouter van Dijk am 15 Mai 2019
Hi, I would like to implement the function dpotrs from LAPACKE in the level-2 C S-function. However, whenever I make a call to this function, matlab/simulink gives an internal error. The S-function runs when I put dpotrs in comments (and thus I just copy the input B). My mdlOutputs looks like the following:
static void mdlOutputs(SimStruct *S, int_T tid)
{
int_T *dimsB = ssGetInputPortDimensions(S, 1);
real_T n = dimsB[0];
real_T m = dimsB[1];
real_T q;
real_T *C;
const real_T *A = ssGetInputPortRealSignal(S,0);
const real_T *B = ssGetInputPortRealSignal(S,1);
real_T *X = ssGetOutputPortRealSignal(S,0);
memcpy( X, B, (size_t)m*(size_t)n*sizeof(real_T));
/* Solve system */
dpotrs("U", &n, &m, A, &n, X, &n, &q);
if (q < 0) ssSetErrorStatus(S,"Error: illegal input to solve_chol");
}
I am able to compile the C code with:
mex -R2018a solve_chol_sfun.c -lmwlapack
I'm quite certain that the dimensions of the variables are correct. Any suggestions?

Akzeptierte Antwort

James Tursa
James Tursa am 14 Mai 2019
Bearbeitet: James Tursa am 14 Mai 2019
According to the interface listed here and the link you list above:
The n, m, and q arguments should be integer type. Typically, when linking with the MATLAB supplied BLAS and LAPACK libraries, this means mwSignedIndex. So try:
mwSignedIndex n = dimsB[0];
mwSignedIndex m = dimsB[1];
mwSignedIndex q;

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by