Package org.openjdk.jmc.common.unit
Class LongPreOffsetTransform
java.lang.Object
org.openjdk.jmc.common.unit.LongPreOffsetTransform
- All Implemented Interfaces:
IScalarAffineTransform
Transform
that adds an offset first and then multiplies with the
multiplier. This is typically used to reduce cancellation errors when the offset is larger than
can be accurately represented in a double.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconcat
(IScalarAffineTransform innerTransform) Concatenate this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this transform on the resulting value.boolean
double
double
int
hashCode()
invert()
invertAndConcat
(IScalarAffineTransform innerTransform) Concatenate the inverse of this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this inverse of this transform on the resulting value.boolean
boolean
isUnity()
double
targetFloor
(double srcNumericalValue) long
targetFloor
(long srcNumericalValue) int
targetIntFloor
(Number srcNumericalValue) targetNumber
(long srcNumericalValue) targetNumber
(Number srcNumericalValue) boolean
targetOutOfRange
(double srcNumericalValue, long maxAbsValue) boolean
targetOutOfRange
(long srcNumericalValue, long maxAbsValue) double
targetValue
(double srcNumericalValue) long
targetValue
(long srcNumericalValue)
-
Constructor Details
-
LongPreOffsetTransform
public LongPreOffsetTransform(long preOffset, double multiplier)
-
-
Method Details
-
getOffset
public double getOffset()- Specified by:
getOffset
in interfaceIScalarAffineTransform
- Returns:
- the offset to be added (after the source value has been multiplied with the
multiplier
)
-
getMultiplier
public double getMultiplier()- Specified by:
getMultiplier
in interfaceIScalarAffineTransform
- Returns:
- the multiplier which source values should be multiplied with (before the
offset
is added)
-
equals
-
hashCode
public int hashCode() -
targetOutOfRange
public boolean targetOutOfRange(long srcNumericalValue, long maxAbsValue) - Specified by:
targetOutOfRange
in interfaceIScalarAffineTransform
-
targetOutOfRange
public boolean targetOutOfRange(double srcNumericalValue, long maxAbsValue) - Specified by:
targetOutOfRange
in interfaceIScalarAffineTransform
-
targetValue
public long targetValue(long srcNumericalValue) - Specified by:
targetValue
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit,
rounded to the closest integer that can be represented by a
long
-
targetFloor
public long targetFloor(long srcNumericalValue) - Specified by:
targetFloor
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the floor of the corresponding numerical quantity value, when expressed in the target
unit, clamped to a
long
-
targetFloor
public double targetFloor(double srcNumericalValue) - Specified by:
targetFloor
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the floor of the corresponding numerical quantity value, when expressed in the target unit
-
targetIntFloor
- Specified by:
targetIntFloor
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the floor of the corresponding numerical quantity value, when expressed in the target
unit, clamped to an
int
-
targetNumber
- Specified by:
targetNumber
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- an exact numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit, as a
Long
if it can exactly be represented in one, otherwise as some otherNumber
with at least the precision ofdouble
-
targetNumber
- Specified by:
targetNumber
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- an exact or inexact numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit, as a
Long
if it can exactly be represented in one, otherwise as some otherNumber
with at least the precision ofdouble
-
targetValue
public double targetValue(double srcNumericalValue) - Specified by:
targetValue
in interfaceIScalarAffineTransform
- Parameters:
srcNumericalValue
- a numerical quantity value, expressed in the source unit- Returns:
- the corresponding numerical quantity value, when expressed in the target unit
-
invert
- Specified by:
invert
in interfaceIScalarAffineTransform
- Returns:
- the inverse transform
-
isUnity
public boolean isUnity()- Specified by:
isUnity
in interfaceIScalarAffineTransform
- Returns:
- true iff this represents the identity transform
-
isInteger
public boolean isInteger()- Specified by:
isInteger
in interfaceIScalarAffineTransform
- Returns:
- true iff this transform can exactly be described by an integer multiplier followed by an integer offset
-
concat
Description copied from interface:IScalarAffineTransform
Concatenate this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this transform on the resulting value. That is, R(v) = T(I(v)), where R(v) is the resulting transform, T(v) is this transform, and I(v) isinnerTransform
.In this snippet,
v1
andv2
should be equal, apart from numerical precision, for anyv
.IScalarAffineTransform R, T = ..., I = ...; double v = ...; R = T.concat(I); double v1 = R.targetValue(v); double v2 = T.targetValue(I.targetValue(v));
- Specified by:
concat
in interfaceIScalarAffineTransform
- Parameters:
innerTransform
- the transform that should be applied before this transform- Returns:
- the concatenated transform
-
invertAndConcat
Description copied from interface:IScalarAffineTransform
Concatenate the inverse of this transform withinnerTransform
, such that applying the resulting transform is equivalent to first applyinginnerTransform
and then applying this inverse of this transform on the resulting value. That is, R(v) = T-1(I(v)), where R(v) is the resulting transform, T-1(v) is the inverse of this transform, and I(v) isinnerTransform
.In this snippet,
v1
andv2
should be equal, apart from numerical precision, for anyv
.IScalarAffineTransform R, T = ..., I = ...; double v = ...; R = T.invertAndConcat(I); double v1 = R.targetValue(v); double v2 = T.invert().targetValue(I.targetValue(v));
- Specified by:
invertAndConcat
in interfaceIScalarAffineTransform
- Parameters:
innerTransform
- the transform that should be applied before this transform- Returns:
- the concatenated transform
-