| 1 |
|
| |
| 2 |
|
| #line 453 "lib/PDL/PP.pm" |
| 3 |
|
| /* |
| 4 |
|
| * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Slices.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_Slices |
| 21 |
|
| extern Core* PDL; /* Structure hold core C functions */ |
| 22 |
|
| |
| 23 |
|
| #line 1877 "lib/PDL/PP.pm" |
| 24 |
|
| typedef struct pdl_params_splitdim { |
| 25 |
|
| #line 26 "lib/PDL/Slices-pp-splitdim.c" |
| 26 |
|
| PDL_Indx nthdim; |
| 27 |
|
| PDL_Indx nsp; |
| 28 |
|
| } pdl_params_splitdim; |
| 29 |
|
| |
| 30 |
|
| |
| 31 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 32 |
|
| pdl_error pdl_splitdim_redodims(pdl_trans *__privtrans) { |
| 33 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 34 |
|
| #line 35 "lib/PDL/Slices-pp-splitdim.c" |
| 35 |
76 |
| pdl_params_splitdim *__params = __privtrans->params; (void)__params; |
| 36 |
76 |
| pdl *__it = __privtrans->pdls[1]; (void) __it; |
| 37 |
76 |
▶ | PDL->hdr_childcopy(__privtrans); __privtrans->dims_redone = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| PDL->hdr_childcopy(__privtrans); __privtrans->dims_redone = 1; |
0 |
76 |
76 |
|
| 38 |
|
| |
| 39 |
|
| #line 1764 "lib/PDL/Slices.pd" |
| 40 |
|
| PDL_Indx i = __params->nthdim; |
| 41 |
|
| PDL_Indx nsp = __params->nsp; |
| 42 |
|
| if(nsp == 0) {return PDL->make_error(PDL_EUSERERROR, "Error in splitdim:" "Cannot split to 0\n");} |
| 43 |
|
| if (i < 0) |
| 44 |
|
| i = __params->nthdim += __privtrans->pdls[0]->ndims; |
| 45 |
|
| if (i < 0 || i >= __privtrans->pdls[0]->ndims) |
| 46 |
|
| return PDL->make_error(PDL_EUSERERROR, "Error in splitdim:" "nthdim %"IND_FLAG" after adjusting for negative must not be negative or greater or equal to number of dims %"IND_FLAG"\n",i,__privtrans->pdls[0]->ndims); |
| 47 |
|
| if (nsp > __privtrans->pdls[0]->dims[i]) |
| 48 |
|
| return PDL->make_error(PDL_EUSERERROR, "Error in splitdim:" "nsp %"IND_FLAG" cannot be greater than dim %"IND_FLAG"\n",nsp,__privtrans->pdls[0]->dims[i]); |
| 49 |
|
| if ((__privtrans->pdls[0]->dims[i] % nsp) != 0) |
| 50 |
|
| return PDL->make_error(PDL_EUSERERROR, "Error in splitdim:" "nsp %"IND_FLAG" non-divisible into dim %"IND_FLAG"\n",nsp,__privtrans->pdls[0]->dims[i]); |
| 51 |
|
| __privtrans->offs = 0; |
| 52 |
|
| PDL_RETERROR(PDL_err, PDL->reallocdims(__it,__privtrans->pdls[0]->ndims+1));; |
| 53 |
|
| __privtrans->incs = malloc(sizeof(*__privtrans->incs) * __privtrans->pdls[1]->ndims); /* CType.get_malloc */ |
| 54 |
|
| ; |
| 55 |
|
| for(i=0; i<__params->nthdim; i++) { |
| 56 |
|
| __privtrans->pdls[1]->dims[i] = __privtrans->pdls[0]->dims[i]; |
| 57 |
|
| __privtrans->incs[i] = __privtrans->pdls[0]->dimincs[i]; |
| 58 |
|
| } |
| 59 |
|
| __privtrans->pdls[1]->dims[i] = __params->nsp; |
| 60 |
|
| __privtrans->pdls[1]->dims[i+1] = __privtrans->pdls[0]->dims[i] / __params->nsp; |
| 61 |
|
| __privtrans->incs[i] = __privtrans->pdls[0]->dimincs[i]; |
| 62 |
|
| __privtrans->incs[i+1] = __privtrans->pdls[0]->dimincs[i] * __params->nsp; |
| 63 |
|
| i++; |
| 64 |
|
| for(; i<__privtrans->pdls[0]->ndims; i++) { |
| 65 |
|
| __privtrans->pdls[1]->dims[i+1] = __privtrans->pdls[0]->dims[i]; |
| 66 |
|
| __privtrans->incs[i+1] = __privtrans->pdls[0]->dimincs[i]; |
| 67 |
|
| } |
| 68 |
|
| PDL_RETERROR(PDL_err, PDL->setdims_careful(__it));; |
| 69 |
|
| #line 70 "lib/PDL/Slices-pp-splitdim.c" |
| 70 |
74 |
| return PDL_err; |
| 71 |
|
| } |
| 72 |
|
| |
| 73 |
|
| |
| 74 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 75 |
|
| pdl_error pdl_splitdim_free(pdl_trans *__privtrans, char destroy) { |
| 76 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 77 |
|
| #line 78 "lib/PDL/Slices-pp-splitdim.c" |
| 78 |
76 |
| pdl_params_splitdim *__params = __privtrans->params; (void)__params; |
| 79 |
76 |
| pdl *__it = __privtrans->pdls[1]; (void) __it; |
| 80 |
76 |
▶ | PDL_FREE_CODE(__privtrans, destroy, , free(__privtrans->incs); /* CType.get_free */ |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_FREE_CODE(__privtrans, destroy, , free(__privtrans->incs); /* CType.get_free */ |
76 |
0 |
76 |
|
| 81 |
76 |
| ) return PDL_err; |
| 82 |
|
| } |
| 83 |
|
| |
| 84 |
|
| static pdl_datatypes pdl_splitdim_vtable_gentypes[] = { PDL_SB, PDL_B, PDL_S, PDL_US, PDL_L, PDL_UL, PDL_IND, PDL_ULL, PDL_LL, PDL_F, PDL_D, PDL_LD, PDL_CF, PDL_CD, PDL_CLD, -1 }; |
| 85 |
|
| static PDL_Indx pdl_splitdim_vtable_realdims[] = { 0, 0 }; |
| 86 |
|
| static char *pdl_splitdim_vtable_parnames[] = { "PARENT","CHILD" }; |
| 87 |
|
| static short pdl_splitdim_vtable_parflags[] = { |
| 88 |
|
| 0, |
| 89 |
|
| PDL_PARAM_ISCREAT|PDL_PARAM_ISCREATEALWAYS|PDL_PARAM_ISOUT|PDL_PARAM_ISWRITE |
| 90 |
|
| }; |
| 91 |
|
| static pdl_datatypes pdl_splitdim_vtable_partypes[] = { -1, -1 }; |
| 92 |
|
| static PDL_Indx pdl_splitdim_vtable_realdims_starts[] = { 0, 0 }; |
| 93 |
|
| static PDL_Indx pdl_splitdim_vtable_realdims_ind_ids[] = { 0 }; |
| 94 |
|
| static char *pdl_splitdim_vtable_indnames[] = { "" }; |
| 95 |
|
| pdl_transvtable pdl_splitdim_vtable = { |
| 96 |
|
| 0, PDL_ITRANS_ISAFFINE|PDL_ITRANS_DO_DATAFLOW_ANY, pdl_splitdim_vtable_gentypes, 1, 2, NULL /*CORE21*/, |
| 97 |
|
| pdl_splitdim_vtable_realdims, pdl_splitdim_vtable_parnames, |
| 98 |
|
| pdl_splitdim_vtable_parflags, pdl_splitdim_vtable_partypes, |
| 99 |
|
| pdl_splitdim_vtable_realdims_starts, pdl_splitdim_vtable_realdims_ind_ids, 0, |
| 100 |
|
| 0, pdl_splitdim_vtable_indnames, |
| 101 |
|
| pdl_splitdim_redodims, NULL, NULL, |
| 102 |
|
| pdl_splitdim_free, |
| 103 |
|
| sizeof(pdl_params_splitdim),"PDL::Slices::splitdim" |
| 104 |
|
| }; |
| 105 |
|
| |
| 106 |
|
| |
| 107 |
76 |
| pdl_error pdl_run_splitdim(pdl *PARENT,pdl *CHILD,PDL_Indx nthdim,PDL_Indx nsp) { |
| 108 |
76 |
| pdl_error PDL_err = {0, NULL, 0}; |
| 109 |
76 |
▶ | if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
0 |
76 |
76 |
|
| 110 |
76 |
| pdl_trans *__privtrans = PDL->create_trans(&pdl_splitdim_vtable); |
| 111 |
76 |
▶ | if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
0 |
76 |
76 |
|
| 112 |
76 |
| pdl_params_splitdim *__params = __privtrans->params; |
| 113 |
76 |
| __privtrans->pdls[0] = PARENT; |
| 114 |
76 |
| __privtrans->pdls[1] = CHILD; |
| 115 |
76 |
▶ | PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
0 |
76 |
76 |
|
| 116 |
76 |
| (__params->nthdim) = (nthdim); /* CType.get_copy */ |
| 117 |
76 |
| (__params->nsp) = (nsp); /* CType.get_copy */ |
| 118 |
76 |
▶ | PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
0 |
76 |
76 |
|
| 119 |
76 |
| return PDL_err; |
| 120 |
|
| } |