help with Compiling a mex-file
이전 댓글 표시
hello Folks,
I downloaded a Matlab package for probabilistic modeling of circular data with mixtures of von Mises distributions.
please see this link
in the installation phase i have to do this :
- Clone or download this repository and add it to your MATLAB search path.
- Compile the *.mex-file located at @VonMisesMixture/private by browsing to that directory in MATLAB and running mex sampleVonMisesMex.c from the command line.
i didn't understand how to do the second step if any one can help
채택된 답변
추가 답변 (2개)
Abdelmalek Benaimeur
2019년 6월 3일
댓글 수: 1
Walter Roberson
2019년 6월 3일
Hmmm, I do not know where they are expecting to get random() from. random() is not part of the C language standard. C++ has a header named "<random>" but none of the functions are named random()
Abdelmalek Benaimeur
2019년 6월 3일
0 개 추천
댓글 수: 5
Walter Roberson
2019년 6월 3일
File a bug report with the author.
Walter Roberson
2019년 6월 4일
I checked further. It turns out that random() is part of POSIX stdlib.h but not part of any ISO C stdlib.h up to and including C18 .
Therefore the code is valid on POSIX compliant systems, and might be valid on some Unix systems that are not POSIX certified, but is potentially not valid on MS Windows.
Juha Kuortti
2021년 12월 14일
A little late, but you can also just modify the code in sampleVonMisesMex.c line 54:
srand( time(NULL) + clock() + random() );
to
srand( time(NULL) + clock());
This code initialises the random number generator ( function rand() later in the code) with only current time. In practice this should be sufficient, but for critical work you should consider something not temporally monotonic.
Richard Cui
2023년 9월 13일
Modify random() to rand(), which will do the work.
Walter Roberson
2023년 9월 13일
time() returns a time_t (data type not specified by C standard, but often some form of integer)
clock() returns a clock_t (data type not specified by C standard, but often some form of integer)
random() returns an int (not a long int)
The sum of those three is not well defined in type.
srand() requires an unsigned int parameter.
It is not obvious that adding those three types gives an appropriate parameter for srand()
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!