Skip to content
\n

Step 2: Integrate Sylvester equation solver within the rprocess
\nFor this I consider the following toy example

\n
library(pomp)\nlibrary(magrittr)\nlibrary(maotai)\n\nreadLines(\"sylvester.h\") |> paste(collapse=\"\\n\") -> global.h\nreadLines(\"sylvester.c\") -> global.c\nglobal.c[grepl(\"include \\\"my_sylvester.h\\\"\",global.c)] <- global.h\nextract(global.c,!grepl(\"include \\\"sylvester.h\\\"\",global.c)) |>\n  paste(collapse=\"\\n\") -> global.c\n\nricker() |>\n  simulate(rmeasure=Csnippet(\"\n    int n = 2, m=2;\n    double A[4] = {1.0, 3.0, 2.0, 4.0};\n    double B[4] = {1.0, 0.0, 0.0, 1.0};\n    double C[4] = {5.0, 7.0, 6.0, 8.0};\n    double X[3][3];\n    solve_sylvester(A, B, C, &m, &n);\n    y = rnorm(N+C[0],1);\n    y = (y > 0) ? y : 0;\"),\n  dmeasure=Csnippet(\"\n    lik = dnorm(y,N,1,0);\n    if (give_log) lik = log(lik);\"),\n  statenames=\"N\",\n  globals=global.c\n)  -> rick4\n\nrick4 |>\n  pfilter(Np=10000) |>\n  logLik() |>\n  replicate(n=10) |>\n  logmeanexp(se=TRUE)\n
\n

sylvester.zip

\n

I have not been able to make this toy example to work. I am getting the following error:

\n
Error: in ‘simulate’: unable to load shared object '/tmp/RtmpMQc4ey/833422/pomp_753876c7d31d99a58252ecbdc9d0ea9d.so':\n  /tmp/RtmpMQc4ey/833422/pomp_753876c7d31d99a58252ecbdc9d0ea9d.so: undefined symbol: dtrsyl_\n
\n

Is this error indicating the compilation was not successful? How to link the lapack library during compilation? In step 1 I use system(\"R CMD SHLIB lapack_test.c -llapack\").

","upvoteCount":1,"answerCount":4,"acceptedAnswer":{"@type":"Answer","text":"

On the one hand, @etsagued, the answer to your question is relatively straightforward. Have a look at FAQ 3.7, which gives instructions on linking C snippets with external libraries.

\n

On the other hand, I wonder whether for such a model it is necessary to use simulation-based methods. Given the linear structure of the problem, more efficient approaches are available, no?

","upvoteCount":1,"url":"https://github.com/kingaa/pomp/discussions/211#discussioncomment-9066978"}}}

How to make a Lapack routine accessible to the Csnippet #211

Answered by kingaa
etsagued asked this question in Q&A
Discussion options

You must be logged in to vote

On the one hand, @etsagued, the answer to your question is relatively straightforward. Have a look at FAQ 3.7, which gives instructions on linking C snippets with external libraries.

On the other hand, I wonder whether for such a model it is necessary to use simulation-based methods. Given the linear structure of the problem, more efficient approaches are available, no?

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by etsagued
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants