[#48591] StringValuePtrでnull終止されてない文字列の作り方 — madoka yamamoto <yamamotomadoka@...>
5bGx5pys44Go44KC44GG44GX44G+44GZ44CCDQoNCnRydW5r44GuUnVieeOBp1Bvc3RncmVTUUzm
5 messages
2014/10/05
[#48598] Re: StringValuePtrでnull終止されてない文字列の作り方
— "NARUSE, Yui" <naruse@...>
2014/10/06
GyRCJF4kOiEiGyhCQ1J1YnkbJEIkSCQ3JEYkTxsoQlN0cmluZ1ZhbHVlUHRyGyRCJCwbKEJOVUwb
[#48666] Re: [ruby-cvs:55171] duerst:r48021 (trunk): common.mk: Added a rule to generate lib/unicode_normalize/tables.rb. — "Martin J. Dürst" <duerst@...>
=E4=B8=AD=E7=94=B0=E3=81=95=E3=82=93=E3=80=81=E3=81=93=E3=82=93=E3=81=AB=E3=
3 messages
2014/10/19
[ruby-dev:48624] [ruby-trunk - Feature #10298] Array#float_sum (like math.fsum of Python)
From:
nobu@...
Date:
2014-10-14 02:07:38 UTC
List:
ruby-dev #48624
Issue #10298 has been updated by Nobuyoshi Nakada.
https://github.com/nobu/ruby/compare/Feature%2310298-float_sum
It doesn't improve the performance as `Array.float_sum`, though.
----------------------------------------
Feature #10298: Array#float_sum (like math.fsum of Python)
https://bugs.ruby-lang.org/issues/10298#change-49420
* Author: Takeshi Nishimatsu
* Status: Feedback
* Priority: Low
* Assignee:
* Category: math
* Target version:
----------------------------------------
Here, I propose Array#float_sum in array.c (or math.c).
Array#float_sum returns an accurate total summation of Float
elements in an array using the Kahan summation algorithm
http://en.wikipedia.org/wiki/Kahan_summation_algorithm .
This algorithm can significantly reduce the numerical
error in the total obtained by adding a sequence of
finite precision floating point numbers, compared to the
obvious approach. Python already have math.fsum
https://docs.python.org/2/library/math.html#math.fsum .
```
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1].float_sum #=> 1.0
[].float_sum #=> 0.0
Array.new( 10, 0.1).float_sum #=> 1.0
Array.new(100, 0.1).float_sum #=> 10.0
# cf.
Array.new( 10, 0.1).reduce(:+) #=> 0.9999999999999999
Array.new(100, 0.1).reduce(:+) #=> 9.99999999999998
```
The name of method can be fsum, sum_float, etc., though
I propose float_sum.
This Array#float_sum is inspired by Feature #9834 Float#{next_float,prev_float}.
---Files--------------------------------
array.float_sum.patch (1.32 KB)
--
https://bugs.ruby-lang.org/