| 1 |
|
| |
| 2 |
|
| #line 453 "lib/PDL/PP.pm" |
| 3 |
|
| /* |
| 4 |
|
| * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/MatrixOps.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_MatrixOps |
| 21 |
|
| extern Core* PDL; /* Structure hold core C functions */ |
| 22 |
|
| #line 23 "lib/PDL/MatrixOps-pp-eigens_sym.c" |
| 23 |
|
| |
| 24 |
|
| #include <math.h> |
| 25 |
|
| |
| 26 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 27 |
|
| pdl_error pdl_eigens_sym_redodims(pdl_trans *__privtrans) { |
| 28 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 29 |
|
| #line 30 "lib/PDL/MatrixOps-pp-eigens_sym.c" |
| 30 |
|
| #ifndef PDL_DECLARE_PARAMS_eigens_sym_0 |
| 31 |
|
| #define PDL_DECLARE_PARAMS_eigens_sym_0(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
| 32 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[0]), 0, PDL_PPSYM_OP) \ |
| 33 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ev, (__privtrans->pdls[1]), 0, PDL_PPSYM_OP) \ |
| 34 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, e, (__privtrans->pdls[2]), 0, PDL_PPSYM_OP) |
| 35 |
|
| #endif |
| 36 |
|
| #define PDL_IF_BAD(t,f) f |
| 37 |
5 |
▶ | switch (__privtrans->__datatype) { /* Start generic switch */ |
Branch: 1 branch
| Branch | True | False | Total |
| switch (__privtrans->__datatype) { /* Start generic switch */ |
5 |
0 |
5 |
|
| 38 |
5 |
| case PDL_D: { |
| 39 |
5 |
▶ | PDL_DECLARE_PARAMS_eigens_sym_0(PDL_Double,D) |
Branch: 3 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_eigens_sym_0(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_0(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_0(PDL_Double,D) |
0 |
5 |
5 |
|
| 40 |
5 |
| {float n = (sqrtf(1 + 8*__privtrans->ind_sizes[0]) - 1)/2; |
| 41 |
5 |
| __privtrans->ind_sizes[1] = roundf(n); |
| 42 |
5 |
▶ | if (fabsf(__privtrans->ind_sizes[1] - n) > 0.0001) |
Branch: 1 branch
| Branch | True | False | Total |
| if (fabsf(__privtrans->ind_sizes[1] - n) > 0.0001) |
0 |
5 |
5 |
|
| 43 |
0 |
| return PDL->make_error(PDL_EUSERERROR, "Error in eigens_sym:" "Non-triangular vector size=%"IND_FLAG,__privtrans->ind_sizes[0]); |
| 44 |
|
| } |
| 45 |
5 |
| } break; |
| 46 |
0 |
| default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in eigens_sym: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
| 47 |
|
| } |
| 48 |
|
| #undef PDL_IF_BAD |
| 49 |
|
| |
| 50 |
5 |
▶ | PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
0 |
5 |
5 |
|
| 51 |
5 |
| return PDL_err; |
| 52 |
|
| } |
| 53 |
|
| |
| 54 |
|
| |
| 55 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 56 |
|
| pdl_error pdl_eigens_sym_readdata(pdl_trans *__privtrans) { |
| 57 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 58 |
|
| #line 59 "lib/PDL/MatrixOps-pp-eigens_sym.c" |
| 59 |
5 |
▶ | if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in eigens_sym:" "broadcast.incs NULL"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in eigens_sym:" "broadcast.incs NULL"); |
0 |
5 |
5 |
|
| 60 |
|
| /* broadcastloop declarations */ |
| 61 |
|
| int __brcloopval; |
| 62 |
|
| register PDL_Indx __tind0,__tind1; /* counters along dim */ |
| 63 |
5 |
| register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
| 64 |
|
| /* dims here are how many steps along those dims */ |
| 65 |
5 |
| register PDL_Indx __tinc0_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
| 66 |
5 |
| register PDL_Indx __tinc0_ev = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
| 67 |
5 |
| register PDL_Indx __tinc0_e = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0); |
| 68 |
5 |
| register PDL_Indx __tinc1_a = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
| 69 |
5 |
| register PDL_Indx __tinc1_ev = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
| 70 |
5 |
| register PDL_Indx __tinc1_e = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1); |
| 71 |
|
| #define PDL_BROADCASTLOOP_START_eigens_sym_readdata PDL_BROADCASTLOOP_START( \ |
| 72 |
|
| readdata, \ |
| 73 |
|
| __privtrans->broadcast, \ |
| 74 |
|
| __privtrans->vtable, \ |
| 75 |
|
| a_datap += __offsp[0]; \ |
| 76 |
|
| ev_datap += __offsp[1]; \ |
| 77 |
|
| e_datap += __offsp[2]; \ |
| 78 |
|
| , \ |
| 79 |
|
| ( ,a_datap += __tinc1_a - __tinc0_a * __tdims0 \ |
| 80 |
|
| ,ev_datap += __tinc1_ev - __tinc0_ev * __tdims0 \ |
| 81 |
|
| ,e_datap += __tinc1_e - __tinc0_e * __tdims0 \ |
| 82 |
|
| ), \ |
| 83 |
|
| ( ,a_datap += __tinc0_a \ |
| 84 |
|
| ,ev_datap += __tinc0_ev \ |
| 85 |
|
| ,e_datap += __tinc0_e \ |
| 86 |
|
| ) \ |
| 87 |
|
| ) |
| 88 |
|
| #define PDL_BROADCASTLOOP_END_eigens_sym_readdata PDL_BROADCASTLOOP_END( \ |
| 89 |
|
| __privtrans->broadcast, \ |
| 90 |
|
| a_datap -= __tinc1_a * __tdims1 + __offsp[0]; \ |
| 91 |
|
| ev_datap -= __tinc1_ev * __tdims1 + __offsp[1]; \ |
| 92 |
|
| e_datap -= __tinc1_e * __tdims1 + __offsp[2]; \ |
| 93 |
|
| ) |
| 94 |
5 |
| register PDL_Indx __inc_a_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_a_m; |
| 95 |
5 |
| register PDL_Indx __inc_e_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_e_n; |
| 96 |
5 |
| register PDL_Indx __inc_ev_n0 = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_ev_n0;register PDL_Indx __inc_ev_n1 = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,1)]; (void)__inc_ev_n1; |
| 97 |
|
| #ifndef PDL_DECLARE_PARAMS_eigens_sym_1 |
| 98 |
|
| #define PDL_DECLARE_PARAMS_eigens_sym_1(PDL_TYPE_OP,PDL_PPSYM_OP) \ |
| 99 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, a, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
| 100 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, ev, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \ |
| 101 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, e, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) |
| 102 |
|
| #endif |
| 103 |
|
| #define PDL_IF_BAD(t,f) f |
| 104 |
5 |
▶ | switch (__privtrans->__datatype) { /* Start generic switch */ |
Branch: 1 branch
| Branch | True | False | Total |
| switch (__privtrans->__datatype) { /* Start generic switch */ |
5 |
0 |
5 |
|
| 105 |
5 |
| case PDL_D: { |
| 106 |
5 |
▶ | PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
Branch: 9 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
5 |
0 |
5 |
| PDL_DECLARE_PARAMS_eigens_sym_1(PDL_Double,D) |
0 |
5 |
5 |
|
| 107 |
20 |
▶ | PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
Branch: 7 branches
| Branch | True | False | Total |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
0 |
5 |
5 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
5 |
5 |
10 |
| PDL_BROADCASTLOOP_START_eigens_sym_readdata {extern void eigens( double *A, double *EV, double *E, int N ); |
5 |
5 |
10 |
|
| 108 |
5 |
| eigens(a_datap, ev_datap, e_datap, __privtrans->ind_sizes[1]); |
| 109 |
5 |
▶ | }PDL_BROADCASTLOOP_END_eigens_sym_readdata |
Branch: 2 branches
| Branch | True | False | Total |
| }PDL_BROADCASTLOOP_END_eigens_sym_readdata |
0 |
5 |
5 |
| }PDL_BROADCASTLOOP_END_eigens_sym_readdata |
0 |
5 |
5 |
|
| 110 |
5 |
| } break; |
| 111 |
0 |
| default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in eigens_sym: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
| 112 |
|
| } |
| 113 |
|
| #undef PDL_IF_BAD |
| 114 |
5 |
| return PDL_err; |
| 115 |
|
| } |
| 116 |
|
| |
| 117 |
|
| static pdl_datatypes pdl_eigens_sym_vtable_gentypes[] = { PDL_D, -1 }; |
| 118 |
|
| static PDL_Indx pdl_eigens_sym_vtable_realdims[] = { 1, 2, 1 }; |
| 119 |
|
| static char *pdl_eigens_sym_vtable_parnames[] = { "a","ev","e" }; |
| 120 |
|
| static short pdl_eigens_sym_vtable_parflags[] = { |
| 121 |
|
| PDL_PARAM_ISPHYS, |
| 122 |
|
| PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE, |
| 123 |
|
| PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE |
| 124 |
|
| }; |
| 125 |
|
| static pdl_datatypes pdl_eigens_sym_vtable_partypes[] = { -1, -1, -1 }; |
| 126 |
|
| static PDL_Indx pdl_eigens_sym_vtable_realdims_starts[] = { 0, 1, 3 }; |
| 127 |
|
| static PDL_Indx pdl_eigens_sym_vtable_realdims_ind_ids[] = { 0, 1, 1, 1 }; |
| 128 |
|
| static char *pdl_eigens_sym_vtable_indnames[] = { "m","n" }; |
| 129 |
|
| pdl_transvtable pdl_eigens_sym_vtable = { |
| 130 |
|
| PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADIGNORE, 0, pdl_eigens_sym_vtable_gentypes, 1, 3, NULL /*CORE21*/, |
| 131 |
|
| pdl_eigens_sym_vtable_realdims, pdl_eigens_sym_vtable_parnames, |
| 132 |
|
| pdl_eigens_sym_vtable_parflags, pdl_eigens_sym_vtable_partypes, |
| 133 |
|
| pdl_eigens_sym_vtable_realdims_starts, pdl_eigens_sym_vtable_realdims_ind_ids, 4, |
| 134 |
|
| 2, pdl_eigens_sym_vtable_indnames, |
| 135 |
|
| pdl_eigens_sym_redodims, pdl_eigens_sym_readdata, NULL, |
| 136 |
|
| NULL, |
| 137 |
|
| 0,"PDL::MatrixOps::eigens_sym" |
| 138 |
|
| }; |
| 139 |
|
| |
| 140 |
|
| |
| 141 |
5 |
| pdl_error pdl_run_eigens_sym(pdl *a,pdl *ev,pdl *e) { |
| 142 |
5 |
| pdl_error PDL_err = {0, NULL, 0}; |
| 143 |
5 |
▶ | 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 |
5 |
5 |
|
| 144 |
5 |
| pdl_trans *__privtrans = PDL->create_trans(&pdl_eigens_sym_vtable); |
| 145 |
5 |
▶ | 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 |
5 |
5 |
|
| 146 |
5 |
| __privtrans->pdls[0] = a; |
| 147 |
5 |
| __privtrans->pdls[1] = ev; |
| 148 |
5 |
| __privtrans->pdls[2] = e; |
| 149 |
5 |
▶ | PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
0 |
5 |
5 |
|
| 150 |
5 |
▶ | 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 |
5 |
5 |
|
| 151 |
5 |
| return PDL_err; |
| 152 |
|
| } |