{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
module Language.Drasil.Expr.Class (
ExprC(..),
frac, recip_,
square, half,
oneHalf, oneThird,
apply1, apply2,
m2x2, vec2D, dgnl2x2, rowVec, columnVec, mkSet
) where
import Prelude hiding (sqrt, log, sin, cos, tan, exp)
import Control.Lens ((^.))
import Language.Drasil.Symbol
import Language.Drasil.Expr.Lang
import Language.Drasil.Literal.Lang
import Language.Drasil.Space (DomainDesc(..), RTopology(..), RealInterval, Space)
import qualified Language.Drasil.ModelExpr.Lang as M
import qualified Language.Drasil.CodeExpr.Lang as C
import Language.Drasil.Literal.Class (LiteralC(..))
import Language.Drasil.UID (HasUID(..))
import Utils.Drasil (toColumn)
frac :: (ExprC r, LiteralC r) => Integer -> Integer -> r
frac :: forall r. (ExprC r, LiteralC r) => Integer -> Integer -> r
frac Integer
n Integer
d = Integer -> r
forall r. LiteralC r => Integer -> r
exactDbl Integer
n r -> r -> r
forall r. ExprC r => r -> r -> r
$/ Integer -> r
forall r. LiteralC r => Integer -> r
exactDbl Integer
d
recip_ :: (ExprC r, LiteralC r) => r -> r
recip_ :: forall r. (ExprC r, LiteralC r) => r -> r
recip_ r
denom = Integer -> r
forall r. LiteralC r => Integer -> r
exactDbl Integer
1 r -> r -> r
forall r. ExprC r => r -> r -> r
$/ r
denom
square :: (ExprC r, LiteralC r) => r -> r
square :: forall r. (ExprC r, LiteralC r) => r -> r
square r
x = r
x r -> r -> r
forall r. ExprC r => r -> r -> r
$^ Integer -> r
forall r. LiteralC r => Integer -> r
exactDbl Integer
2
half :: (ExprC r, LiteralC r) => r -> r
half :: forall r. (ExprC r, LiteralC r) => r -> r
half r
x = r
x r -> r -> r
forall r. ExprC r => r -> r -> r
$/ Integer -> r
forall r. LiteralC r => Integer -> r
exactDbl Integer
2
oneHalf :: (ExprC r, LiteralC r) => r
oneHalf :: forall r. (ExprC r, LiteralC r) => r
oneHalf = Integer -> Integer -> r
forall r. (ExprC r, LiteralC r) => Integer -> Integer -> r
frac Integer
1 Integer
2
oneThird :: (ExprC r, LiteralC r) => r
oneThird :: forall r. (ExprC r, LiteralC r) => r
oneThird = Integer -> Integer -> r
forall r. (ExprC r, LiteralC r) => Integer -> Integer -> r
frac Integer
1 Integer
3
apply1 :: (ExprC r, HasUID f, HasSymbol f, HasUID a, HasSymbol a) => f -> a -> r
apply1 :: forall r f a.
(ExprC r, HasUID f, HasSymbol f, HasUID a, HasSymbol a) =>
f -> a -> r
apply1 f
f a
a = f -> [r] -> r
forall f. (HasUID f, HasSymbol f) => f -> [r] -> r
forall r f. (ExprC r, HasUID f, HasSymbol f) => f -> [r] -> r
apply f
f [a -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy a
a]
apply2 :: (ExprC r, HasUID f, HasSymbol f, HasUID a, HasSymbol a, HasUID b, HasSymbol b)
=> f -> a -> b -> r
apply2 :: forall r f a b.
(ExprC r, HasUID f, HasSymbol f, HasUID a, HasSymbol a, HasUID b,
HasSymbol b) =>
f -> a -> b -> r
apply2 f
f a
a b
b = f -> [r] -> r
forall f. (HasUID f, HasSymbol f) => f -> [r] -> r
forall r f. (ExprC r, HasUID f, HasSymbol f) => f -> [r] -> r
apply f
f [a -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy a
a, b -> r
forall c. (HasUID c, HasSymbol c) => c -> r
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy b
b]
m2x2 :: ExprC r => r -> r -> r -> r -> r
m2x2 :: forall r. ExprC r => r -> r -> r -> r -> r
m2x2 r
a r
b r
c r
d = [[r]] -> r
forall r. ExprC r => [[r]] -> r
matrix [[r
a,r
b],[r
c,r
d]]
mkSet :: ExprC r => Space -> [r] -> r
mkSet :: forall r. ExprC r => Space -> [r] -> r
mkSet = Space -> [r] -> r
forall r. ExprC r => Space -> [r] -> r
set'
vec2D :: ExprC r => r -> r -> r
vec2D :: forall r. ExprC r => r -> r -> r
vec2D r
a r
b = [[r]] -> r
forall r. ExprC r => [[r]] -> r
matrix [[r
a],[r
b]]
dgnl2x2 :: (ExprC r, LiteralC r) => r -> r -> r
dgnl2x2 :: forall r. (ExprC r, LiteralC r) => r -> r -> r
dgnl2x2 r
a = r -> r -> r -> r -> r
forall r. ExprC r => r -> r -> r -> r -> r
m2x2 r
a (Integer -> r
forall r. LiteralC r => Integer -> r
int Integer
0) (Integer -> r
forall r. LiteralC r => Integer -> r
int Integer
0)
rowVec :: ExprC r => [r] -> r
rowVec :: forall r. ExprC r => [r] -> r
rowVec [r]
a = [[r]] -> r
forall r. ExprC r => [[r]] -> r
matrix [[r]
a]
columnVec :: ExprC r => [r] -> r
columnVec :: forall r. ExprC r => [r] -> r
columnVec [r]
a = [[r]] -> r
forall r. ExprC r => [[r]] -> r
matrix ([[r]] -> r) -> [[r]] -> r
forall a b. (a -> b) -> a -> b
$ [r] -> [[r]]
forall a. [a] -> [[a]]
toColumn [r]
a
class ExprC r where
infixr 8 $^
infixl 7 $/
infixr 4 $=
infixr 9 $&&
infixr 9 $||
lit :: Literal -> r
($=), ($!=) :: r -> r -> r
($<), ($>), ($<=), ($>=) :: r -> r -> r
($.) :: r -> r -> r
($+) :: r -> r -> r
($*) :: r -> r -> r
($-), ($/), ($^) :: r -> r -> r
($=>), ($<=>) :: r -> r -> r
($&&), ($||) :: r -> r -> r
in' :: r -> r -> r
abs_ :: r -> r
neg :: r -> r
log :: r -> r
ln :: r -> r
sqrt :: r -> r
sin :: r -> r
cos :: r -> r
tan :: r -> r
sec :: r -> r
csc :: r -> r
cot :: r -> r
arcsin :: r -> r
arccos :: r -> r
arctan :: r -> r
exp :: r -> r
dim :: r -> r
norm :: r -> r
negVec :: r -> r
not_ :: r -> r
idx :: r -> r -> r
idxOf :: r -> r -> r
defint, defsum, defprod :: Symbol -> r -> r -> r -> r
realInterval :: HasUID c => c -> RealInterval r r -> r
euclidean :: [r] -> r
cross :: r -> r -> r
vScale :: r -> r -> r
vAdd :: r -> r -> r
vSub :: r -> r -> r
completeCase :: [(r, r)] -> r
incompleteCase :: [(r, r)] -> r
matrix :: [[r]] -> r
set' :: Space -> [r] -> r
apply :: (HasUID f, HasSymbol f) => f -> [r] -> r
sy :: (HasUID c, HasSymbol c) => c -> r
instance ExprC Expr where
lit :: Literal -> Expr
lit = Literal -> Expr
Lit
$= :: Expr -> Expr -> Expr
($=) = EqBinOp -> Expr -> Expr -> Expr
EqBinaryOp EqBinOp
Eq
$!= :: Expr -> Expr -> Expr
($!=) = EqBinOp -> Expr -> Expr -> Expr
EqBinaryOp EqBinOp
NEq
$< :: Expr -> Expr -> Expr
($<) = OrdBinOp -> Expr -> Expr -> Expr
OrdBinaryOp OrdBinOp
Lt
$> :: Expr -> Expr -> Expr
($>) = OrdBinOp -> Expr -> Expr -> Expr
OrdBinaryOp OrdBinOp
Gt
$<= :: Expr -> Expr -> Expr
($<=) = OrdBinOp -> Expr -> Expr -> Expr
OrdBinaryOp OrdBinOp
LEq
$>= :: Expr -> Expr -> Expr
($>=) = OrdBinOp -> Expr -> Expr -> Expr
OrdBinaryOp OrdBinOp
GEq
$. :: Expr -> Expr -> Expr
($.) = VVNBinOp -> Expr -> Expr -> Expr
VVNBinaryOp VVNBinOp
Dot
$+ :: Expr -> Expr -> Expr
($+) (Lit (Int Integer
0)) Expr
r = Expr
r
($+) Expr
l (Lit (Int Integer
0)) = Expr
l
($+) (Lit (Dbl Double
0)) Expr
r = Expr
r
($+) Expr
l (Lit (Dbl Double
0)) = Expr
l
($+) Expr
l (Lit (ExactDbl Integer
0)) = Expr
l
($+) (Lit (ExactDbl Integer
0)) Expr
r = Expr
r
($+) (AssocA AssocArithOper
Add [Expr]
l) (AssocA AssocArithOper
Add [Expr]
r) = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Add ([Expr]
l [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [Expr]
r)
($+) (AssocA AssocArithOper
Add [Expr]
l) Expr
r = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Add ([Expr]
l [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [Expr
r])
($+) Expr
l (AssocA AssocArithOper
Add [Expr]
r) = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Add (Expr
l Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: [Expr]
r)
($+) Expr
l Expr
r = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Add [Expr
l, Expr
r]
$* :: Expr -> Expr -> Expr
($*) (Lit (Int Integer
1)) Expr
r = Expr
r
($*) Expr
l (Lit (Int Integer
1)) = Expr
l
($*) (Lit (Dbl Double
1.0)) Expr
r = Expr
r
($*) Expr
l (Lit (Dbl Double
1.0)) = Expr
l
($*) Expr
l (Lit (ExactDbl Integer
1)) = Expr
l
($*) (Lit (ExactDbl Integer
1)) Expr
r = Expr
r
($*) (AssocA AssocArithOper
Mul [Expr]
l) (AssocA AssocArithOper
Mul [Expr]
r) = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Mul ([Expr]
l [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [Expr]
r)
($*) (AssocA AssocArithOper
Mul [Expr]
l) Expr
r = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Mul ([Expr]
l [Expr] -> [Expr] -> [Expr]
forall a. [a] -> [a] -> [a]
++ [Expr
r])
($*) Expr
l (AssocA AssocArithOper
Mul [Expr]
r) = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Mul (Expr
l Expr -> [Expr] -> [Expr]
forall a. a -> [a] -> [a]
: [Expr]
r)
($*) Expr
l Expr
r = AssocArithOper -> [Expr] -> Expr
AssocA AssocArithOper
Mul [Expr
l, Expr
r]
$- :: Expr -> Expr -> Expr
($-) = ArithBinOp -> Expr -> Expr -> Expr
ArithBinaryOp ArithBinOp
Subt
$/ :: Expr -> Expr -> Expr
($/) = ArithBinOp -> Expr -> Expr -> Expr
ArithBinaryOp ArithBinOp
Frac
$^ :: Expr -> Expr -> Expr
($^) = ArithBinOp -> Expr -> Expr -> Expr
ArithBinaryOp ArithBinOp
Pow
$=> :: Expr -> Expr -> Expr
($=>) = BoolBinOp -> Expr -> Expr -> Expr
BoolBinaryOp BoolBinOp
Impl
$<=> :: Expr -> Expr -> Expr
($<=>) = BoolBinOp -> Expr -> Expr -> Expr
BoolBinaryOp BoolBinOp
Iff
Expr
a $&& :: Expr -> Expr -> Expr
$&& Expr
b = AssocBoolOper -> [Expr] -> Expr
AssocB AssocBoolOper
And [Expr
a, Expr
b]
Expr
a $|| :: Expr -> Expr -> Expr
$|| Expr
b = AssocBoolOper -> [Expr] -> Expr
AssocB AssocBoolOper
Or [Expr
a, Expr
b]
in' :: Expr -> Expr -> Expr
in' = ESBBinOp -> Expr -> Expr -> Expr
ESBBinaryOp ESBBinOp
SContains
abs_ :: Expr -> Expr
abs_ = UFunc -> Expr -> Expr
UnaryOp UFunc
Abs
neg :: Expr -> Expr
neg = UFunc -> Expr -> Expr
UnaryOp UFunc
Neg
log :: Expr -> Expr
log = UFunc -> Expr -> Expr
UnaryOp UFunc
Log
ln :: Expr -> Expr
ln = UFunc -> Expr -> Expr
UnaryOp UFunc
Ln
sqrt :: Expr -> Expr
sqrt = UFunc -> Expr -> Expr
UnaryOp UFunc
Sqrt
sin :: Expr -> Expr
sin = UFunc -> Expr -> Expr
UnaryOp UFunc
Sin
cos :: Expr -> Expr
cos = UFunc -> Expr -> Expr
UnaryOp UFunc
Cos
tan :: Expr -> Expr
tan = UFunc -> Expr -> Expr
UnaryOp UFunc
Tan
sec :: Expr -> Expr
sec = UFunc -> Expr -> Expr
UnaryOp UFunc
Sec
csc :: Expr -> Expr
csc = UFunc -> Expr -> Expr
UnaryOp UFunc
Csc
cot :: Expr -> Expr
cot = UFunc -> Expr -> Expr
UnaryOp UFunc
Cot
arcsin :: Expr -> Expr
arcsin = UFunc -> Expr -> Expr
UnaryOp UFunc
Arcsin
arccos :: Expr -> Expr
arccos = UFunc -> Expr -> Expr
UnaryOp UFunc
Arccos
arctan :: Expr -> Expr
arctan = UFunc -> Expr -> Expr
UnaryOp UFunc
Arctan
exp :: Expr -> Expr
exp = UFunc -> Expr -> Expr
UnaryOp UFunc
Exp
dim :: Expr -> Expr
dim = UFuncVN -> Expr -> Expr
UnaryOpVN UFuncVN
Dim
norm :: Expr -> Expr
norm = UFuncVN -> Expr -> Expr
UnaryOpVN UFuncVN
Norm
negVec :: Expr -> Expr
negVec = UFuncVV -> Expr -> Expr
UnaryOpVV UFuncVV
NegV
vScale :: Expr -> Expr -> Expr
vScale = NVVBinOp -> Expr -> Expr -> Expr
NVVBinaryOp NVVBinOp
Scale
not_ :: Expr -> Expr
not_ = UFuncB -> Expr -> Expr
UnaryOpB UFuncB
Not
idx :: Expr -> Expr -> Expr
idx = LABinOp -> Expr -> Expr -> Expr
LABinaryOp LABinOp
Index
idxOf :: Expr -> Expr -> Expr
idxOf = LABinOp -> Expr -> Expr -> Expr
LABinaryOp LABinOp
IndexOf
defint :: Symbol -> Expr -> Expr -> Expr -> Expr
defint Symbol
v Expr
low Expr
high = AssocArithOper -> DiscreteDomainDesc Expr Expr -> Expr -> Expr
Operator AssocArithOper
Add (Symbol -> RTopology -> Expr -> Expr -> DiscreteDomainDesc Expr Expr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Continuous Expr
low Expr
high)
defsum :: Symbol -> Expr -> Expr -> Expr -> Expr
defsum Symbol
v Expr
low Expr
high = AssocArithOper -> DiscreteDomainDesc Expr Expr -> Expr -> Expr
Operator AssocArithOper
Add (Symbol -> RTopology -> Expr -> Expr -> DiscreteDomainDesc Expr Expr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete Expr
low Expr
high)
defprod :: Symbol -> Expr -> Expr -> Expr -> Expr
defprod Symbol
v Expr
low Expr
high = AssocArithOper -> DiscreteDomainDesc Expr Expr -> Expr -> Expr
Operator AssocArithOper
Mul (Symbol -> RTopology -> Expr -> Expr -> DiscreteDomainDesc Expr Expr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete Expr
low Expr
high)
realInterval :: forall c. HasUID c => c -> RealInterval Expr Expr -> Expr
realInterval c
c = UID -> RealInterval Expr Expr -> Expr
RealI (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
euclidean :: [Expr] -> Expr
euclidean = Expr -> Expr
forall r. ExprC r => r -> r
sqrt (Expr -> Expr) -> ([Expr] -> Expr) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Expr -> Expr -> Expr) -> [Expr] -> Expr
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 Expr -> Expr -> Expr
forall r. ExprC r => r -> r -> r
($+) ([Expr] -> Expr) -> ([Expr] -> [Expr]) -> [Expr] -> Expr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Expr -> Expr) -> [Expr] -> [Expr]
forall a b. (a -> b) -> [a] -> [b]
map Expr -> Expr
forall r. (ExprC r, LiteralC r) => r -> r
square
cross :: Expr -> Expr -> Expr
cross = VVVBinOp -> Expr -> Expr -> Expr
VVVBinaryOp VVVBinOp
Cross
vAdd :: Expr -> Expr -> Expr
vAdd = VVVBinOp -> Expr -> Expr -> Expr
VVVBinaryOp VVVBinOp
VAdd
vSub :: Expr -> Expr -> Expr
vSub = VVVBinOp -> Expr -> Expr -> Expr
VVVBinaryOp VVVBinOp
VSub
completeCase :: [(Expr, Expr)] -> Expr
completeCase = Completeness -> [(Expr, Expr)] -> Expr
Case Completeness
Complete
incompleteCase :: [(Expr, Expr)] -> Expr
incompleteCase = Completeness -> [(Expr, Expr)] -> Expr
Case Completeness
Incomplete
matrix :: [[Expr]] -> Expr
matrix = [[Expr]] -> Expr
Matrix
set' :: Space -> [Expr] -> Expr
set' = Space -> [Expr] -> Expr
Set
apply :: forall f. (HasUID f, HasSymbol f) => f -> [Expr] -> Expr
apply f
f [] = f -> Expr
forall c. (HasUID c, HasSymbol c) => c -> Expr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy f
f
apply f
f [Expr]
ps = UID -> [Expr] -> Expr
FCall (f
f f -> Getting UID f UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID f UID
forall c. HasUID c => Getter c UID
Getter f UID
uid) [Expr]
ps
sy :: forall c. (HasUID c, HasSymbol c) => c -> Expr
sy c
x = UID -> Expr
C (c
x c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
instance ExprC M.ModelExpr where
lit :: Literal -> ModelExpr
lit = Literal -> ModelExpr
M.Lit
$= :: ModelExpr -> ModelExpr -> ModelExpr
($=) = EqBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.EqBinaryOp EqBinOp
M.Eq
$!= :: ModelExpr -> ModelExpr -> ModelExpr
($!=) = EqBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.EqBinaryOp EqBinOp
M.NEq
$< :: ModelExpr -> ModelExpr -> ModelExpr
($<) = OrdBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.OrdBinaryOp OrdBinOp
M.Lt
$> :: ModelExpr -> ModelExpr -> ModelExpr
($>) = OrdBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.OrdBinaryOp OrdBinOp
M.Gt
$<= :: ModelExpr -> ModelExpr -> ModelExpr
($<=) = OrdBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.OrdBinaryOp OrdBinOp
M.LEq
$>= :: ModelExpr -> ModelExpr -> ModelExpr
($>=) = OrdBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.OrdBinaryOp OrdBinOp
M.GEq
$. :: ModelExpr -> ModelExpr -> ModelExpr
($.) = VVNBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.VVNBinaryOp VVNBinOp
M.Dot
$+ :: ModelExpr -> ModelExpr -> ModelExpr
($+) (M.Lit (Int Integer
0)) ModelExpr
r = ModelExpr
r
($+) ModelExpr
l (M.Lit (Int Integer
0)) = ModelExpr
l
($+) (M.Lit (Dbl Double
0)) ModelExpr
r = ModelExpr
r
($+) ModelExpr
l (M.Lit (Dbl Double
0)) = ModelExpr
l
($+) ModelExpr
l (M.Lit (ExactDbl Integer
0)) = ModelExpr
l
($+) (M.Lit (ExactDbl Integer
0)) ModelExpr
r = ModelExpr
r
($+) (M.AssocA AssocArithOper
M.Add [ModelExpr]
l) (M.AssocA AssocArithOper
M.Add [ModelExpr]
r) = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Add ([ModelExpr]
l [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [ModelExpr]
r)
($+) (M.AssocA AssocArithOper
M.Add [ModelExpr]
l) ModelExpr
r = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Add ([ModelExpr]
l [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [ModelExpr
r])
($+) ModelExpr
l (M.AssocA AssocArithOper
M.Add [ModelExpr]
r) = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Add (ModelExpr
l ModelExpr -> [ModelExpr] -> [ModelExpr]
forall a. a -> [a] -> [a]
: [ModelExpr]
r)
($+) ModelExpr
l ModelExpr
r = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Add [ModelExpr
l, ModelExpr
r]
$* :: ModelExpr -> ModelExpr -> ModelExpr
($*) (M.Lit (Int Integer
1)) ModelExpr
r = ModelExpr
r
($*) ModelExpr
l (M.Lit (Int Integer
1)) = ModelExpr
l
($*) (M.Lit (Dbl Double
1.0)) ModelExpr
r = ModelExpr
r
($*) ModelExpr
l (M.Lit (Dbl Double
1.0)) = ModelExpr
l
($*) ModelExpr
l (M.Lit (ExactDbl Integer
1)) = ModelExpr
l
($*) (M.Lit (ExactDbl Integer
1)) ModelExpr
r = ModelExpr
r
($*) (M.AssocA AssocArithOper
M.Mul [ModelExpr]
l) (M.AssocA AssocArithOper
M.Mul [ModelExpr]
r) = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Mul ([ModelExpr]
l [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [ModelExpr]
r)
($*) (M.AssocA AssocArithOper
M.Mul [ModelExpr]
l) ModelExpr
r = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Mul ([ModelExpr]
l [ModelExpr] -> [ModelExpr] -> [ModelExpr]
forall a. [a] -> [a] -> [a]
++ [ModelExpr
r])
($*) ModelExpr
l (M.AssocA AssocArithOper
M.Mul [ModelExpr]
r) = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Mul (ModelExpr
l ModelExpr -> [ModelExpr] -> [ModelExpr]
forall a. a -> [a] -> [a]
: [ModelExpr]
r)
($*) ModelExpr
l ModelExpr
r = AssocArithOper -> [ModelExpr] -> ModelExpr
M.AssocA AssocArithOper
M.Mul [ModelExpr
l,ModelExpr
r]
$- :: ModelExpr -> ModelExpr -> ModelExpr
($-) = ArithBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.ArithBinaryOp ArithBinOp
M.Subt
$/ :: ModelExpr -> ModelExpr -> ModelExpr
($/) = ArithBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.ArithBinaryOp ArithBinOp
M.Frac
$^ :: ModelExpr -> ModelExpr -> ModelExpr
($^) = ArithBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.ArithBinaryOp ArithBinOp
M.Pow
$=> :: ModelExpr -> ModelExpr -> ModelExpr
($=>) = BoolBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.BoolBinaryOp BoolBinOp
M.Impl
$<=> :: ModelExpr -> ModelExpr -> ModelExpr
($<=>) = BoolBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.BoolBinaryOp BoolBinOp
M.Iff
ModelExpr
a $&& :: ModelExpr -> ModelExpr -> ModelExpr
$&& ModelExpr
b = AssocBoolOper -> [ModelExpr] -> ModelExpr
M.AssocB AssocBoolOper
M.And [ModelExpr
a, ModelExpr
b]
ModelExpr
a $|| :: ModelExpr -> ModelExpr -> ModelExpr
$|| ModelExpr
b = AssocBoolOper -> [ModelExpr] -> ModelExpr
M.AssocB AssocBoolOper
M.Or [ModelExpr
a, ModelExpr
b]
in' :: ModelExpr -> ModelExpr -> ModelExpr
in' = ESBBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.ESBBinaryOp ESBBinOp
M.SContains
abs_ :: ModelExpr -> ModelExpr
abs_ = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Abs
neg :: ModelExpr -> ModelExpr
neg = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Neg
log :: ModelExpr -> ModelExpr
log = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Log
ln :: ModelExpr -> ModelExpr
ln = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Ln
sqrt :: ModelExpr -> ModelExpr
sqrt = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Sqrt
sin :: ModelExpr -> ModelExpr
sin = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Sin
cos :: ModelExpr -> ModelExpr
cos = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Cos
tan :: ModelExpr -> ModelExpr
tan = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Tan
sec :: ModelExpr -> ModelExpr
sec = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Sec
csc :: ModelExpr -> ModelExpr
csc = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Csc
cot :: ModelExpr -> ModelExpr
cot = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Cot
arcsin :: ModelExpr -> ModelExpr
arcsin = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Arcsin
arccos :: ModelExpr -> ModelExpr
arccos = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Arccos
arctan :: ModelExpr -> ModelExpr
arctan = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Arctan
exp :: ModelExpr -> ModelExpr
exp = UFunc -> ModelExpr -> ModelExpr
M.UnaryOp UFunc
M.Exp
dim :: ModelExpr -> ModelExpr
dim = UFuncVN -> ModelExpr -> ModelExpr
M.UnaryOpVN UFuncVN
M.Dim
norm :: ModelExpr -> ModelExpr
norm = UFuncVN -> ModelExpr -> ModelExpr
M.UnaryOpVN UFuncVN
M.Norm
negVec :: ModelExpr -> ModelExpr
negVec = UFuncVV -> ModelExpr -> ModelExpr
M.UnaryOpVV UFuncVV
M.NegV
vScale :: ModelExpr -> ModelExpr -> ModelExpr
vScale = NVVBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.NVVBinaryOp NVVBinOp
M.Scale
not_ :: ModelExpr -> ModelExpr
not_ = UFuncB -> ModelExpr -> ModelExpr
M.UnaryOpB UFuncB
M.Not
idx :: ModelExpr -> ModelExpr -> ModelExpr
idx = LABinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.LABinaryOp LABinOp
M.Index
idxOf :: ModelExpr -> ModelExpr -> ModelExpr
idxOf = LABinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.LABinaryOp LABinOp
M.IndexOf
defint :: Symbol -> ModelExpr -> ModelExpr -> ModelExpr -> ModelExpr
defint Symbol
v ModelExpr
low ModelExpr
high = AssocArithOper
-> DomainDesc 'Discrete ModelExpr ModelExpr
-> ModelExpr
-> ModelExpr
forall (t :: RTopology).
AssocArithOper
-> DomainDesc t ModelExpr ModelExpr -> ModelExpr -> ModelExpr
M.Operator AssocArithOper
M.Add (Symbol
-> RTopology
-> ModelExpr
-> ModelExpr
-> DomainDesc 'Discrete ModelExpr ModelExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Continuous ModelExpr
low ModelExpr
high)
defsum :: Symbol -> ModelExpr -> ModelExpr -> ModelExpr -> ModelExpr
defsum Symbol
v ModelExpr
low ModelExpr
high = AssocArithOper
-> DomainDesc 'Discrete ModelExpr ModelExpr
-> ModelExpr
-> ModelExpr
forall (t :: RTopology).
AssocArithOper
-> DomainDesc t ModelExpr ModelExpr -> ModelExpr -> ModelExpr
M.Operator AssocArithOper
M.Add (Symbol
-> RTopology
-> ModelExpr
-> ModelExpr
-> DomainDesc 'Discrete ModelExpr ModelExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete ModelExpr
low ModelExpr
high)
defprod :: Symbol -> ModelExpr -> ModelExpr -> ModelExpr -> ModelExpr
defprod Symbol
v ModelExpr
low ModelExpr
high = AssocArithOper
-> DomainDesc 'Discrete ModelExpr ModelExpr
-> ModelExpr
-> ModelExpr
forall (t :: RTopology).
AssocArithOper
-> DomainDesc t ModelExpr ModelExpr -> ModelExpr -> ModelExpr
M.Operator AssocArithOper
M.Mul (Symbol
-> RTopology
-> ModelExpr
-> ModelExpr
-> DomainDesc 'Discrete ModelExpr ModelExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete ModelExpr
low ModelExpr
high)
realInterval :: forall c.
HasUID c =>
c -> RealInterval ModelExpr ModelExpr -> ModelExpr
realInterval c
c = UID -> RealInterval ModelExpr ModelExpr -> ModelExpr
M.RealI (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
euclidean :: [ModelExpr] -> ModelExpr
euclidean = ModelExpr -> ModelExpr
forall r. ExprC r => r -> r
sqrt (ModelExpr -> ModelExpr)
-> ([ModelExpr] -> ModelExpr) -> [ModelExpr] -> ModelExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModelExpr -> ModelExpr -> ModelExpr) -> [ModelExpr] -> ModelExpr
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 ModelExpr -> ModelExpr -> ModelExpr
forall r. ExprC r => r -> r -> r
($+) ([ModelExpr] -> ModelExpr)
-> ([ModelExpr] -> [ModelExpr]) -> [ModelExpr] -> ModelExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ModelExpr -> ModelExpr) -> [ModelExpr] -> [ModelExpr]
forall a b. (a -> b) -> [a] -> [b]
map ModelExpr -> ModelExpr
forall r. (ExprC r, LiteralC r) => r -> r
square
cross :: ModelExpr -> ModelExpr -> ModelExpr
cross = VVVBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.VVVBinaryOp VVVBinOp
M.Cross
vAdd :: ModelExpr -> ModelExpr -> ModelExpr
vAdd = VVVBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.VVVBinaryOp VVVBinOp
M.VAdd
vSub :: ModelExpr -> ModelExpr -> ModelExpr
vSub = VVVBinOp -> ModelExpr -> ModelExpr -> ModelExpr
M.VVVBinaryOp VVVBinOp
M.VSub
completeCase :: [(ModelExpr, ModelExpr)] -> ModelExpr
completeCase = Completeness -> [(ModelExpr, ModelExpr)] -> ModelExpr
M.Case Completeness
Complete
incompleteCase :: [(ModelExpr, ModelExpr)] -> ModelExpr
incompleteCase = Completeness -> [(ModelExpr, ModelExpr)] -> ModelExpr
M.Case Completeness
Incomplete
matrix :: [[ModelExpr]] -> ModelExpr
matrix = [[ModelExpr]] -> ModelExpr
M.Matrix
set' :: Space -> [ModelExpr] -> ModelExpr
set' = Space -> [ModelExpr] -> ModelExpr
M.Set
apply :: forall f. (HasUID f, HasSymbol f) => f -> [ModelExpr] -> ModelExpr
apply f
f [] = f -> ModelExpr
forall c. (HasUID c, HasSymbol c) => c -> ModelExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy f
f
apply f
f [ModelExpr]
ps = UID -> [ModelExpr] -> ModelExpr
M.FCall (f
f f -> Getting UID f UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID f UID
forall c. HasUID c => Getter c UID
Getter f UID
uid) [ModelExpr]
ps
sy :: forall c. (HasUID c, HasSymbol c) => c -> ModelExpr
sy c
x = UID -> ModelExpr
M.C (c
x c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
instance ExprC C.CodeExpr where
lit :: Literal -> CodeExpr
lit = Literal -> CodeExpr
C.Lit
$= :: CodeExpr -> CodeExpr -> CodeExpr
($=) = EqBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.EqBinaryOp EqBinOp
C.Eq
$!= :: CodeExpr -> CodeExpr -> CodeExpr
($!=) = EqBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.EqBinaryOp EqBinOp
C.NEq
$< :: CodeExpr -> CodeExpr -> CodeExpr
($<) = OrdBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.OrdBinaryOp OrdBinOp
C.Lt
$> :: CodeExpr -> CodeExpr -> CodeExpr
($>) = OrdBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.OrdBinaryOp OrdBinOp
C.Gt
$<= :: CodeExpr -> CodeExpr -> CodeExpr
($<=) = OrdBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.OrdBinaryOp OrdBinOp
C.LEq
$>= :: CodeExpr -> CodeExpr -> CodeExpr
($>=) = OrdBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.OrdBinaryOp OrdBinOp
C.GEq
$. :: CodeExpr -> CodeExpr -> CodeExpr
($.) = VVNBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.VVNBinaryOp VVNBinOp
C.Dot
$+ :: CodeExpr -> CodeExpr -> CodeExpr
($+) (C.Lit (Int Integer
0)) CodeExpr
r = CodeExpr
r
($+) CodeExpr
l (C.Lit (Int Integer
0)) = CodeExpr
l
($+) (C.Lit (Dbl Double
0)) CodeExpr
r = CodeExpr
r
($+) CodeExpr
l (C.Lit (Dbl Double
0)) = CodeExpr
l
($+) CodeExpr
l (C.Lit (ExactDbl Integer
0)) = CodeExpr
l
($+) (C.Lit (ExactDbl Integer
0)) CodeExpr
r = CodeExpr
r
($+) (C.AssocA AssocArithOper
C.Add [CodeExpr]
l) (C.AssocA AssocArithOper
C.Add [CodeExpr]
r) = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Add ([CodeExpr]
l [CodeExpr] -> [CodeExpr] -> [CodeExpr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr]
r)
($+) (C.AssocA AssocArithOper
C.Add [CodeExpr]
l) CodeExpr
r = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Add ([CodeExpr]
l [CodeExpr] -> [CodeExpr] -> [CodeExpr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr
r])
($+) CodeExpr
l (C.AssocA AssocArithOper
C.Add [CodeExpr]
r) = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Add (CodeExpr
l CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
r)
($+) CodeExpr
l CodeExpr
r = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Add [CodeExpr
l, CodeExpr
r]
$* :: CodeExpr -> CodeExpr -> CodeExpr
($*) (C.Lit (Int Integer
1)) CodeExpr
r = CodeExpr
r
($*) CodeExpr
l (C.Lit (Int Integer
1)) = CodeExpr
l
($*) (C.Lit (Dbl Double
1.0)) CodeExpr
r = CodeExpr
r
($*) CodeExpr
l (C.Lit (Dbl Double
1.0)) = CodeExpr
l
($*) CodeExpr
l (C.Lit (ExactDbl Integer
1)) = CodeExpr
l
($*) (C.Lit (ExactDbl Integer
1)) CodeExpr
r = CodeExpr
r
($*) (C.AssocA AssocArithOper
C.Mul [CodeExpr]
l) (C.AssocA AssocArithOper
C.Mul [CodeExpr]
r) = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Mul ([CodeExpr]
l [CodeExpr] -> [CodeExpr] -> [CodeExpr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr]
r)
($*) (C.AssocA AssocArithOper
C.Mul [CodeExpr]
l) CodeExpr
r = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Mul ([CodeExpr]
l [CodeExpr] -> [CodeExpr] -> [CodeExpr]
forall a. [a] -> [a] -> [a]
++ [CodeExpr
r])
($*) CodeExpr
l (C.AssocA AssocArithOper
C.Mul [CodeExpr]
r) = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Mul (CodeExpr
l CodeExpr -> [CodeExpr] -> [CodeExpr]
forall a. a -> [a] -> [a]
: [CodeExpr]
r)
($*) CodeExpr
l CodeExpr
r = AssocArithOper -> [CodeExpr] -> CodeExpr
C.AssocA AssocArithOper
C.Mul [CodeExpr
l,CodeExpr
r]
$- :: CodeExpr -> CodeExpr -> CodeExpr
($-) = ArithBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.ArithBinaryOp ArithBinOp
C.Subt
$/ :: CodeExpr -> CodeExpr -> CodeExpr
($/) = ArithBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.ArithBinaryOp ArithBinOp
C.Frac
$^ :: CodeExpr -> CodeExpr -> CodeExpr
($^) = ArithBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.ArithBinaryOp ArithBinOp
C.Pow
$=> :: CodeExpr -> CodeExpr -> CodeExpr
($=>) = BoolBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.BoolBinaryOp BoolBinOp
C.Impl
$<=> :: CodeExpr -> CodeExpr -> CodeExpr
($<=>) = BoolBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.BoolBinaryOp BoolBinOp
C.Iff
CodeExpr
a $&& :: CodeExpr -> CodeExpr -> CodeExpr
$&& CodeExpr
b = AssocBoolOper -> [CodeExpr] -> CodeExpr
C.AssocB AssocBoolOper
C.And [CodeExpr
a, CodeExpr
b]
CodeExpr
a $|| :: CodeExpr -> CodeExpr -> CodeExpr
$|| CodeExpr
b = AssocBoolOper -> [CodeExpr] -> CodeExpr
C.AssocB AssocBoolOper
C.Or [CodeExpr
a, CodeExpr
b]
in' :: CodeExpr -> CodeExpr -> CodeExpr
in' = ESBBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.ESBBinaryOp ESBBinOp
C.SContains
abs_ :: CodeExpr -> CodeExpr
abs_ = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Abs
neg :: CodeExpr -> CodeExpr
neg = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Neg
log :: CodeExpr -> CodeExpr
log = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Log
ln :: CodeExpr -> CodeExpr
ln = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Ln
sqrt :: CodeExpr -> CodeExpr
sqrt = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Sqrt
sin :: CodeExpr -> CodeExpr
sin = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Sin
cos :: CodeExpr -> CodeExpr
cos = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Cos
tan :: CodeExpr -> CodeExpr
tan = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Tan
sec :: CodeExpr -> CodeExpr
sec = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Sec
csc :: CodeExpr -> CodeExpr
csc = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Csc
cot :: CodeExpr -> CodeExpr
cot = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Cot
arcsin :: CodeExpr -> CodeExpr
arcsin = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Arcsin
arccos :: CodeExpr -> CodeExpr
arccos = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Arccos
arctan :: CodeExpr -> CodeExpr
arctan = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Arctan
exp :: CodeExpr -> CodeExpr
exp = UFunc -> CodeExpr -> CodeExpr
C.UnaryOp UFunc
C.Exp
dim :: CodeExpr -> CodeExpr
dim = UFuncVN -> CodeExpr -> CodeExpr
C.UnaryOpVN UFuncVN
C.Dim
norm :: CodeExpr -> CodeExpr
norm = UFuncVN -> CodeExpr -> CodeExpr
C.UnaryOpVN UFuncVN
C.Norm
negVec :: CodeExpr -> CodeExpr
negVec = UFuncVV -> CodeExpr -> CodeExpr
C.UnaryOpVV UFuncVV
C.NegV
vScale :: CodeExpr -> CodeExpr -> CodeExpr
vScale = NVVBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.NVVBinaryOp NVVBinOp
C.Scale
not_ :: CodeExpr -> CodeExpr
not_ = UFuncB -> CodeExpr -> CodeExpr
C.UnaryOpB UFuncB
C.Not
idx :: CodeExpr -> CodeExpr -> CodeExpr
idx = LABinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.LABinaryOp LABinOp
C.Index
idxOf :: CodeExpr -> CodeExpr -> CodeExpr
idxOf = LABinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.LABinaryOp LABinOp
C.IndexOf
defint :: Symbol -> CodeExpr -> CodeExpr -> CodeExpr -> CodeExpr
defint Symbol
v CodeExpr
low CodeExpr
high = AssocArithOper
-> DiscreteDomainDesc CodeExpr CodeExpr -> CodeExpr -> CodeExpr
C.Operator AssocArithOper
C.Add (Symbol
-> RTopology
-> CodeExpr
-> CodeExpr
-> DiscreteDomainDesc CodeExpr CodeExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Continuous CodeExpr
low CodeExpr
high)
defsum :: Symbol -> CodeExpr -> CodeExpr -> CodeExpr -> CodeExpr
defsum Symbol
v CodeExpr
low CodeExpr
high = AssocArithOper
-> DiscreteDomainDesc CodeExpr CodeExpr -> CodeExpr -> CodeExpr
C.Operator AssocArithOper
C.Add (Symbol
-> RTopology
-> CodeExpr
-> CodeExpr
-> DiscreteDomainDesc CodeExpr CodeExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete CodeExpr
low CodeExpr
high)
defprod :: Symbol -> CodeExpr -> CodeExpr -> CodeExpr -> CodeExpr
defprod Symbol
v CodeExpr
low CodeExpr
high = AssocArithOper
-> DiscreteDomainDesc CodeExpr CodeExpr -> CodeExpr -> CodeExpr
C.Operator AssocArithOper
C.Mul (Symbol
-> RTopology
-> CodeExpr
-> CodeExpr
-> DiscreteDomainDesc CodeExpr CodeExpr
forall a b.
Symbol -> RTopology -> a -> b -> DomainDesc 'Discrete a b
BoundedDD Symbol
v RTopology
Discrete CodeExpr
low CodeExpr
high)
realInterval :: forall c.
HasUID c =>
c -> RealInterval CodeExpr CodeExpr -> CodeExpr
realInterval c
c = UID -> RealInterval CodeExpr CodeExpr -> CodeExpr
C.RealI (c
c c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)
euclidean :: [CodeExpr] -> CodeExpr
euclidean = CodeExpr -> CodeExpr
forall r. ExprC r => r -> r
sqrt (CodeExpr -> CodeExpr)
-> ([CodeExpr] -> CodeExpr) -> [CodeExpr] -> CodeExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeExpr -> CodeExpr -> CodeExpr) -> [CodeExpr] -> CodeExpr
forall a. (a -> a -> a) -> [a] -> a
forall (t :: * -> *) a. Foldable t => (a -> a -> a) -> t a -> a
foldr1 CodeExpr -> CodeExpr -> CodeExpr
forall r. ExprC r => r -> r -> r
($+) ([CodeExpr] -> CodeExpr)
-> ([CodeExpr] -> [CodeExpr]) -> [CodeExpr] -> CodeExpr
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeExpr -> CodeExpr) -> [CodeExpr] -> [CodeExpr]
forall a b. (a -> b) -> [a] -> [b]
map CodeExpr -> CodeExpr
forall r. (ExprC r, LiteralC r) => r -> r
square
cross :: CodeExpr -> CodeExpr -> CodeExpr
cross = VVVBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.VVVBinaryOp VVVBinOp
C.Cross
vAdd :: CodeExpr -> CodeExpr -> CodeExpr
vAdd = VVVBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.VVVBinaryOp VVVBinOp
C.VAdd
vSub :: CodeExpr -> CodeExpr -> CodeExpr
vSub = VVVBinOp -> CodeExpr -> CodeExpr -> CodeExpr
C.VVVBinaryOp VVVBinOp
C.VSub
completeCase :: [(CodeExpr, CodeExpr)] -> CodeExpr
completeCase = Completeness -> [(CodeExpr, CodeExpr)] -> CodeExpr
C.Case Completeness
Complete
incompleteCase :: [(CodeExpr, CodeExpr)] -> CodeExpr
incompleteCase = Completeness -> [(CodeExpr, CodeExpr)] -> CodeExpr
C.Case Completeness
Incomplete
matrix :: [[CodeExpr]] -> CodeExpr
matrix = [[CodeExpr]] -> CodeExpr
C.Matrix
set' :: Space -> [CodeExpr] -> CodeExpr
set' = Space -> [CodeExpr] -> CodeExpr
C.Set
apply :: forall f. (HasUID f, HasSymbol f) => f -> [CodeExpr] -> CodeExpr
apply f
f [] = f -> CodeExpr
forall c. (HasUID c, HasSymbol c) => c -> CodeExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy f
f
apply f
f [CodeExpr]
ps = UID -> [CodeExpr] -> [(UID, CodeExpr)] -> CodeExpr
C.FCall (f
f f -> Getting UID f UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID f UID
forall c. HasUID c => Getter c UID
Getter f UID
uid) [CodeExpr]
ps []
sy :: forall c. (HasUID c, HasSymbol c) => c -> CodeExpr
sy c
x = UID -> CodeExpr
C.C (c
x c -> Getting UID c UID -> UID
forall s a. s -> Getting a s a -> a
^. Getting UID c UID
forall c. HasUID c => Getter c UID
Getter c UID
uid)