I'm new to D and am trying to implement simple sparse vectors
using associative arrays, but I'm getting fairly large floating
point errors. Example code for sparse dot product:
import std.stdio;
import std.math;
import std.random;
static import std.datetime;
int main(string[] args) {
double[
Are errors of this magnitude to be expected using doubles, or
is this a compiler bug?
Errors of this magnitude are to be expected. the value of accum
in your example is somewhere around 3e+08, so the relative error
is around 1e-15, and double.epsilon is 2.22045e-16.
By the way, you can use u
On Thursday, 7 March 2013 at 09:43:21 UTC, jerro wrote:
Are errors of this magnitude to be expected using doubles, or
is this a compiler bug?
Errors of this magnitude are to be expected. the value of accum
in your example is somewhere around 3e+08, so the relative
error is around 1e-15, and d
On Thursday, 7 March 2013 at 07:03:04 UTC, Ed wrote:
I'm new to D and am trying to implement simple sparse vectors
using associative arrays, but I'm getting fairly large floating
point errors. Example code for sparse dot product:
import std.stdio;
import std.math;
import std.random;
static imp
You could also try to use a Kahan Accumulator to 'fix' this
problem.
See wikipedia:
http://en.wikipedia.org/wiki/Kahan_summation_algorithm
Its pretty straight forward to implement.
Gr,
Danny Arends
http://www.dannyarends.nl