Safe Haskell | None |
---|
Support for unified handling of scalars and vectors.
Attention:
The rounding and fraction functions only work
for floating point values with maximum magnitude of maxBound :: Int32
.
This way we save expensive handling of possibly seldom cases.
- class (Real a, IsFloating a) => Fraction a where
- truncate :: Value a -> CodeGenFunction r (Value a)
- fraction :: Value a -> CodeGenFunction r (Value a)
- signedFraction :: Fraction a => Value a -> CodeGenFunction r (Value a)
- addToPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)
- incPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)
- truncateToInt :: (IsFloating a, IsInteger i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)
- floorToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)
- ceilingToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)
- roundToIntFast :: (IsFloating a, RationalConstant a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)
- splitFractionToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i, Value a)
- type family Scalar vector :: *
- class Replicate vector where
- replicate :: Value (Scalar vector) -> CodeGenFunction r (Value vector)
- replicateConst :: ConstValue (Scalar vector) -> ConstValue vector
- replicateOf :: (IsConst (Scalar v), Replicate v) => Scalar v -> Value v
- class IsArithmetic a => Real a where
- min :: Value a -> Value a -> CodeGenFunction r (Value a)
- max :: Value a -> Value a -> CodeGenFunction r (Value a)
- abs :: Value a -> CodeGenFunction r (Value a)
- signum :: Value a -> CodeGenFunction r (Value a)
- class (IsArithmetic (Scalar v), IsArithmetic v) => PseudoModule v where
- scale :: a ~ Scalar v => Value a -> Value v -> CodeGenFunction r (Value v)
- scaleConst :: a ~ Scalar v => ConstValue a -> ConstValue v -> CodeGenFunction r (ConstValue v)
- class IsConst a => IntegerConstant a where
- constFromInteger :: Integer -> ConstValue a
- class IntegerConstant a => RationalConstant a where
- constFromRational :: Rational -> ConstValue a
- class RationalConstant a => TranscendentalConstant a where
- constPi :: ConstValue a
Documentation
class (Real a, IsFloating a) => Fraction a whereSource
truncate :: Value a -> CodeGenFunction r (Value a)Source
fraction :: Value a -> CodeGenFunction r (Value a)Source
signedFraction :: Fraction a => Value a -> CodeGenFunction r (Value a)Source
The fraction has the same sign as the argument. This is not particular useful but fast on IEEE implementations.
addToPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)Source
increment (first operand) may be negative, phase must always be non-negative
incPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)Source
both increment and phase must be non-negative
truncateToInt :: (IsFloating a, IsInteger i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)Source
floorToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)Source
ceilingToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)Source
roundToIntFast :: (IsFloating a, RationalConstant a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i)Source
Rounds to the next integer.
For numbers of the form n+0.5
,
we choose one of the neighboured integers
such that the overall implementation is most efficient.
splitFractionToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, NumberOfElements a ~ NumberOfElements i) => Value a -> CodeGenFunction r (Value i, Value a)Source
class Replicate vector whereSource
replicate :: Value (Scalar vector) -> CodeGenFunction r (Value vector)Source
an alternative is using the Constant
vector type
replicateConst :: ConstValue (Scalar vector) -> ConstValue vectorSource
class IsArithmetic a => Real a whereSource
class (IsArithmetic (Scalar v), IsArithmetic v) => PseudoModule v whereSource
scale :: a ~ Scalar v => Value a -> Value v -> CodeGenFunction r (Value v)Source
scaleConst :: a ~ Scalar v => ConstValue a -> ConstValue v -> CodeGenFunction r (ConstValue v)Source
class IsConst a => IntegerConstant a whereSource
constFromInteger :: Integer -> ConstValue aSource
class IntegerConstant a => RationalConstant a whereSource
RationalConstant Double | |
RationalConstant Float | |
(RationalConstant a, IsPrimitive a, Positive n) => RationalConstant (Vector n a) |
class RationalConstant a => TranscendentalConstant a whereSource
constPi :: ConstValue aSource