1// compile
2
3// Copyright 2016 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7// This tickles (a version of) the PPC64 back end to
8// emit a BVS instruction.
9
10package foo
11
12type Flag int
13
14const (
15	Identity  Flag = iota - 2 // H is the identity matrix; no rotation is needed.
16	Rescaling                 // H specifies rescaling.
17)
18
19type DrotmParams struct {
20	Flag
21}
22
23func Drotmg(d1, d2, x1, y1 float64) (p DrotmParams, rd1, rd2, rx1 float64) {
24
25	const (
26		gam    = 4.0
27		gamsq  = 16.0
28		rgamsq = 5e-8
29	)
30
31	if d1 < 0 {
32		p.Flag = Rescaling
33		return
34	}
35
36	for rd1 <= rgamsq || rd1 >= gamsq {
37		if rd1 <= rgamsq {
38			rd1 *= gam * gam
39			rx1 /= gam
40		} else {
41			rd1 /= gam * gam
42			rx1 *= gam
43		}
44	}
45	return
46}
47