algorithm. C and Ruby implementations were compared. There's a Fortran
example too but I'm not going to try compiling code from 1972.
The source is here:
https://github.com/AE9RB/firpm
Times from a 3.0GHz Core 2 Duo:
C: 2.07ms
Go: 3.03ms
Ruby 2.0.0: 85.50ms
Ruby 1.9.2: 190.02ms
If you check that the computed results match you will find that they do not. Sin and Cos in Go uses a different algorithm than clang (and probably gcc). See for yourself:
package main
// #include <math.h>
import "C"
import "fmt"
import "math"
func main() {
fmt.Println(C.cos(math.Pi / 2))
fmt.Println(math.Cos(math.Pi / 2))
}
In practice, the firpm results are accurate enough that the filters will perform identically. However, writing tests against a C reference implementation is difficult. It's possible there's a bug introducing inaccuracy beyond Sin and Cos differences. I suppose I could swap in a new math library that made C calls for testing. But I won't yet because I just wanted a rough idea of Go performance for the kinds of problems I was hoping to use it for.
Looking at the Go source I see a lot of i386 assembly for math which uses FPU hardware but the amd64 uses Go code. I'm probably going to write a float32 math library so I'll have to learn more about why this is.
-david from OreGOn
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.