| 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/Stats/Kmeans.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_Stats_Kmeans |
|
21
|
|
|
|
|
|
|
extern Core* PDL; /* Structure hold core C functions */ |
|
22
|
|
|
|
|
|
|
#line 23 "lib/PDL/Stats/Kmeans-pp-_random_cluster.c" |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#include |
|
25
|
|
|
|
|
|
|
#include |
|
26
|
|
|
|
|
|
|
#include |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
30
|
|
|
|
|
|
|
pdl_error pdl__random_cluster_redodims(pdl_trans *__privtrans) { |
|
31
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
32
|
|
|
|
|
|
|
#line 33 "lib/PDL/Stats/Kmeans-pp-_random_cluster.c" |
|
33
|
|
|
|
|
|
|
#ifndef PDL_DECLARE_PARAMS__random_cluster_0 |
|
34
|
|
|
|
|
|
|
#define PDL_DECLARE_PARAMS__random_cluster_0(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
|
35
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, rand_data, (__privtrans->pdls[0]), 0, PDL_PPSYM_OP) \ |
|
36
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, b, (__privtrans->pdls[1]), 0, PDL_PPSYM_OP) |
|
37
|
|
|
|
|
|
|
#endif |
|
38
|
|
|
|
|
|
|
#define PDL_IF_BAD(t,f) f |
|
39
|
6
|
50
|
|
|
|
|
switch (__privtrans->__datatype) { /* Start generic switch */ |
|
40
|
6
|
|
|
|
|
|
case PDL_S: { |
|
41
|
6
|
50
|
|
|
|
|
PDL_DECLARE_PARAMS__random_cluster_0(PDL_Short,S) |
|
|
|
50
|
|
|
|
|
|
|
42
|
6
|
50
|
|
|
|
|
{if (__privtrans->ind_sizes[0] > __privtrans->ind_sizes[1]) return PDL->make_error(PDL_EUSERERROR, "Error in _random_cluster:" "more cluster than obs!");} |
|
43
|
6
|
|
|
|
|
|
} break; |
|
44
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _random_cluster: unhandled datatype(%d), only handles (S)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
#undef PDL_IF_BAD |
|
47
|
|
|
|
|
|
|
|
|
48
|
6
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
|
49
|
6
|
|
|
|
|
|
return PDL_err; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#line 1857 "lib/PDL/PP.pm" |
|
54
|
|
|
|
|
|
|
pdl_error pdl__random_cluster_readdata(pdl_trans *__privtrans) { |
|
55
|
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
56
|
|
|
|
|
|
|
#line 57 "lib/PDL/Stats/Kmeans-pp-_random_cluster.c" |
|
57
|
6
|
|
|
|
|
|
register PDL_Indx __c_size = __privtrans->ind_sizes[0]; |
|
58
|
6
|
|
|
|
|
|
register PDL_Indx __o_size = __privtrans->ind_sizes[1]; |
|
59
|
6
|
50
|
|
|
|
|
if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in _random_cluster:" "broadcast.incs NULL"); |
|
60
|
|
|
|
|
|
|
/* broadcastloop declarations */ |
|
61
|
|
|
|
|
|
|
int __brcloopval; |
|
62
|
|
|
|
|
|
|
register PDL_Indx __tind0,__tind1; /* counters along dim */ |
|
63
|
6
|
|
|
|
|
|
register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
|
64
|
|
|
|
|
|
|
/* dims here are how many steps along those dims */ |
|
65
|
6
|
|
|
|
|
|
register PDL_Indx __tinc0_rand_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
|
66
|
6
|
|
|
|
|
|
register PDL_Indx __tinc0_b = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
|
67
|
6
|
|
|
|
|
|
register PDL_Indx __tinc1_rand_data = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
|
68
|
6
|
|
|
|
|
|
register PDL_Indx __tinc1_b = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
|
69
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_START__random_cluster_readdata PDL_BROADCASTLOOP_START( \ |
|
70
|
|
|
|
|
|
|
readdata, \ |
|
71
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
72
|
|
|
|
|
|
|
__privtrans->vtable, \ |
|
73
|
|
|
|
|
|
|
rand_data_datap += __offsp[0]; \ |
|
74
|
|
|
|
|
|
|
b_datap += __offsp[1]; \ |
|
75
|
|
|
|
|
|
|
, \ |
|
76
|
|
|
|
|
|
|
( ,rand_data_datap += __tinc1_rand_data - __tinc0_rand_data * __tdims0 \ |
|
77
|
|
|
|
|
|
|
,b_datap += __tinc1_b - __tinc0_b * __tdims0 \ |
|
78
|
|
|
|
|
|
|
), \ |
|
79
|
|
|
|
|
|
|
( ,rand_data_datap += __tinc0_rand_data \ |
|
80
|
|
|
|
|
|
|
,b_datap += __tinc0_b \ |
|
81
|
|
|
|
|
|
|
) \ |
|
82
|
|
|
|
|
|
|
) |
|
83
|
|
|
|
|
|
|
#define PDL_BROADCASTLOOP_END__random_cluster_readdata PDL_BROADCASTLOOP_END( \ |
|
84
|
|
|
|
|
|
|
__privtrans->broadcast, \ |
|
85
|
|
|
|
|
|
|
rand_data_datap -= __tinc1_rand_data * __tdims1 + __offsp[0]; \ |
|
86
|
|
|
|
|
|
|
b_datap -= __tinc1_b * __tdims1 + __offsp[1]; \ |
|
87
|
|
|
|
|
|
|
) |
|
88
|
6
|
|
|
|
|
|
register PDL_Indx __inc_b_o = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_b_o;register PDL_Indx __inc_b_c = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_b_c; |
|
89
|
6
|
|
|
|
|
|
register PDL_Indx __inc_rand_data_o = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_rand_data_o; |
|
90
|
|
|
|
|
|
|
#ifndef PDL_DECLARE_PARAMS__random_cluster_1 |
|
91
|
|
|
|
|
|
|
#define PDL_DECLARE_PARAMS__random_cluster_1(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
|
92
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, rand_data, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
|
93
|
|
|
|
|
|
|
PDL_DECLARE_PARAMETER(PDL_TYPE_OP, b, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) |
|
94
|
|
|
|
|
|
|
#endif |
|
95
|
|
|
|
|
|
|
#define PDL_IF_BAD(t,f) f |
|
96
|
6
|
50
|
|
|
|
|
switch (__privtrans->__datatype) { /* Start generic switch */ |
|
97
|
6
|
|
|
|
|
|
case PDL_S: { |
|
98
|
6
|
50
|
|
|
|
|
PDL_DECLARE_PARAMS__random_cluster_1(PDL_Short,S) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
{ |
|
100
|
6
|
|
|
|
|
|
PDL_Indx nc = __privtrans->ind_sizes[0]; |
|
101
|
251
|
50
|
|
|
|
|
PDL_BROADCASTLOOP_START__random_cluster_readdata |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
102
|
790
|
100
|
|
|
|
|
{/* Open o */ PDL_EXPAND2(register PDL_Indx o=0, __o_stop=(__o_size)); for(; o<__o_stop; o+=1) { |
|
103
|
690
|
|
|
|
|
|
PDL_Indx cl = (rand_data_datap)[0+(__inc_rand_data_o*(o))] % nc; |
|
104
|
2070
|
100
|
|
|
|
|
{/* Open c */ PDL_EXPAND2(register PDL_Indx c=0, __c_stop=(__c_size)); for(; c<__c_stop; c+=1) { |
|
105
|
1380
|
|
|
|
|
|
(b_datap)[0+(__inc_b_o*(o))+(__inc_b_c*(c))] = (c == cl) ? 1 : 0; |
|
106
|
|
|
|
|
|
|
}} /* Close c */ |
|
107
|
|
|
|
|
|
|
}} /* Close o */ |
|
108
|
63
|
50
|
|
|
|
|
PDL_BROADCASTLOOP_END__random_cluster_readdata |
|
|
|
100
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
6
|
|
|
|
|
|
} break; |
|
111
|
0
|
|
|
|
|
|
default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _random_cluster: unhandled datatype(%d), only handles (S)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
#undef PDL_IF_BAD |
|
114
|
6
|
|
|
|
|
|
return PDL_err; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
static pdl_datatypes pdl__random_cluster_vtable_gentypes[] = { PDL_S, -1 }; |
|
118
|
|
|
|
|
|
|
static PDL_Indx pdl__random_cluster_vtable_realdims[] = { 1, 2 }; |
|
119
|
|
|
|
|
|
|
static char *pdl__random_cluster_vtable_parnames[] = { "rand_data","b" }; |
|
120
|
|
|
|
|
|
|
static short pdl__random_cluster_vtable_parflags[] = { |
|
121
|
|
|
|
|
|
|
0, |
|
122
|
|
|
|
|
|
|
PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE |
|
123
|
|
|
|
|
|
|
}; |
|
124
|
|
|
|
|
|
|
static pdl_datatypes pdl__random_cluster_vtable_partypes[] = { -1, -1 }; |
|
125
|
|
|
|
|
|
|
static PDL_Indx pdl__random_cluster_vtable_realdims_starts[] = { 0, 1 }; |
|
126
|
|
|
|
|
|
|
static PDL_Indx pdl__random_cluster_vtable_realdims_ind_ids[] = { 1, 1, 0 }; |
|
127
|
|
|
|
|
|
|
static char *pdl__random_cluster_vtable_indnames[] = { "c","o" }; |
|
128
|
|
|
|
|
|
|
pdl_transvtable pdl__random_cluster_vtable = { |
|
129
|
|
|
|
|
|
|
PDL_TRANS_DO_BROADCAST, 0, pdl__random_cluster_vtable_gentypes, 1, 2, NULL /*CORE21*/, |
|
130
|
|
|
|
|
|
|
pdl__random_cluster_vtable_realdims, pdl__random_cluster_vtable_parnames, |
|
131
|
|
|
|
|
|
|
pdl__random_cluster_vtable_parflags, pdl__random_cluster_vtable_partypes, |
|
132
|
|
|
|
|
|
|
pdl__random_cluster_vtable_realdims_starts, pdl__random_cluster_vtable_realdims_ind_ids, 3, |
|
133
|
|
|
|
|
|
|
2, pdl__random_cluster_vtable_indnames, |
|
134
|
|
|
|
|
|
|
pdl__random_cluster_redodims, pdl__random_cluster_readdata, NULL, |
|
135
|
|
|
|
|
|
|
NULL, |
|
136
|
|
|
|
|
|
|
0,"PDL::Stats::Kmeans::_random_cluster" |
|
137
|
|
|
|
|
|
|
}; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
6
|
|
|
|
|
|
pdl_error pdl_run__random_cluster(pdl *rand_data,pdl *b) { |
|
141
|
6
|
|
|
|
|
|
pdl_error PDL_err = {0, NULL, 0}; |
|
142
|
6
|
50
|
|
|
|
|
if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
|
143
|
6
|
|
|
|
|
|
pdl_trans *__privtrans = PDL->create_trans(&pdl__random_cluster_vtable); |
|
144
|
6
|
50
|
|
|
|
|
if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
|
145
|
6
|
|
|
|
|
|
__privtrans->pdls[0] = rand_data; |
|
146
|
6
|
|
|
|
|
|
__privtrans->pdls[1] = b; |
|
147
|
6
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
|
148
|
6
|
50
|
|
|
|
|
PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
|
149
|
6
|
|
|
|
|
|
return PDL_err; |
|
150
|
|
|
|
|
|
|
} |