File: MT.xs

package info (click to toggle)
libmath-random-mt-perl 1.17-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: ansic: 216; perl: 63; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 1,342 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"

#include "mt.h"


typedef struct mt * Math__Random__MT;

void * U32ArrayPtr ( int n ) {
    SV * sv = sv_2mortal( NEWSV( 0, n*sizeof(U32) ) );
    return SvPVX(sv);
}

MODULE = Math::Random::MT   PACKAGE = Math::Random::MT  PREFIX = mt_
PROTOTYPES: DISABLE

Math::Random::MT
mt_init()
    CODE:
        RETVAL = mt_init();
    OUTPUT:
        RETVAL

void
mt_init_seed(self, seed)
    Math::Random::MT self
    U32     seed
    CODE:
        mt_init_seed(self, seed);

void
mt_setup_array(self, array, ...)
    Math::Random::MT self;
    U32 * array = U32ArrayPtr( items );
    PREINIT:
        U32 ix_array = 0;
    CODE:
        items--;
        while ( items--) {
            array[ix_array] = (U32)SvIV(ST(ix_array+1));
            ix_array++;
        }
        mt_setup_array(self, (uint32_t*)array, ix_array);

void
mt_DESTROY(self)
    Math::Random::MT self
    CODE:
        mt_free(self);

U32
mt_get_seed(self)
    Math::Random::MT self
    CODE:
        RETVAL = mt_get_seed(self);
    OUTPUT:
        RETVAL

double
mt_genrand(self)
    Math::Random::MT self
    CODE:
        RETVAL = mt_genrand(self);
    OUTPUT:
        RETVAL

U32
mt_genirand(self)
    Math::Random::MT self
    CODE:
        RETVAL = mt_genirand(self);
    OUTPUT:
        RETVAL