| 1 | /* specfunc/mathieu_workspace.c |
| 2 | * |
| 3 | * Copyright (C) 2003 Lowell Johnson |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | /* Author: L. Johnson */ |
| 21 | |
| 22 | #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/ |
| 23 | #include <stdlib.h> |
| 24 | #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/ |
| 25 | #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/ |
| 26 | #include "gsl_sf_mathieu.h"cxx . . $ `<file>/external/gsl/gsl_sf_mathieu.h`/ |
| 27 | |
| 28 | |
| 29 | gsl_sf_mathieu_workspacecxx . . $ gsl_sf_mathieu_workspace# *gsl_sf_mathieu_alloccxx . . $ gsl_sf_mathieu_alloc(53f09d5e7c470cd).(const size_t nn, |
| 30 | const double qq) |
| 31 | { |
| 32 | gsl_sf_mathieu_workspacecxx . . $ gsl_sf_mathieu_workspace# *workspace; |
| 33 | unsigned int even_order = nn/2 + 1, odd_order = (nn + 1)/2, |
| 34 | extra_values; |
| 35 | |
| 36 | /* Compute the maximum number of extra terms required for 10^-18 root |
| 37 | accuracy for a given value of q (contributed by Brian Gladman). */ |
| 38 | extra_values = (int)(2.1*pow(fabs(qq), 0.37)) + 9; |
| 39 | |
| 40 | if (nn + 1 == 0) |
| 41 | { |
| 42 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("matrix dimension must be positive integer", GSL_EINVAL); |
| 43 | } |
| 44 | |
| 45 | workspace = |
| 46 | (gsl_sf_mathieu_workspacecxx . . $ gsl_sf_mathieu_workspace# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(gsl_sf_mathieu_workspacecxx . . $ gsl_sf_mathieu_workspace#)); |
| 47 | if (workspace == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 48 | { |
| 49 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for workspace", GSL_ENOMEM); |
| 50 | } |
| 51 | |
| 52 | /* Extend matrices to ensure accuracy. */ |
| 53 | even_order += extra_values; |
| 54 | odd_order += extra_values; |
| 55 | |
| 56 | workspace->sizecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#size. = nn; |
| 57 | workspace->even_ordercxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#even_order. = even_order; |
| 58 | workspace->odd_ordercxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#odd_order. = odd_order; |
| 59 | workspace->extra_valuescxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#extra_values. = extra_values; |
| 60 | |
| 61 | /* Allocate space for the characteristic values. */ |
| 62 | workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((nn+1)*sizeof(double)); |
| 63 | if (workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 64 | { |
| 65 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 66 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("Error allocating memory for characteristic a values", |
| 67 | GSL_ENOMEM); |
| 68 | } |
| 69 | |
| 70 | workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((nn+1)*sizeof(double)); |
| 71 | if (workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 72 | { |
| 73 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 74 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 75 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("Error allocating memory for characteristic b values", |
| 76 | GSL_ENOMEM); |
| 77 | } |
| 78 | |
| 79 | /* Since even_order is always >= odd_order, dimension the arrays for |
| 80 | even_order. */ |
| 81 | |
| 82 | workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(even_order*sizeof(double)); |
| 83 | if (workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 84 | { |
| 85 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 86 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 87 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 88 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for diagonal", GSL_ENOMEM); |
| 89 | } |
| 90 | |
| 91 | workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(even_order*sizeof(double)); |
| 92 | if (workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 93 | { |
| 94 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 95 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 96 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 97 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 98 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for diagonal", GSL_ENOMEM); |
| 99 | } |
| 100 | |
| 101 | workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(3*even_order*sizeof(double)); |
| 102 | if (workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 103 | { |
| 104 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 105 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 106 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 107 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 108 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 109 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for diagonal", GSL_ENOMEM); |
| 110 | } |
| 111 | |
| 112 | workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(even_order*sizeof(double)); |
| 113 | if (workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 114 | { |
| 115 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 116 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 117 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 118 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 119 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 120 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 121 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for diagonal", GSL_ENOMEM); |
| 122 | } |
| 123 | |
| 124 | workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz. = (double *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(even_order*even_order*sizeof(double)); |
| 125 | if (workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 126 | { |
| 127 | freecxx . . $ free(5d22bdacc48458e8).(workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2.); |
| 128 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 129 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 130 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 131 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 132 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 133 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 134 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for diagonal", GSL_ENOMEM); |
| 135 | } |
| 136 | |
| 137 | workspace->evalcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#eval. = gsl_vector_alloccxx . . $ gsl_vector_alloc(71d9e095f27e8ea9).(even_order); |
| 138 | |
| 139 | if (workspace->evalcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#eval. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 140 | { |
| 141 | freecxx . . $ free(5d22bdacc48458e8).(workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz.); |
| 142 | freecxx . . $ free(5d22bdacc48458e8).(workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2.); |
| 143 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 144 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 145 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 146 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 147 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 148 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 149 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for eval", GSL_ENOMEM); |
| 150 | } |
| 151 | |
| 152 | workspace->eveccxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#evec. = gsl_matrix_alloccxx . . $ gsl_matrix_alloc(5a4d020b4836594).(even_order, even_order); |
| 153 | |
| 154 | if (workspace->eveccxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#evec. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 155 | { |
| 156 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (workspace->evalcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#eval.); |
| 157 | freecxx . . $ free(5d22bdacc48458e8).(workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz.); |
| 158 | freecxx . . $ free(5d22bdacc48458e8).(workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2.); |
| 159 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 160 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 161 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 162 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 163 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 164 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 165 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for evec", GSL_ENOMEM); |
| 166 | } |
| 167 | |
| 168 | workspace->wmatcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#wmat. = gsl_eigen_symmv_alloccxx . . $ gsl_eigen_symmv_alloc(a0b7a55282ff7b99).(even_order); |
| 169 | |
| 170 | if (workspace->wmatcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#wmat. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 171 | { |
| 172 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636). (workspace->eveccxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#evec.); |
| 173 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259). (workspace->evalcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#eval.); |
| 174 | freecxx . . $ free(5d22bdacc48458e8).(workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz.); |
| 175 | freecxx . . $ free(5d22bdacc48458e8).(workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2.); |
| 176 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 177 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 178 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 179 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 180 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 181 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 182 | GSL_ERROR_NULLcxx . . $ `external/gsl/gsl_errno.h:129:9`!("failed to allocate space for wmat", GSL_ENOMEM); |
| 183 | } |
| 184 | |
| 185 | return workspace; |
| 186 | } |
| 187 | |
| 188 | |
| 189 | void gsl_sf_mathieu_freecxx . . $ gsl_sf_mathieu_free(f5b085d8c6ef2116).(gsl_sf_mathieu_workspacecxx . . $ gsl_sf_mathieu_workspace# *workspace) |
| 190 | { |
| 191 | gsl_vector_freecxx . . $ gsl_vector_free(5d65852ca0326259).(workspace->evalcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#eval.); |
| 192 | gsl_matrix_freecxx . . $ gsl_matrix_free(ab29a617cccd3636).(workspace->eveccxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#evec.); |
| 193 | gsl_eigen_symmv_freecxx . . $ gsl_eigen_symmv_free(bb7222d0ceadfe9b).(workspace->wmatcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#wmat.); |
| 194 | freecxx . . $ free(5d22bdacc48458e8).(workspace->aacxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#aa.); |
| 195 | freecxx . . $ free(5d22bdacc48458e8).(workspace->bbcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#bb.); |
| 196 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ddcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#dd.); |
| 197 | freecxx . . $ free(5d22bdacc48458e8).(workspace->eecxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#ee.); |
| 198 | freecxx . . $ free(5d22bdacc48458e8).(workspace->ttcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#tt.); |
| 199 | freecxx . . $ free(5d22bdacc48458e8).(workspace->e2cxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#e2.); |
| 200 | freecxx . . $ free(5d22bdacc48458e8).(workspace->zzcxx . . $ $anonymous_type_66fcc21cdcd56cb3_0#zz.); |
| 201 | freecxx . . $ free(5d22bdacc48458e8).(workspace); |
| 202 | } |