3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
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.
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.
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.
21 const BASE G = 4096.0, G2 = G * G;
22 BASE D1 = *d1, D2 = *d2, x = *b1, y = b2;
23 BASE h11, h12, h21, h22, u;
27 /* case of d1 < 0, appendix A, second to last paragraph */
42 P[0] = -2; /* case of H = I, page 315 */
50 /* case of equation A6 */
55 h12 = (D2 * y) / (D1 * x);
61 if (u <= 0.0) { /* the case u <= 0 is rejected */
77 /* case of equation A7 */
79 if (D2 * y * y < 0.0) {
93 h11 = (D1 * x) / (D2 * y);
112 /* rescale D1 to range [1/G2,G2] */
114 while (D1 <= 1.0 / G2 && D1 != 0.0) {
130 /* rescale D2 to range [1/G2,G2] */
132 while (fabs(D2) <= 1.0 / G2 && D2 != 0.0) {
139 while (fabs(D2) >= G2) {
155 } else if (P[0] == 0.0) {
158 } else if (P[0] == 1.0) {