7a9389330e
gcc/: * gcc.c (default_compilers): Add entry for ".go". * common.opt: Add -static-libgo as a driver option. * doc/install.texi (Configuration): Mention libgo as an option for --enable-shared. Mention go as an option for --enable-languages. * doc/invoke.texi (Overall Options): Mention .go as a file name suffix. Mention go as a -x option. * doc/frontends.texi (G++ and GCC): Mention Go as a supported language. * doc/sourcebuild.texi (Top Level): Mention libgo. * doc/standards.texi (Standards): Add section on Go language. Move references for other languages into their own section. * doc/contrib.texi (Contributors): Mention that I contributed the Go frontend. gcc/testsuite/: * lib/go.exp: New file. * lib/go-dg.exp: New file. * lib/go-torture.exp: New file. * lib/target-supports.exp (check_compile): Match // Go. From-SVN: r167407
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
// Copyright 2009 The Go 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 math
|
|
|
|
/*
|
|
Floating-point arctangent.
|
|
|
|
Atan returns the value of the arctangent of its
|
|
argument in the range [-pi/2,pi/2].
|
|
There are no error returns.
|
|
Coefficients are #5077 from Hart & Cheney. (19.56D)
|
|
*/
|
|
|
|
// xatan evaluates a series valid in the
|
|
// range [-0.414...,+0.414...]. (tan(pi/8))
|
|
func xatan(arg float64) float64 {
|
|
const (
|
|
P4 = .161536412982230228262e2
|
|
P3 = .26842548195503973794141e3
|
|
P2 = .11530293515404850115428136e4
|
|
P1 = .178040631643319697105464587e4
|
|
P0 = .89678597403663861959987488e3
|
|
Q4 = .5895697050844462222791e2
|
|
Q3 = .536265374031215315104235e3
|
|
Q2 = .16667838148816337184521798e4
|
|
Q1 = .207933497444540981287275926e4
|
|
Q0 = .89678597403663861962481162e3
|
|
)
|
|
sq := arg * arg
|
|
value := ((((P4*sq+P3)*sq+P2)*sq+P1)*sq + P0)
|
|
value = value / (((((sq+Q4)*sq+Q3)*sq+Q2)*sq+Q1)*sq + Q0)
|
|
return value * arg
|
|
}
|
|
|
|
// satan reduces its argument (known to be positive)
|
|
// to the range [0,0.414...] and calls xatan.
|
|
func satan(arg float64) float64 {
|
|
if arg < Sqrt2-1 {
|
|
return xatan(arg)
|
|
}
|
|
if arg > Sqrt2+1 {
|
|
return Pi/2 - xatan(1/arg)
|
|
}
|
|
return Pi/4 + xatan((arg-1)/(arg+1))
|
|
}
|
|
|
|
// Atan returns the arctangent of x.
|
|
//
|
|
// Special cases are:
|
|
// Atan(±0) = ±0
|
|
// Atan(±Inf) = ±Pi/2
|
|
func Atan(x float64) float64 {
|
|
if x == 0 {
|
|
return x
|
|
}
|
|
if x > 0 {
|
|
return satan(x)
|
|
}
|
|
return -satan(-x)
|
|
}
|