{-# LANGUAGE TypeOperators, FlexibleContexts, DataKinds, TypeFamilies, CPP,
ScopedTypeVariables, ConstraintKinds, GeneralizedNewtypeDeriving #-}
#if __GLASGOW_HASKELL__ >= 711
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
#endif
module Data.Metrology.Vector (
zero, (|+|), (|-|), qSum, qNegate,
(|*|), (|/|), (/|),
(*|), (|*), (|/),
(|*^|), (|^*|), (|^/|), (|.|),
(|^), (|^^), qNthRoot,
qSq, qCube, qSqrt, qCubeRoot,
qMagnitudeSq, qMagnitude, qNormalized, qProject, qCross2, qCross3,
Point(..), QPoint, (|.-.|), (|.+^|), (|.-^|), qDistanceSq, qDistance,
pointNumIn, (.#), quOfPoint, (%.),
qCompare, (|<|), (|>|), (|<=|), (|>=|), (|==|), (|/=|),
qApprox, qNapprox,
numIn, (#), quOf, (%), showIn,
unity, redim, convert,
defaultLCSU, constant,
(:*)(..), (:/)(..), (:^)(..), (:@)(..),
UnitPrefix(..),
type (%*), type (%/), type (%^),
Qu, MkQu_D, MkQu_DLN, MkQu_U, MkQu_ULN,
Dimension,
Unit(type BaseUnit, type DimOfUnit, conversionRatio),
Canonical,
Dimensionless(..), Number(..), Count, quantity,
MkLCSU, LCSU(DefaultLCSU), DefaultUnitOfDim,
CompatibleUnit, CompatibleDim, ConvertibleLCSUs_D,
DefaultConvertibleLCSU_D, DefaultConvertibleLCSU_U,
MultDimFactors, MultUnitFactors, UnitOfDimFactors,
Z(..), Succ, Pred, type (#+), type (#-), type (#*), type (#/), Negate,
One, Two, Three, Four, Five, MOne, MTwo, MThree, MFour, MFive,
sZero, sOne, sTwo, sThree, sFour, sFive,
sMOne, sMTwo, sMThree, sMFour, sMFive,
sSucc, sPred, sNegate,
module Data.Metrology.Internal
) where
import Data.Metrology.Qu
import Data.Metrology.LCSU
import Data.Metrology.Validity
import Data.Metrology.Factor
import Data.Metrology.Z as Z
import Data.Metrology.Units
import Data.Metrology.Combinators
import Data.Metrology.Dimensions
import Data.Metrology.Internal
import Data.AffineSpace
import Data.VectorSpace
import Data.Cross hiding ( One, Two, Three )
import Data.Proxy
import Data.Coerce
import Data.Foldable as F
zero :: AdditiveGroup n => Qu dimspec l n
zero :: Qu dimspec l n
zero = n -> Qu dimspec l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu n
forall v. AdditiveGroup v => v
zeroV
infixl 6 |+|
(|+|) :: (d1 @~ d2, AdditiveGroup n) => Qu d1 l n -> Qu d2 l n -> Qu d1 l n
(Qu n
a) |+| :: Qu d1 l n -> Qu d2 l n -> Qu d1 l n
|+| (Qu n
b) = n -> Qu d1 l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> n -> n
forall v. AdditiveGroup v => v -> v -> v
^+^ n
b)
qNegate :: AdditiveGroup n => Qu d l n -> Qu d l n
qNegate :: Qu d l n -> Qu d l n
qNegate (Qu n
x) = n -> Qu d l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> n
forall v. AdditiveGroup v => v -> v
negateV n
x)
infixl 6 |-|
(|-|) :: (d1 @~ d2, AdditiveGroup n) => Qu d1 l n -> Qu d2 l n -> Qu d1 l n
Qu d1 l n
a |-| :: Qu d1 l n -> Qu d2 l n -> Qu d1 l n
|-| Qu d2 l n
b = Qu d1 l n
a Qu d1 l n -> Qu d2 l n -> Qu d1 l n
forall (d1 :: [Factor *]) (d2 :: [Factor *]) n (l :: LCSU *).
(d1 @~ d2, AdditiveGroup n) =>
Qu d1 l n -> Qu d2 l n -> Qu d1 l n
|+| Qu d2 l n -> Qu d2 l n
forall n (d :: [Factor *]) (l :: LCSU *).
AdditiveGroup n =>
Qu d l n -> Qu d l n
qNegate Qu d2 l n
b
qSum :: (Foldable f, AdditiveGroup n) => f (Qu d l n) -> Qu d l n
qSum :: f (Qu d l n) -> Qu d l n
qSum = (Qu d l n -> Qu d l n -> Qu d l n)
-> Qu d l n -> f (Qu d l n) -> Qu d l n
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
F.foldr Qu d l n -> Qu d l n -> Qu d l n
forall (d1 :: [Factor *]) (d2 :: [Factor *]) n (l :: LCSU *).
(d1 @~ d2, AdditiveGroup n) =>
Qu d1 l n -> Qu d2 l n -> Qu d1 l n
(|+|) Qu d l n
forall n (dimspec :: [Factor *]) (l :: LCSU *).
AdditiveGroup n =>
Qu dimspec l n
zero
infixl 7 |*^|, |^*|, |^/|
(|*^|) :: VectorSpace n => Qu d1 l (Scalar n) -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l n
(Qu Scalar n
a) |*^| :: Qu d1 l (Scalar n) -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l n
|*^| (Qu n
b) = n -> Qu (Normalize (d1 @@+ Reorder d2 d1)) l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (Scalar n
a Scalar n -> n -> n
forall v. VectorSpace v => Scalar v -> v -> v
*^ n
b)
(|^*|) :: VectorSpace n => Qu d1 l n -> Qu d2 l (Scalar n) -> Qu (Normalize (d1 @+ d2)) l n
(Qu n
a) |^*| :: Qu d1 l n -> Qu d2 l (Scalar n) -> Qu (Normalize (d1 @+ d2)) l n
|^*| (Qu Scalar n
b) = n -> Qu (Normalize (d1 @@+ Reorder d2 d1)) l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Scalar n -> n
forall v s. (VectorSpace v, s ~ Scalar v) => v -> s -> v
^* Scalar n
b)
(|^/|) :: (VectorSpace n, Fractional (Scalar n))
=> Qu d1 l n -> Qu d2 l (Scalar n) -> Qu (Normalize (d1 @- d2)) l n
(Qu n
a) |^/| :: Qu d1 l n -> Qu d2 l (Scalar n) -> Qu (Normalize (d1 @- d2)) l n
|^/| (Qu Scalar n
b) = n -> Qu (Normalize (d1 @- d2)) l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Scalar n -> n
forall v s.
(VectorSpace v, s ~ Scalar v, Fractional s) =>
v -> s -> v
^/ Scalar n
b)
infixl 7 |/
(|/) :: (VectorSpace n, Fractional (Scalar n)) => Qu a l n -> Scalar n -> Qu a l n
(Qu n
a) |/ :: Qu a l n -> Scalar n -> Qu a l n
|/ Scalar n
b = n -> Qu a l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Scalar n -> n
forall v s.
(VectorSpace v, s ~ Scalar v, Fractional s) =>
v -> s -> v
^/ Scalar n
b)
infixl 7 *| , |*
(*|) :: VectorSpace n => Scalar n -> Qu b l n -> Qu b l n
Scalar n
a *| :: Scalar n -> Qu b l n -> Qu b l n
*| (Qu n
b) = n -> Qu b l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (Scalar n
a Scalar n -> n -> n
forall v. VectorSpace v => Scalar v -> v -> v
*^ n
b)
(|*) :: VectorSpace n => Qu a l n -> Scalar n -> Qu a l n
(Qu n
a) |* :: Qu a l n -> Scalar n -> Qu a l n
|* Scalar n
b = n -> Qu a l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Scalar n -> n
forall v s. (VectorSpace v, s ~ Scalar v) => v -> s -> v
^* Scalar n
b)
infixl 7 |.|
(|.|) :: InnerSpace n => Qu d1 l n -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l (Scalar n)
(Qu n
a) |.| :: Qu d1 l n -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l (Scalar n)
|.| (Qu n
b) = Scalar n -> Qu (Normalize (d1 @@+ Reorder d2 d1)) l (Scalar n)
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> n -> Scalar n
forall v. InnerSpace v => v -> v -> Scalar v
<.> n
b)
qMagnitudeSq :: InnerSpace n => Qu d l n -> Qu (d @* Z.Two) l (Scalar n)
qMagnitudeSq :: Qu d l n -> Qu (d @* Two) l (Scalar n)
qMagnitudeSq (Qu n
x) = Scalar n -> Qu (d @* Two) l (Scalar n)
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> Scalar n
forall v s. (InnerSpace v, s ~ Scalar v) => v -> s
magnitudeSq n
x)
qMagnitude :: (InnerSpace n, Floating (Scalar n)) => Qu d l n -> Qu d l (Scalar n)
qMagnitude :: Qu d l n -> Qu d l (Scalar n)
qMagnitude (Qu n
x) = Scalar n -> Qu d l (Scalar n)
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> Scalar n
forall v s. (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
magnitude n
x)
qNormalized :: (InnerSpace n, Floating (Scalar n)) => Qu d l n -> Qu '[] l n
qNormalized :: Qu d l n -> Qu '[] l n
qNormalized (Qu n
x) = n -> Qu '[] l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> n
forall v s. (InnerSpace v, s ~ Scalar v, Floating s) => v -> v
normalized n
x)
qProject :: (InnerSpace n, Floating (Scalar n)) => Qu d2 l n -> Qu d1 l n -> Qu d1 l n
qProject :: Qu d2 l n -> Qu d1 l n -> Qu d1 l n
qProject (Qu n
u) (Qu n
v) = n -> Qu d1 l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
u n -> n -> n
forall v s.
(InnerSpace v, s ~ Scalar v, Fractional s) =>
v -> v -> v
`project` n
v)
qCross2 :: HasCross2 n => Qu d l n -> Qu d l n
qCross2 :: Qu d l n -> Qu d l n
qCross2 (Qu n
x) = n -> Qu d l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> n
forall v. HasCross2 v => v -> v
cross2 n
x)
qCross3 :: HasCross3 n => Qu d1 l n -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l n
qCross3 :: Qu d1 l n -> Qu d2 l n -> Qu (Normalize (d1 @+ d2)) l n
qCross3 (Qu n
x) (Qu n
y) = n -> Qu (Normalize (d1 @@+ Reorder d2 d1)) l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
x n -> n -> n
forall v. HasCross3 v => v -> v -> v
`cross3` n
y)
newtype Point n = Point n
deriving (Int -> Point n -> ShowS
[Point n] -> ShowS
Point n -> String
(Int -> Point n -> ShowS)
-> (Point n -> String) -> ([Point n] -> ShowS) -> Show (Point n)
forall n. Show n => Int -> Point n -> ShowS
forall n. Show n => [Point n] -> ShowS
forall n. Show n => Point n -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Point n] -> ShowS
$cshowList :: forall n. Show n => [Point n] -> ShowS
show :: Point n -> String
$cshow :: forall n. Show n => Point n -> String
showsPrec :: Int -> Point n -> ShowS
$cshowsPrec :: forall n. Show n => Int -> Point n -> ShowS
Show, Point n -> Point n -> Bool
(Point n -> Point n -> Bool)
-> (Point n -> Point n -> Bool) -> Eq (Point n)
forall n. Eq n => Point n -> Point n -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Point n -> Point n -> Bool
$c/= :: forall n. Eq n => Point n -> Point n -> Bool
== :: Point n -> Point n -> Bool
$c== :: forall n. Eq n => Point n -> Point n -> Bool
Eq, Int -> Point n
Point n -> Int
Point n -> [Point n]
Point n -> Point n
Point n -> Point n -> [Point n]
Point n -> Point n -> Point n -> [Point n]
(Point n -> Point n)
-> (Point n -> Point n)
-> (Int -> Point n)
-> (Point n -> Int)
-> (Point n -> [Point n])
-> (Point n -> Point n -> [Point n])
-> (Point n -> Point n -> [Point n])
-> (Point n -> Point n -> Point n -> [Point n])
-> Enum (Point n)
forall n. Enum n => Int -> Point n
forall n. Enum n => Point n -> Int
forall n. Enum n => Point n -> [Point n]
forall n. Enum n => Point n -> Point n
forall n. Enum n => Point n -> Point n -> [Point n]
forall n. Enum n => Point n -> Point n -> Point n -> [Point n]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Point n -> Point n -> Point n -> [Point n]
$cenumFromThenTo :: forall n. Enum n => Point n -> Point n -> Point n -> [Point n]
enumFromTo :: Point n -> Point n -> [Point n]
$cenumFromTo :: forall n. Enum n => Point n -> Point n -> [Point n]
enumFromThen :: Point n -> Point n -> [Point n]
$cenumFromThen :: forall n. Enum n => Point n -> Point n -> [Point n]
enumFrom :: Point n -> [Point n]
$cenumFrom :: forall n. Enum n => Point n -> [Point n]
fromEnum :: Point n -> Int
$cfromEnum :: forall n. Enum n => Point n -> Int
toEnum :: Int -> Point n
$ctoEnum :: forall n. Enum n => Int -> Point n
pred :: Point n -> Point n
$cpred :: forall n. Enum n => Point n -> Point n
succ :: Point n -> Point n
$csucc :: forall n. Enum n => Point n -> Point n
Enum, Point n
Point n -> Point n -> Bounded (Point n)
forall a. a -> a -> Bounded a
forall n. Bounded n => Point n
maxBound :: Point n
$cmaxBound :: forall n. Bounded n => Point n
minBound :: Point n
$cminBound :: forall n. Bounded n => Point n
Bounded)
type family QPoint n where
QPoint (Qu d l n) = Qu d l (Point n)
instance AdditiveGroup n => AffineSpace (Point n) where
type Diff (Point n) = n
.-. :: Point n -> Point n -> Diff (Point n)
(.-.) = (n -> n -> n) -> Point n -> Point n -> n
coerce (n -> n -> n
forall v. AdditiveGroup v => v -> v -> v
(^-^) :: n -> n -> n)
.+^ :: Point n -> Diff (Point n) -> Point n
(.+^) = (n -> n -> n) -> Point n -> n -> Point n
coerce (n -> n -> n
forall v. AdditiveGroup v => v -> v -> v
(^+^) :: n -> n -> n)
quOfPoint :: forall dim lcsu unit n.
( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> n -> unit -> Qu dim lcsu (Point n)
quOfPoint :: n -> unit -> Qu dim lcsu (Point n)
quOfPoint n
n unit
unit = Point n -> Qu dim lcsu (Point n)
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> Point n
forall n. n -> Point n
Point n
x)
where Qu n
x = n -> unit -> Qu dim lcsu n
forall unit (dim :: [Factor *]) (lcsu :: LCSU *) n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
n -> unit -> Qu dim lcsu n
quOf n
n unit
unit :: Qu dim lcsu n
infix 5 %.
(%.) :: ( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> n -> unit -> Qu dim lcsu (Point n)
%. :: n -> unit -> Qu dim lcsu (Point n)
(%.) = n -> unit -> Qu dim lcsu (Point n)
forall (dim :: [Factor *]) (lcsu :: LCSU *) unit n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
n -> unit -> Qu dim lcsu (Point n)
quOfPoint
pointNumIn :: forall unit dim lcsu n.
( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> Qu dim lcsu (Point n) -> unit -> n
pointNumIn :: Qu dim lcsu (Point n) -> unit -> n
pointNumIn (Qu (Point n
n)) unit
unit = Qu dim lcsu n -> unit -> n
forall unit (dim :: [Factor *]) (lcsu :: LCSU *) n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
Qu dim lcsu n -> unit -> n
numIn (n -> Qu dim lcsu n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu n
n :: Qu dim lcsu n) unit
unit
infix 5 .#
(.#) :: (ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n))
=> Qu dim lcsu (Point n) -> unit -> n
.# :: Qu dim lcsu (Point n) -> unit -> n
(.#) = Qu dim lcsu (Point n) -> unit -> n
forall unit (dim :: [Factor *]) (lcsu :: LCSU *) n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
Qu dim lcsu (Point n) -> unit -> n
pointNumIn
infixl 6 |.-.|, |.+^|, |.-^|
(|.-.|) :: (d1 @~ d2, AffineSpace n) => Qu d1 l n -> Qu d2 l n -> Qu d1 l (Diff n)
(Qu n
a) |.-.| :: Qu d1 l n -> Qu d2 l n -> Qu d1 l (Diff n)
|.-.| (Qu n
b) = Diff n -> Qu d1 l (Diff n)
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> n -> Diff n
forall p. AffineSpace p => p -> p -> Diff p
.-. n
b)
(|.+^|) :: (d1 @~ d2, AffineSpace n) => Qu d1 l n -> Qu d2 l (Diff n) -> Qu d1 l n
(Qu n
a) |.+^| :: Qu d1 l n -> Qu d2 l (Diff n) -> Qu d1 l n
|.+^| (Qu Diff n
b) = n -> Qu d1 l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Diff n -> n
forall p. AffineSpace p => p -> Diff p -> p
.+^ Diff n
b)
(|.-^|) :: (d1 @~ d2, AffineSpace n) => Qu d1 l n -> Qu d2 l (Diff n) -> Qu d1 l n
(Qu n
a) |.-^| :: Qu d1 l n -> Qu d2 l (Diff n) -> Qu d1 l n
|.-^| (Qu Diff n
b) = n -> Qu d1 l n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> Diff n -> n
forall p. AffineSpace p => p -> Diff p -> p
.-^ Diff n
b)
qDistanceSq :: (d1 @~ d2, AffineSpace n, InnerSpace (Diff n))
=> Qu d1 l n -> Qu d2 l n -> Qu (d1 @* Z.Two) l (Scalar (Diff n))
qDistanceSq :: Qu d1 l n -> Qu d2 l n -> Qu (d1 @* Two) l (Scalar (Diff n))
qDistanceSq (Qu n
a) (Qu n
b) = Scalar (Diff n) -> Qu (d1 @* Two) l (Scalar (Diff n))
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> n -> Scalar (Diff n)
forall p v.
(AffineSpace p, v ~ Diff p, InnerSpace v) =>
p -> p -> Scalar v
`distanceSq` n
b)
qDistance :: (d1 @~ d2, AffineSpace n, InnerSpace (Diff n), Floating (Scalar (Diff n)))
=> Qu d1 l n -> Qu d2 l n -> Qu d1 l (Scalar (Diff n))
qDistance :: Qu d1 l n -> Qu d2 l n -> Qu d1 l (Scalar (Diff n))
qDistance (Qu n
a) (Qu n
b) = Scalar (Diff n) -> Qu d1 l (Scalar (Diff n))
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
a n -> n -> Scalar (Diff n)
forall p v s.
(AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v,
Floating (Scalar v)) =>
p -> p -> s
`distance` n
b)
numIn :: forall unit dim lcsu n.
( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> Qu dim lcsu n -> unit -> n
numIn :: Qu dim lcsu n -> unit -> n
numIn (Qu n
val) unit
u
= n
val n -> Scalar n -> n
forall v s. (VectorSpace v, s ~ Scalar v) => v -> s -> v
^* Rational -> Scalar n
forall a. Fractional a => Rational -> a
fromRational
(Proxy (LookupList dim lcsu) -> Rational
forall (units :: [Factor *]).
UnitFactor units =>
Proxy units -> Rational
canonicalConvRatioSpec (Proxy (LookupList dim lcsu)
forall k (t :: k). Proxy t
Proxy :: Proxy (LookupList dim lcsu))
Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ unit -> Rational
forall unit. Unit unit => unit -> Rational
canonicalConvRatio unit
u)
infix 5 #
(#) :: ( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> Qu dim lcsu n -> unit -> n
# :: Qu dim lcsu n -> unit -> n
(#) = Qu dim lcsu n -> unit -> n
forall unit (dim :: [Factor *]) (lcsu :: LCSU *) n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
Qu dim lcsu n -> unit -> n
numIn
quOf :: forall unit dim lcsu n.
( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> n -> unit -> Qu dim lcsu n
quOf :: n -> unit -> Qu dim lcsu n
quOf n
d unit
u
= n -> Qu dim lcsu n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n
d n -> Scalar n -> n
forall v s. (VectorSpace v, s ~ Scalar v) => v -> s -> v
^* Rational -> Scalar n
forall a. Fractional a => Rational -> a
fromRational
(unit -> Rational
forall unit. Unit unit => unit -> Rational
canonicalConvRatio unit
u
Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Proxy (LookupList dim lcsu) -> Rational
forall (units :: [Factor *]).
UnitFactor units =>
Proxy units -> Rational
canonicalConvRatioSpec (Proxy (LookupList dim lcsu)
forall k (t :: k). Proxy t
Proxy :: Proxy (LookupList dim lcsu))))
infix 5 %
(%) :: ( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n) )
=> n -> unit -> Qu dim lcsu n
% :: n -> unit -> Qu dim lcsu n
(%) = n -> unit -> Qu dim lcsu n
forall unit (dim :: [Factor *]) (lcsu :: LCSU *) n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
n -> unit -> Qu dim lcsu n
quOf
convert :: forall d l1 l2 n.
( ConvertibleLCSUs d l1 l2
, VectorSpace n
, Fractional (Scalar n) )
=> Qu d l1 n -> Qu d l2 n
convert :: Qu d l1 n -> Qu d l2 n
convert (Qu n
x) = n -> Qu d l2 n
forall (a :: [Factor *]) (lcsu :: LCSU *) n. n -> Qu a lcsu n
Qu (n -> Qu d l2 n) -> n -> Qu d l2 n
forall a b. (a -> b) -> a -> b
$ n
x n -> Scalar n -> n
forall v s. (VectorSpace v, s ~ Scalar v) => v -> s -> v
^* Rational -> Scalar n
forall a. Fractional a => Rational -> a
fromRational (
Proxy (LookupList d l1) -> Rational
forall (units :: [Factor *]).
UnitFactor units =>
Proxy units -> Rational
canonicalConvRatioSpec (Proxy (LookupList d l1)
forall k (t :: k). Proxy t
Proxy :: Proxy (LookupList d l1))
Rational -> Rational -> Rational
forall a. Fractional a => a -> a -> a
/ Proxy (LookupList d l2) -> Rational
forall (units :: [Factor *]).
UnitFactor units =>
Proxy units -> Rational
canonicalConvRatioSpec (Proxy (LookupList d l2)
forall k (t :: k). Proxy t
Proxy :: Proxy (LookupList d l2)))
constant :: ( d @~ e
, ConvertibleLCSUs e DefaultLCSU l
, VectorSpace n
, Fractional (Scalar n) )
=> Qu d DefaultLCSU n -> Qu e l n
constant :: Qu d 'DefaultLCSU n -> Qu e l n
constant = Qu e 'DefaultLCSU n -> Qu e l n
forall (d :: [Factor *]) (l1 :: LCSU *) (l2 :: LCSU *) n.
(ConvertibleLCSUs d l1 l2, VectorSpace n, Fractional (Scalar n)) =>
Qu d l1 n -> Qu d l2 n
convert (Qu e 'DefaultLCSU n -> Qu e l n)
-> (Qu d 'DefaultLCSU n -> Qu e 'DefaultLCSU n)
-> Qu d 'DefaultLCSU n
-> Qu e l n
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Qu d 'DefaultLCSU n -> Qu e 'DefaultLCSU n
forall (d :: [Factor *]) (e :: [Factor *]) (l :: LCSU *) n.
(d @~ e) =>
Qu d l n -> Qu e l n
redim
infix 1 `showIn`
showIn :: ( ValidDLU dim lcsu unit
, VectorSpace n
, Fractional (Scalar n)
, Show unit
, Show n )
=> Qu dim lcsu n -> unit -> String
showIn :: Qu dim lcsu n -> unit -> String
showIn Qu dim lcsu n
x unit
u = n -> String
forall a. Show a => a -> String
show (Qu dim lcsu n
x Qu dim lcsu n -> unit -> n
forall (dim :: [Factor *]) (lcsu :: LCSU *) unit n.
(ValidDLU dim lcsu unit, VectorSpace n, Fractional (Scalar n)) =>
Qu dim lcsu n -> unit -> n
# unit
u) String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" " String -> ShowS
forall a. [a] -> [a] -> [a]
++ unit -> String
forall a. Show a => a -> String
show unit
u