| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
#line 453 "lib/PDL/PP.pm" |
|
3
|
|
|
|
|
|
|
/* |
|
4
|
|
|
|
|
|
|
* THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Primitive.pd! Do not modify! |
|
5
|
|
|
|
|
|
|
*/ |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \ |
|
8
|
|
|
|
|
|
|
if (destroy) { \ |
|
9
|
|
|
|
|
|
|
comp_free_code \ |
|
10
|
|
|
|
|
|
|
} \ |
|
11
|
|
|
|
|
|
|
if ((trans)->dims_redone) { \ |
|
12
|
|
|
|
|
|
|
ntpriv_free_code \ |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
16
|
|
|
|
|
|
|
#include "perl.h" |
|
17
|
|
|
|
|
|
|
#include "XSUB.h" |
|
18
|
|
|
|
|
|
|
#include "pdl.h" |
|
19
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
20
|
|
|
|
|
|
|
#define PDL PDL_Primitive |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
#line 23 "lib/PDL/Primitive-pp-srandom.c" |
|
23
|
|
|
|
|
|
|
extern int pdl_srand_threads; |
|
24
|
|
|
|
|
|
|
extern uint64_t *pdl_rand_state; |
|
25
|
|
|
|
|
|
|
void pdl_srand(uint64_t **s, uint64_t seed, int n); |
|
26
|
|
|
|
|
|
|
double pdl_drand(uint64_t *s); |
|
27
|
|
|
|
|
|
|
#define PDL_MAYBE_SRAND \ |
|
28
|
|
|
|
|
|
|
if (pdl_srand_threads < 0) \ |
|
29
|
|
|
|
|
|
|
pdl_srand(&pdl_rand_state, PDL->pdl_seed(), PDL->online_cpus()); |
|
30
|
|
|
|
|
|
|
#define PDL_RAND_SET_OFFSET(v, thr, pdl) \ |
|
31
|
|
|
|
|
|
|
if (v < 0) { \ |
|
32
|
|
|
|
|
|
|
if (thr.mag_nthr >= 0) { \ |
|
33
|
|
|
|
|
|
|
int thr_no = PDL->magic_get_thread(pdl); \ |
|
34
|
|
|
|
|
|
|
if (thr_no < 0) return PDL->make_error_simple(PDL_EFATAL, "Invalid pdl_magic_get_thread!"); \ |
|
35
|
|
|
|
|
|
|
v = thr_no == 0 ? thr_no : thr_no % PDL->online_cpus(); \ |
|
36
|
|
|
|
|
|
|
} else { \ |
|
37
|
|
|
|
|
|
|
v = 0; \ |
|
38
|
|
|
|
|
|
|
} \ |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
42
|
|
|
|
|
|
|
pdl_error pdl_srandom_readdata(pdl_trans *__privtrans) { |
|
43
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
44
|
|
|
|
|
|
|
#line 45 "lib/PDL/Primitive-pp-srandom.c" |
|
45
|
|
|
|
|
|
|
#ifndef PDL_DECLARE_PARAMS_srandom_1 |
|
46
|
|
|
|
|
|
|
#define PDL_DECLARE_PARAMS_srandom_1(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
|
47
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) |
|
48
|
|
|
|
|
|
|
#endif |
|
49
|
|
|
|
|
|
|
#define PDL_IF_BAD(t,f) f |
|
50
|
4
|
50
|
|
|
|
|
switch (__privtrans->__datatype) { /* Start generic switch */ |
|
51
|
4
|
|
|
|
|
|
case PDL_LL: { |
|
52
|
4
|
50
|
|
|
|
|
PDL_DECLARE_PARAMS_srandom_1(PDL_LongLong,Q) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
|
{pdl_srand(&pdl_rand_state, (uint64_t)(a_datap)[0], PDL->online_cpus()); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
4
|
|
|
|
|
|
} break; |
|
56
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in srandom: unhandled datatype(%d), only handles (Q)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
#undef PDL_IF_BAD |
|
59
|
4
|
|
|
|
|
|
return PDL_err; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
static pdl_datatypes pdl_srandom_vtable_gentypes[] = { PDL_LL, -1 }; |
|
63
|
|
|
|
|
|
|
static PDL_Indx pdl_srandom_vtable_realdims[] = { 0 }; |
|
64
|
|
|
|
|
|
|
static char *pdl_srandom_vtable_parnames[] = { "a" }; |
|
65
|
|
|
|
|
|
|
static short pdl_srandom_vtable_parflags[] = { |
|
66
|
|
|
|
|
|
|
0 |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
|
|
|
|
|
|
static pdl_datatypes pdl_srandom_vtable_partypes[] = { -1 }; |
|
69
|
|
|
|
|
|
|
static PDL_Indx pdl_srandom_vtable_realdims_starts[] = { 0 }; |
|
70
|
|
|
|
|
|
|
static PDL_Indx pdl_srandom_vtable_realdims_ind_ids[] = { 0 }; |
|
71
|
|
|
|
|
|
|
static char *pdl_srandom_vtable_indnames[] = { "" }; |
|
72
|
|
|
|
|
|
|
pdl_transvtable pdl_srandom_vtable = { |
|
73
|
|
|
|
|
|
|
PDL_TRANS_NO_PARALLEL, 0, pdl_srandom_vtable_gentypes, 1, 1, NULL /*CORE21*/, |
|
74
|
|
|
|
|
|
|
pdl_srandom_vtable_realdims, pdl_srandom_vtable_parnames, |
|
75
|
|
|
|
|
|
|
pdl_srandom_vtable_parflags, pdl_srandom_vtable_partypes, |
|
76
|
|
|
|
|
|
|
pdl_srandom_vtable_realdims_starts, pdl_srandom_vtable_realdims_ind_ids, 0, |
|
77
|
|
|
|
|
|
|
0, pdl_srandom_vtable_indnames, |
|
78
|
|
|
|
|
|
|
NULL, pdl_srandom_readdata, NULL, |
|
79
|
|
|
|
|
|
|
NULL, |
|
80
|
|
|
|
|
|
|
0,"PDL::Primitive::srandom" |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
|
pdl_error pdl_run_srandom(pdl *a) { |
|
85
|
4
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
86
|
4
|
50
|
|
|
|
|
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
|
87
|
4
|
|
|
|
|
|
pdl_trans *__privtrans = PDL->create_trans(&pdl_srandom_vtable); |
|
88
|
4
|
50
|
|
|
|
|
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
|
89
|
4
|
|
|
|
|
|
__privtrans->pdls[0] = a; |
|
90
|
4
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
|
91
|
4
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
|
92
|
4
|
|
|
|
|
|
return PDL_err; |
|
93
|
|
|
|
|
|
|
} |