public class DoubleAdditionStrategy extends DoubleBaseMath implements AdditionStrategy<Double>
double
element type.Constructor and Description |
---|
DoubleAdditionStrategy(int radix)
Creates an addition strategy using the specified radix.
|
Modifier and Type | Method and Description |
---|---|
Double |
add(DataStorage.Iterator src1,
DataStorage.Iterator src2,
Double carry,
DataStorage.Iterator dst,
long size)
Addition in some base.
|
Double |
divide(DataStorage.Iterator src1,
Double src2,
Double carry,
DataStorage.Iterator dst,
long size)
Division in some base.
|
Double |
multiplyAdd(DataStorage.Iterator src1,
DataStorage.Iterator src2,
Double src3,
Double carry,
DataStorage.Iterator dst,
long size)
Multiplication and addition in some base.
|
Double |
subtract(DataStorage.Iterator src1,
DataStorage.Iterator src2,
Double carry,
DataStorage.Iterator dst,
long size)
Subtraction in some base.
|
Double |
zero()
Returns the zero element.
|
baseAdd, baseDivide, baseMultiplyAdd, baseSubtract
public DoubleAdditionStrategy(int radix)
radix
- The radix that will be used.public Double add(DataStorage.Iterator src1, DataStorage.Iterator src2, Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
AdditionStrategy
src1
and src2
and stores the result to
dst
. src2
may be null
, in
which case it is ignored (only the carry is propagated).
Essentially calculates dst[i] = src1[i] + src2[i]
.
add
in interface AdditionStrategy<Double>
src1
- First source data sequence. Can be null
, in which case it's ignored.src2
- Second source data sequence. Can be null
, in which case it's ignored.carry
- Input carry bit. This is added to the first (rightmost) word in the accessed sequence.dst
- Destination data sequence.size
- Number of elements to process.ApfloatRuntimeException
public Double subtract(DataStorage.Iterator src1, DataStorage.Iterator src2, Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
AdditionStrategy
src1
and src2
and stores the result to
dst
. src1
and src2
may be
null
, in which case they are ignored (the values are assumed
to be zero and only the carry is propagated).
Essentially calculates dst[i] = src1[i] - src2[i]
.
subtract
in interface AdditionStrategy<Double>
src1
- First source data sequence. Can be null
, in which case the input values are assumed to be zero.src2
- Second source data sequence. Can be null
, in which case it's ignored, or can be the same as dst
.carry
- Input carry bit. This is subtracted from the first (rightmost) word in the accessed sequence.dst
- Destination data sequence.size
- Number of elements to process.1
if the carry is set, and 0
otherwise.ApfloatRuntimeException
public Double multiplyAdd(DataStorage.Iterator src1, DataStorage.Iterator src2, Double src3, Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
AdditionStrategy
src1
by src3
and adds the result to the
words in src2
, and stores the result to dst
.
src2
may be null
, in which case it is ignored
(the values are assumed to be zero).Assumes that the result from the addition doesn't overflow the upper result word (to larger than the base). This is the case e.g. when using this method to perform an arbitrary precision multiplication.
Essentially calculates dst[i] = src1[i] * src3 + src2[i]
.
multiplyAdd
in interface AdditionStrategy<Double>
src1
- First source data sequence.src2
- Second source data sequence. Can be null
, in which case it's ignored, or can be the same as dst
.src3
- Multiplicand. All elements of src1
are multiplied by this value.carry
- Input carry word. This is added to the first (rightmost) word in the accessed sequence.dst
- Destination data sequence.size
- Number of elements to process.ApfloatRuntimeException
public Double divide(DataStorage.Iterator src1, Double src2, Double carry, DataStorage.Iterator dst, long size) throws ApfloatRuntimeException
AdditionStrategy
src1
by src2
and stores the result to
dst
. src1
may be null
,
in which case it is ignored (the values are assumed to be
zero and only the carry division is propagated).
Essentially calculates dst[i] = src1[i] / src2
.
divide
in interface AdditionStrategy<Double>
src1
- First source data sequence. Can be null
, in which case the input values are assumed to be zero.src2
- Divisor. All elements of src1
are divided by this value.carry
- Input carry word. Used as the upper word for the division of the first input element. This should be the remainder word returned from the previous block processed.dst
- Destination data sequence.size
- Number of elements to process.ApfloatRuntimeException
public Double zero()
AdditionStrategy
zero
in interface AdditionStrategy<Double>
Copyright © 2018. All rights reserved.