pa-m / sklearn

bits of sklearn ported to Go #golang
MIT License
345 stars 38 forks source link

all: fix misuses of math.Pow(x, 2) #2

Closed sbinet closed 6 years ago

sbinet commented 6 years ago

math.Pow(x, 2) is really inefficient because math.Pow(x, y) is written for the general use case of computing the power of x where y is a floating point number. In the simpler case of y as an integer, a much simpler algorithm can be used. In the even simpler case of y==2, inlining is even faster.

codecov-io commented 6 years ago

Codecov Report

Merging #2 into master will increase coverage by <.01%. The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
+ Coverage   63.24%   63.25%   +<.01%     
==========================================
  Files          32       32              
  Lines        3197     3200       +3     
==========================================
+ Hits         2022     2024       +2     
- Misses       1053     1054       +1     
  Partials      122      122
Impacted Files Coverage Δ
preprocessing/data.go 73.26% <0%> (-0.19%) :arrow_down:
neighbors/distance.go 77.14% <100%> (+0.67%) :arrow_up:
cluster/distance.go 17.14% <100%> (+2.43%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 50446ff...b6deb78. Read the comment docs.