Lapacke in level-2 C S-function

2 vues (au cours des 30 derniers jours)
Wouter van Dijk
Wouter van Dijk le 14 Mai 2019
Commenté : Wouter van Dijk le 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?

Réponse acceptée

James Tursa
James Tursa le 14 Mai 2019
Modifié(e) : James Tursa le 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;
  1 commentaire
Wouter van Dijk
Wouter van Dijk le 15 Mai 2019
Spot on, this works!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by