File: iparmq.go

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (117 lines) | stat: -rw-r--r-- 2,741 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright ©2016 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gonum

import "math"

// Iparmq returns problem and machine dependent parameters useful for Dhseqr and
// related subroutines for eigenvalue problems.
//
// ispec specifies the parameter to return:
//
//	12: Crossover point between Dlahqr and Dlaqr0. Will be at least 11.
//	13: Deflation window size.
//	14: Nibble crossover point. Determines when to skip a multi-shift QR sweep.
//	15: Number of simultaneous shifts in a multishift QR iteration.
//	16: Select structured matrix multiply.
//
// For other values of ispec Iparmq will panic.
//
// name is the name of the calling function. name must be in uppercase but this
// is not checked.
//
// opts is not used and exists for future use.
//
// n is the order of the Hessenberg matrix H.
//
// ilo and ihi specify the block [ilo:ihi+1,ilo:ihi+1] that is being processed.
//
// lwork is the amount of workspace available.
//
// Except for ispec input parameters are not checked.
//
// Iparmq is an internal routine. It is exported for testing purposes.
func (Implementation) Iparmq(ispec int, name, opts string, n, ilo, ihi, lwork int) int {
	nh := ihi - ilo + 1
	ns := 2
	switch {
	case nh >= 30:
		ns = 4
	case nh >= 60:
		ns = 10
	case nh >= 150:
		ns = max(10, nh/int(math.Log(float64(nh))/math.Ln2))
	case nh >= 590:
		ns = 64
	case nh >= 3000:
		ns = 128
	case nh >= 6000:
		ns = 256
	}
	ns = max(2, ns-(ns%2))

	switch ispec {
	default:
		panic(badIspec)

	case 12:
		// Matrices of order smaller than nmin get sent to Dlahqr, the
		// classic double shift algorithm. This must be at least 11.
		const nmin = 75
		return nmin

	case 13:
		const knwswp = 500
		if nh <= knwswp {
			return ns
		}
		return 3 * ns / 2

	case 14:
		// Skip a computationally expensive multi-shift QR sweep with
		// Dlaqr5 whenever aggressive early deflation finds at least
		// nibble*(window size)/100 deflations. The default, small,
		// value reflects the expectation that the cost of looking
		// through the deflation window with Dlaqr3 will be
		// substantially smaller.
		const nibble = 14
		return nibble

	case 15:
		return ns

	case 16:
		if len(name) != 6 {
			panic(badName)
		}
		const (
			k22min = 14
			kacmin = 14
		)
		var acc22 int
		switch {
		case name[1:] == "GGHRD" || name[1:] == "GGHD3":
			acc22 = 1
			if nh >= k22min {
				acc22 = 2
			}
		case name[3:] == "EXC":
			if nh >= kacmin {
				acc22 = 1
			}
			if nh >= k22min {
				acc22 = 2
			}
		case name[1:] == "HSEQR" || name[1:5] == "LAQR":
			if ns >= kacmin {
				acc22 = 1
			}
			if ns >= k22min {
				acc22 = 2
			}
		}
		return acc22
	}
}