Skip to content

Commit

Permalink
Merge pull request #28 from hubues/master
Browse files Browse the repository at this point in the history
Include copy of fmath with fix for archs other than amd64
  • Loading branch information
ungerik authored May 20, 2021
2 parents d82aece + ea46c66 commit 9ffa86f
Show file tree
Hide file tree
Showing 63 changed files with 3,594 additions and 10 deletions.
27 changes: 27 additions & 0 deletions fmath/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2011 Arne Vansteenkiste. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 8 additions & 0 deletions fmath/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
32-bit floating point math library for GO.

This library provides float32 counterparts for Go's float64 math functions.
E.g.: Sqrtf(x float32) float32.

The implementation partially uses assembly code (see, e.g., sqrtf_amd64.s) for fast computation. However, when no assembly implementation exists yet a generic implementation is used which uses Go's float64 math functions underneath.

Note: the assembly code is not goinstallable on all platforms. Therefore, goinstall will compile the portable implementation. If you manually execute "make install", you will get the faster implementation.
16 changes: 16 additions & 0 deletions fmath/absf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2011 Arne Vansteenkiste. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file provides a trivial implementation based on
// Go's float64 math library. It may be overridden by an
// assembly implementation when available for the platform.

package fmath

import "math"

// float32 version of math.Fabsf
func Abs(x float32) float32 {
return float32(math.Abs(float64(x)))
}
16 changes: 16 additions & 0 deletions fmath/acosf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2011 Arne Vansteenkiste. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file provides a trivial implementation based on
// Go's float64 math library. It may be overridden by an
// assembly implementation when available for the platform.

package fmath

import "math"

// float32 version of math.Acos
func Acos(x float32) float32 {
return float32(math.Acos(float64(x)))
}
16 changes: 16 additions & 0 deletions fmath/acoshf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2011 Arne Vansteenkiste. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file provides a trivial implementation based on
// Go's float64 math library. It may be overridden by an
// assembly implementation when available for the platform.

package fmath

import "math"

// float32 version of math.Acosh
func Acosh(x float32) float32 {
return float32(math.Acosh(float64(x)))
}
Loading

0 comments on commit 9ffa86f

Please sign in to comment.