OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [math/] [tanh.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go 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 math
6
 
7
/*
8
        Floating-point hyperbolic tangent.
9
 
10
        Sinh and Cosh are called except for large arguments, which
11
        would cause overflow improperly.
12
*/
13
 
14
// Tanh computes the hyperbolic tangent of x.
15
//
16
// Special cases are:
17
//      Tanh(±0) = ±0
18
//      Tanh(±Inf) = ±1
19
//      Tanh(NaN) = NaN
20
func Tanh(x float64) float64 {
21
        if x < 0 {
22
                x = -x
23
                if x > 21 {
24
                        return -1
25
                }
26
                return -Sinh(x) / Cosh(x)
27
        }
28
        if x > 21 {
29
                return 1
30
        }
31
        return Sinh(x) / Cosh(x)
32
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.