Lapacke in level-2 C S-function

1 回表示 (過去 30 日間)
Wouter van Dijk
Wouter van Dijk 2019 年 5 月 14 日
コメント済み: Wouter van Dijk 2019 年 5 月 15 日
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?

採用された回答

James Tursa
James Tursa 2019 年 5 月 14 日
編集済み: James Tursa 2019 年 5 月 14 日
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 件のコメント
Wouter van Dijk
Wouter van Dijk 2019 年 5 月 15 日
Spot on, this works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by