Giter Site home page Giter Site logo

math32's Introduction

math32 GoDoc

A float32 version of Go's math package. The majority of code in this library is a thin float32 wrapper over the results of the math package that comes in the standard lib.

The original code is lifted from the Go standard library which is governed by a BSD-style licence which can be found here: https://golang.org/LICENSE.

math32's People

Contributors

blackrez avatar bmkessler avatar chewxy avatar dcu avatar dkegel-fastly avatar docmerlin avatar masquerade0097 avatar neclepsio avatar soypat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

math32's Issues

Please support the new processor architecture, thank you very much. This architecture is RISC-V

$ go build .
# github.com/chewxy/math32
../go/pkg/mod/github.com/chewxy/[email protected]/exp.go:3:6: missing function body
../go/pkg/mod/github.com/chewxy/[email protected]/exp.go:57:6: missing function body
../go/pkg/mod/github.com/chewxy/[email protected]/sqrt.go:3:6: missing function body
../go/pkg/mod/github.com/chewxy/[email protected]/log.go:76:6: missing function body
../go/pkg/mod/github.com/chewxy/[email protected]/remainder.go:33:6: missing function body

Missing function bodies for ARM builds

../../../math32/exp.go:3: missing function body for "Exp"
../../../math32/log.go:76: missing function body for "Log"
../../../math32/remainder.go:33: missing function body for "Remainder"
../../../math32/sqrt.go:3: missing function body for "Sqrt"

Abs fix

@dgryski [10:49 AM]
@chewxy You can probably fix this one https://github.com/chewxy/math32/blob/master/abs.go#L8 to do the same as the stdlib abs
(I'm sure Abs shows up in your profiles all the time...)
@chewxy [10:50 AM]
the commented out codes were the original
at the time I wrote the package the if-else version outperforms the << versions
but that was like Go 1.5
@dgryski [10:51 AM]
Yes. There was a compiler issue that's fixed now and it properly gets inlined into a few instructions

Semantic version typo means go mod won't install v1.0.7 or v1.0.8

image

As you cans see in this screenshot of releases, v1.0.7 is incorrectly marked as v1.07 and v1.0.8 is incorrectly marked as v1.08.

As a result, when I run go get -u github.com/chewxy/math32@latest, I end up with github.com/chewxy/math32 v1.0.6.

I need the latest version as Sqrt doesn't work on ARM prior to it.

Workaround: go get -u github.com/chewxy/[email protected]

Support for a New CPU ISA

Recently I have a new cpu architecture other than the one listed, and build gives the following error:

# github.com/chewxy/math32
../../../../go/pkg/mod/github.com/chewxy/[email protected]/exp.go:3:6: missing function body
../../../../go/pkg/mod/github.com/chewxy/[email protected]/exp.go:57:6: missing function body
../../../../go/pkg/mod/github.com/chewxy/[email protected]/log.go:76:6: missing function body
../../../../go/pkg/mod/github.com/chewxy/[email protected]/remainder.go:33:6: missing function body
../../../../go/pkg/mod/github.com/chewxy/[email protected]/sqrt.go:3:6: missing function body

I am wondering do you have instructions for me to port for this new CPU instruction set, many thanks.

Test failure: ARM assembly vetting fails on Remainder

Running Go test on my machine:

--- FAIL: TestVetMath32 (3.45s)
    --- FAIL: TestVetMath32/GOOS=linux_GOARCH=arm (0.33s)
        math32_test.go:55: # github.com/chewxy/math32.test
            github.com/chewxy/math32.archRemainder: nosplit stack over 800 byte limit
            github.com/chewxy/math32.archRemainder<0>
                grows 0 bytes, calls github.com/chewxy/math32.archRemainder<0>
                infinite cycle
             exit status 1
FAIL
FAIL    github.com/chewxy/math32        3.449s
FAIL

Missing function bodies for MIPS builds

Hello,

I'm using the gorgonia library on MIPS and I get the following errors:

../../pkg/mod/github.com/chewxy/[email protected]/exp.go:3:6: missing function body
../../pkg/mod/github.com/chewxy/[email protected]/exp.go:57:6: missing function body
../../pkg/mod/github.com/chewxy/[email protected]/log.go:76:6: missing function body
../../pkg/mod/github.com/chewxy/[email protected]/remainder.go:33:6: missing function body
../../pkg/mod/github.com/chewxy/[email protected]/sqrt.go:3:6: missing function body

I'm trying to build for mips32, mips32le, mips64, and mips64le and I get the same error. Please advise.

Thanks!

Broken assembly implementations

Due to recent developments, some assembly implementations have been discovered to be broken.

An idea for 64bit assembly implementations

Disclaimer: I'm unsure if casting float64s is desirable. This is just a shot-in-the-dark idea.

Instead of us hosting the assembly implementation for 64 bit architectures we could provide an additional boolean build flag similar to haveArchFunc, but indicating that the Go standard library has the 64 bit implementation, thus we can just use a wrapper func style implementation.

This may be clearer if I illustrate with an example
Today The Sqrt implementation is as follows:

func Sqrt(x float32) float32 {
	if haveArchSqrt {
		return archSqrt(x)
	}
	return sqrt(x)
}

I propose adding a new constant haveStdlibSqrt and a new file sqrt_stdlib.go. The above code changes as follows

func Sqrt(x float32) float32 {
	if haveArchSqrt {
		return archSqrt(x)
	}
	if haveStdlibSqrt {
		return float32(math.Sqrt(float32(x)))
	}
	return sqrt(x)
}

The new file sqrt_stdlib.go has the following contents.

//go:build !noasm && (arm64 || risc64)
package math32

import "math"

const haveStdlibSqrt = true // set to false in _noasm and _asm files

Importing math32 for TinyGo on RP2040/arm32 missing methods for Sqrt Log and Exp

I am importing your great float32 package for the following environment:

tinygo version 0.23.0 linux/arm (using go version go1.18.1 and LLVM version 14.0.0)
Target: Raspberry Pi Pico RP2040 (arm32)

Linking is failing as per message below.

tinygo:ld.lld: error: undefined symbol: github.com/chewxy/math32.Sqrt
tinygo:ld.lld: error: undefined symbol: github.com/chewxy/math32.Log
tinygo:ld.lld: error: undefined symbol: github.com/chewxy/math32.Exp

I think this is because some sort of architechture nuance here means it does or doesn't have the in-built architecture dependent versions. Sorry not sure of the exact flags, happy to help debug some more.

The workaround for me is to comment out missing "haveArchExp" symbol (for example):

func Exp(x float32) float32 {
	/*	if haveArchExp {
		return archExp(x)
	}*/
	return exp(x)
}

Fix tests.

TODO:

Thanks to @docmerlin for the headsup

  • find the correct all_test.go from old git repos.
  • travisify this repo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.