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