32
edits
(Created page with "== random == how to get equal matlab random numbers in octave - using twister(!) algorithm? * terminology: https://en.wikipedia.org/wiki/Mersenne_twister#Pseudocode * nice2k...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
== random == | * Owner of http://mxeoctave.osuv.de | ||
* markuman@gmail.com (Mail, Gtalk) | |||
* markuman@jabber.ccc.de (XMPP) | |||
* markuman on irc.freenode.net | |||
* https://keybase.io/notagain | |||
* https://github.com/markuman/ | |||
=== random === | |||
how to get equal matlab random numbers in octave - using twister(!) algorithm? | how to get equal matlab random numbers in octave - using twister(!) algorithm? | ||
Line 6: | Line 13: | ||
* nice2know: http://stackoverflow.com/questions/13735096/python-vs-octave-random-generator | * nice2know: http://stackoverflow.com/questions/13735096/python-vs-octave-random-generator | ||
=== initial situation === | ==== initial situation ==== | ||
* ruby and python using twister algo as default | * ruby and python using twister algo as default | ||
Line 48: | Line 55: | ||
=== how to get the right seed states in octave? === | ==== how to get the right seed states in octave? ==== | ||
rand('twister',0) | rand('twister',0) | ||
Line 100: | Line 107: | ||
0.602763376071644 | 0.602763376071644 | ||
Default Matlab seed is rand('twister',twister_seed(5489)) | |||
==== TODO ==== | |||
* https://savannah.gnu.org/bugs/?42557 | |||
=== compiling .mex files written by octave for matlab === | |||
Example file | |||
#include "mex.h" | |||
void | |||
mexFunction (int nlhs, mxArray *plhs[], | |||
int nrhs, const mxArray *prhs[]) | |||
{ | |||
mexPrintf ("Hello, World!\n"); | |||
mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs); | |||
} | |||
Note: Octave need the file extension .mex. Matlab needs on Linux .mexa64 and on Windows .mexw64 etc. | |||
==== using gcc or tcc on the same plattform ==== | |||
Using tcc or gcc | |||
tcc -I/usr/include/octave-3.8.1/octave/ -lm -shared mexample.c -o mexample.mex | |||
gcc -I/usr/include/octave-3.8.1/octave/ -lm -shared -fPIC mexample.c -o mexample.mex | |||
cp mexample.mex mexample.mexa64 | |||
This function can now be used on Linux x64 plattform from both, octave and matlab. | |||
* | * TODO: crosscompiling |
edits