gonum.org/v1/gonum@v0.15.1-0.20240517103525-f853624cb1bb/lapack/gonum/ilaenv.go (about) 1 // Copyright ©2015 The Gonum Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package gonum 6 7 // Ilaenv returns algorithm tuning parameters for the algorithm given by the 8 // input string. ispec specifies the parameter to return: 9 // 10 // 1: The optimal block size for a blocked algorithm. 11 // 2: The minimum block size for a blocked algorithm. 12 // 3: The block size of unprocessed data at which a blocked algorithm should 13 // crossover to an unblocked version. 14 // 4: The number of shifts. 15 // 5: The minimum column dimension for blocking to be used. 16 // 6: The crossover point for SVD (to use QR factorization or not). 17 // 7: The number of processors. 18 // 8: The crossover point for multi-shift in QR and QZ methods for non-symmetric eigenvalue problems. 19 // 9: Maximum size of the subproblems in divide-and-conquer algorithms. 20 // 10: ieee infinity and NaN arithmetic can be trusted not to trap. 21 // 11: ieee infinity arithmetic can be trusted not to trap. 22 // 12...16: parameters for Dhseqr and related functions. See Iparmq for more 23 // information. 24 // 25 // Ilaenv is an internal routine. It is exported for testing purposes. 26 func (impl Implementation) Ilaenv(ispec int, name string, opts string, n1, n2, n3, n4 int) int { 27 // TODO(btracey): Replace this with a constant lookup? A list of constants? 28 sname := name[0] == 'S' || name[0] == 'D' 29 cname := name[0] == 'C' || name[0] == 'Z' 30 if !sname && !cname { 31 panic(badName) 32 } 33 c2 := name[1:3] 34 c3 := name[3:6] 35 c4 := c3[1:3] 36 37 switch ispec { 38 default: 39 panic(badIspec) 40 case 1: 41 switch c2 { 42 default: 43 panic(badName) 44 case "GE": 45 switch c3 { 46 default: 47 panic(badName) 48 case "TRF": 49 if sname { 50 return 64 51 } 52 return 64 53 case "QRF", "RQF", "LQF", "QLF": 54 if sname { 55 return 32 56 } 57 return 32 58 case "HRD": 59 if sname { 60 return 32 61 } 62 return 32 63 case "BRD": 64 if sname { 65 return 32 66 } 67 return 32 68 case "TRI": 69 if sname { 70 return 64 71 } 72 return 64 73 } 74 case "PO": 75 switch c3 { 76 default: 77 panic(badName) 78 case "TRF": 79 if sname { 80 return 64 81 } 82 return 64 83 } 84 case "SY": 85 switch c3 { 86 default: 87 panic(badName) 88 case "TRF": 89 if sname { 90 return 64 91 } 92 return 64 93 case "TRD": 94 return 32 95 case "GST": 96 return 64 97 } 98 case "HE": 99 switch c3 { 100 default: 101 panic(badName) 102 case "TRF": 103 return 64 104 case "TRD": 105 return 32 106 case "GST": 107 return 64 108 } 109 case "OR": 110 switch c3[0] { 111 default: 112 panic(badName) 113 case 'G': 114 switch c3[1:] { 115 default: 116 panic(badName) 117 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 118 return 32 119 } 120 case 'M': 121 switch c3[1:] { 122 default: 123 panic(badName) 124 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 125 return 32 126 } 127 } 128 case "UN": 129 switch c3[0] { 130 default: 131 panic(badName) 132 case 'G': 133 switch c3[1:] { 134 default: 135 panic(badName) 136 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 137 return 32 138 } 139 case 'M': 140 switch c3[1:] { 141 default: 142 panic(badName) 143 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 144 return 32 145 } 146 } 147 case "GB": 148 switch c3 { 149 default: 150 panic(badName) 151 case "TRF": 152 if sname { 153 if n4 <= 64 { 154 return 1 155 } 156 return 32 157 } 158 if n4 <= 64 { 159 return 1 160 } 161 return 32 162 } 163 case "PB": 164 switch c3 { 165 default: 166 panic(badName) 167 case "TRF": 168 if sname { 169 if n2 <= 64 { 170 return 1 171 } 172 return 32 173 } 174 if n2 <= 64 { 175 return 1 176 } 177 return 32 178 } 179 case "PT": 180 switch c3 { 181 default: 182 panic(badName) 183 case "TRS": 184 return 1 185 } 186 case "TR": 187 switch c3 { 188 default: 189 panic(badName) 190 case "TRI": 191 if sname { 192 return 64 193 } 194 return 64 195 case "EVC": 196 if sname { 197 return 64 198 } 199 return 64 200 } 201 case "LA": 202 switch c3 { 203 default: 204 panic(badName) 205 case "UUM": 206 if sname { 207 return 64 208 } 209 return 64 210 } 211 case "ST": 212 if sname && c3 == "EBZ" { 213 return 1 214 } 215 panic(badName) 216 } 217 case 2: 218 switch c2 { 219 default: 220 panic(badName) 221 case "GE": 222 switch c3 { 223 default: 224 panic(badName) 225 case "QRF", "RQF", "LQF", "QLF": 226 if sname { 227 return 2 228 } 229 return 2 230 case "HRD": 231 if sname { 232 return 2 233 } 234 return 2 235 case "BRD": 236 if sname { 237 return 2 238 } 239 return 2 240 case "TRI": 241 if sname { 242 return 2 243 } 244 return 2 245 } 246 case "SY": 247 switch c3 { 248 default: 249 panic(badName) 250 case "TRF": 251 if sname { 252 return 8 253 } 254 return 8 255 case "TRD": 256 if sname { 257 return 2 258 } 259 panic(badName) 260 } 261 case "HE": 262 if c3 == "TRD" { 263 return 2 264 } 265 panic(badName) 266 case "OR": 267 if !sname { 268 panic(badName) 269 } 270 switch c3[0] { 271 default: 272 panic(badName) 273 case 'G': 274 switch c4 { 275 default: 276 panic(badName) 277 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 278 return 2 279 } 280 case 'M': 281 switch c4 { 282 default: 283 panic(badName) 284 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 285 return 2 286 } 287 } 288 case "UN": 289 switch c3[0] { 290 default: 291 panic(badName) 292 case 'G': 293 switch c4 { 294 default: 295 panic(badName) 296 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 297 return 2 298 } 299 case 'M': 300 switch c4 { 301 default: 302 panic(badName) 303 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 304 return 2 305 } 306 } 307 } 308 case 3: 309 switch c2 { 310 default: 311 panic(badName) 312 case "GE": 313 switch c3 { 314 default: 315 panic(badName) 316 case "QRF", "RQF", "LQF", "QLF": 317 if sname { 318 return 128 319 } 320 return 128 321 case "HRD": 322 if sname { 323 return 128 324 } 325 return 128 326 case "BRD": 327 if sname { 328 return 128 329 } 330 return 128 331 } 332 case "SY": 333 if sname && c3 == "TRD" { 334 return 32 335 } 336 panic(badName) 337 case "HE": 338 if c3 == "TRD" { 339 return 32 340 } 341 panic(badName) 342 case "OR": 343 switch c3[0] { 344 default: 345 panic(badName) 346 case 'G': 347 switch c4 { 348 default: 349 panic(badName) 350 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 351 return 128 352 } 353 } 354 case "UN": 355 switch c3[0] { 356 default: 357 panic(badName) 358 case 'G': 359 switch c4 { 360 default: 361 panic(badName) 362 case "QR", "RQ", "LQ", "QL", "HR", "TR", "BR": 363 return 128 364 } 365 } 366 } 367 case 4: 368 // Used by xHSEQR 369 return 6 370 case 5: 371 // Not used 372 return 2 373 case 6: 374 // Used by xGELSS and xGESVD 375 return int(float64(min(n1, n2)) * 1.6) 376 case 7: 377 // Not used 378 return 1 379 case 8: 380 // Used by xHSEQR 381 return 50 382 case 9: 383 // used by xGELSD and xGESDD 384 return 25 385 case 10: 386 // Go guarantees ieee 387 return 1 388 case 11: 389 // Go guarantees ieee 390 return 1 391 case 12, 13, 14, 15, 16: 392 // Dhseqr and related functions for eigenvalue problems. 393 return impl.Iparmq(ispec, name, opts, n1, n2, n3, n4) 394 } 395 }