public class fp
extends java.lang.Object
Fast and Accurate Computation of Sum and Dot Product
orAccurate Computation of Sum and Dot Product [NOTE TYPO IN THE TWOSUM ALGORITHM IN THIS ONE]
Modifier and Type | Method and Description |
---|---|
static double[] |
cusum(double[] in)
Returns the cumulative sum of the elements of the input using Knuth's
correction to accumulate the error.
|
static double[] |
cusumi(double[] in)
Returns the cumulative sum of the elements of the input using Knuth's
correction to accumulate the error (in-place).
|
static double |
dot(double[] a,
double[] b)
Returns the dot product.
|
static double[] |
split(double val)
Splits a double value into two double values where the sum of the two is
the input.
|
static double |
sum(double[] in)
Returns the sum of
in using Knuth's correction to accumulate the
error. |
static double |
sum(double[] in,
int idx0,
int idx1)
Returns the sum between two indices (inclusive).
|
static boolean |
tolEquals(double a,
double b,
double tol) |
static double[] |
twoProduct(double a,
double b)
Returns the product of two double values and a correction for loss of
precision in the multiplication.
|
static double[] |
twoSum(double a,
double b)
Returns the sum of two double values and a correction for loss of
precision in the summation.
|
public static double[] split(double val)
val
- a double inputpublic static double[] twoProduct(double a, double b)
a
- a double value.b
- a double value.public static double[] twoSum(double a, double b)
a
- a double value.b
- a double value.public static double sum(double[] in)
in
using Knuth's correction to accumulate the
error. The accumulated error is added to the output.in
- public static double sum(double[] in, int idx0, int idx1)
in
- input arrayidx0
- start indexidx1
- end indexpublic static double[] cusum(double[] in)
in
- public static double[] cusumi(double[] in)
in
- public static double dot(double[] a, double[] b)
a
- double[] input ab
- double[] input bpublic static boolean tolEquals(double a, double b, double tol)