18 |
|
extern "C" void |
19 |
|
plan_transport(MIGRATION *mig) |
20 |
|
{ |
21 |
< |
double src[mtx_nrows(mig)]; |
22 |
< |
double dst[mtx_ncols(mig)]; |
21 |
> |
double *src; |
22 |
> |
double *dst; |
23 |
> |
TsFlow *flow; |
24 |
> |
|
25 |
> |
src = new double[mtx_nrows(mig)]; |
26 |
> |
dst = new double[mtx_ncols(mig)]; |
27 |
> |
|
28 |
|
TsSignature<RBFVAL> srcSig(mtx_nrows(mig), mig->rbfv[0]->rbfa, src); |
29 |
|
TsSignature<RBFVAL> dstSig(mtx_ncols(mig), mig->rbfv[1]->rbfa, dst); |
30 |
< |
TsFlow flow[mtx_nrows(mig)+mtx_ncols(mig)-1]; |
30 |
> |
flow = new TsFlow[mtx_nrows(mig)+mtx_ncols(mig)-1]; |
31 |
|
int n; |
32 |
|
/* clear flow matrix */ |
33 |
|
memset(mig->mtx, 0, sizeof(float)*mtx_nrows(mig)*mtx_ncols(mig)); |
47 |
|
progname); |
48 |
|
exit(1); |
49 |
|
} |
50 |
+ |
if (n > mtx_nrows(mig)+mtx_ncols(mig)-1) { |
51 |
+ |
fprintf(stderr, "%s: signature overflow in plan_transport()!\n", |
52 |
+ |
progname); |
53 |
+ |
exit(1); |
54 |
+ |
} |
55 |
|
while (n-- > 0) /* assign sparse matrix */ |
56 |
|
mtx_coef(mig, flow[n].from, flow[n].to) = flow[n].amount; |
57 |
+ |
|
58 |
+ |
delete[] src; |
59 |
+ |
delete[] dst; |
60 |
+ |
delete[] flow; |
61 |
|
} |