| 1 | /* matrix/oper_complex_source.c |
| 2 | * |
| 3 | * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough |
| 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | int |
| 21 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, add) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, |
| 22 | const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * b) |
| 23 | { |
| 24 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 25 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 26 | |
| 27 | if (b->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1. != M || b->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2. != N) |
| 28 | { |
| 29 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("matrices must have same dimensions", GSL_EBADLEN); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | const size_t tda_a = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 34 | const size_t tda_b = b->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 35 | |
| 36 | size_t i, j; |
| 37 | |
| 38 | for (i = 0; i < M; i++) |
| 39 | { |
| 40 | for (j = 0; j < N; j++) |
| 41 | { |
| 42 | const size_t aij = 2 * (i * tda_a + j); |
| 43 | const size_t bij = 2 * (i * tda_b + j); |
| 44 | |
| 45 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij] += b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij]; |
| 46 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1] += b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij + 1]; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | int |
| 55 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, sub) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, |
| 56 | const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * b) |
| 57 | { |
| 58 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 59 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 60 | |
| 61 | if (b->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1. != M || b->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2. != N) |
| 62 | { |
| 63 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("matrices must have same dimensions", GSL_EBADLEN); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | const size_t tda_a = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 68 | const size_t tda_b = b->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 69 | |
| 70 | size_t i, j; |
| 71 | |
| 72 | for (i = 0; i < M; i++) |
| 73 | { |
| 74 | for (j = 0; j < N; j++) |
| 75 | { |
| 76 | const size_t aij = 2 * (i * tda_a + j); |
| 77 | const size_t bij = 2 * (i * tda_b + j); |
| 78 | |
| 79 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij] -= b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij]; |
| 80 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1] -= b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij + 1]; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | int |
| 89 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, mul_elements) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, |
| 90 | const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * b) |
| 91 | { |
| 92 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 93 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 94 | |
| 95 | if (b->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1. != M || b->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2. != N) |
| 96 | { |
| 97 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("matrices must have same dimensions", GSL_EBADLEN); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | const size_t tda_a = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 102 | const size_t tda_b = b->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 103 | |
| 104 | size_t i, j; |
| 105 | |
| 106 | for (i = 0; i < M; i++) |
| 107 | { |
| 108 | for (j = 0; j < N; j++) |
| 109 | { |
| 110 | const size_t aij = 2 * (i * tda_a + j); |
| 111 | const size_t bij = 2 * (i * tda_b + j); |
| 112 | |
| 113 | ATOMICcxx . . $ `./templates_on.h:11:9`! ar = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij]; |
| 114 | ATOMICcxx . . $ `./templates_on.h:11:9`! ai = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1]; |
| 115 | |
| 116 | ATOMICcxx . . $ `./templates_on.h:11:9`! br = b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij]; |
| 117 | ATOMICcxx . . $ `./templates_on.h:11:9`! bi = b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij + 1]; |
| 118 | |
| 119 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij] = ar * br - ai * bi; |
| 120 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1] = ar * bi + ai * br; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | int |
| 129 | FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, div_elements) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, |
| 130 | const TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * b) |
| 131 | { |
| 132 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 133 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 134 | |
| 135 | if (b->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1. != M || b->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2. != N) |
| 136 | { |
| 137 | GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("matrices must have same dimensions", GSL_EBADLEN); |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | const size_t tda_a = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 142 | const size_t tda_b = b->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 143 | |
| 144 | size_t i, j; |
| 145 | |
| 146 | for (i = 0; i < M; i++) |
| 147 | { |
| 148 | for (j = 0; j < N; j++) |
| 149 | { |
| 150 | const size_t aij = 2 * (i * tda_a + j); |
| 151 | const size_t bij = 2 * (i * tda_b + j); |
| 152 | |
| 153 | ATOMICcxx . . $ `./templates_on.h:11:9`! ar = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij]; |
| 154 | ATOMICcxx . . $ `./templates_on.h:11:9`! ai = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1]; |
| 155 | |
| 156 | ATOMICcxx . . $ `./templates_on.h:11:9`! br = b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij]; |
| 157 | ATOMICcxx . . $ `./templates_on.h:11:9`! bi = b->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[bij + 1]; |
| 158 | |
| 159 | ATOMICcxx . . $ `./templates_on.h:11:9`! s = 1.0 / hypot(br, bi); |
| 160 | |
| 161 | ATOMICcxx . . $ `./templates_on.h:11:9`! sbr = s * br; |
| 162 | ATOMICcxx . . $ `./templates_on.h:11:9`! sbi = s * bi; |
| 163 | |
| 164 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij] = (ar * sbr + ai * sbi) * s; |
| 165 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1] = (ai * sbr - ar * sbi) * s; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | int FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, scale) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, const BASEcxx . . $ `./templates_on.h:8:9`! x) |
| 174 | { |
| 175 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 176 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 177 | const size_t tda = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 178 | |
| 179 | size_t i, j; |
| 180 | |
| 181 | ATOMICcxx . . $ `./templates_on.h:11:9`! xr = GSL_REALcxx . . $ `external/gsl/gsl_complex.h:88:9`!(x); |
| 182 | ATOMICcxx . . $ `./templates_on.h:11:9`! xi = GSL_IMAGcxx . . $ `external/gsl/gsl_complex.h:89:9`!(x); |
| 183 | |
| 184 | for (i = 0; i < M; i++) |
| 185 | { |
| 186 | for (j = 0; j < N; j++) |
| 187 | { |
| 188 | const size_t aij = 2 * (i * tda + j); |
| 189 | |
| 190 | ATOMICcxx . . $ `./templates_on.h:11:9`! ar = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij]; |
| 191 | ATOMICcxx . . $ `./templates_on.h:11:9`! ai = a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1]; |
| 192 | |
| 193 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij] = ar * xr - ai * xi; |
| 194 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[aij + 1] = ar * xi + ai * xr; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 199 | } |
| 200 | |
| 201 | int FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, add_constant) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, const BASEcxx . . $ `./templates_on.h:8:9`! x) |
| 202 | { |
| 203 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 204 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 205 | const size_t tda = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 206 | |
| 207 | size_t i, j; |
| 208 | |
| 209 | for (i = 0; i < M; i++) |
| 210 | { |
| 211 | for (j = 0; j < N; j++) |
| 212 | { |
| 213 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[2 * (i * tda + j)] += GSL_REALcxx . . $ `external/gsl/gsl_complex.h:88:9`! (x); |
| 214 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[2 * (i * tda + j) + 1] += GSL_IMAGcxx . . $ `external/gsl/gsl_complex.h:89:9`! (x); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 219 | } |
| 220 | |
| 221 | |
| 222 | int FUNCTIONcxx . . $ `./templates_on.h:233:9`! (gsl_matrix, add_diagonal) (TYPEcxx . . $ `./templates_on.h:234:9`! (gsl_matrix) * a, const BASEcxx . . $ `./templates_on.h:8:9`! x) |
| 223 | { |
| 224 | const size_t M = a->size1cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size1.; |
| 225 | const size_t N = a->size2cxx . . $ $anonymous_type_48f3fae03e2cf644_0#size2.; |
| 226 | const size_t tda = a->tdacxx . . $ $anonymous_type_48f3fae03e2cf644_0#tda.; |
| 227 | const size_t loop_lim = (M < N ? M : N); |
| 228 | size_t i; |
| 229 | for (i = 0; i < loop_lim; i++) |
| 230 | { |
| 231 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[2 * (i * tda + i)] += GSL_REALcxx . . $ `external/gsl/gsl_complex.h:88:9`! (x); |
| 232 | a->datacxx . . $ $anonymous_type_48f3fae03e2cf644_0#data.[2 * (i * tda + i) + 1] += GSL_IMAGcxx . . $ `external/gsl/gsl_complex.h:89:9`! (x); |
| 233 | } |
| 234 | |
| 235 | return GSL_SUCCESScxx . . $ GSL_SUCCESS.; |
| 236 | } |