From: Francis Russell Date: Tue, 18 Sep 2012 18:53:53 +0000 (+0100) Subject: Rewrite inner product as an integral of a product. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0379c2d31839090f86c7652df066e4957a381daa;p=francis%2Fofc.git Rewrite inner product as an integral of a product. --- diff --git a/src/Parser.hs b/src/Parser.hs index e5f920e..12b233b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -95,7 +95,7 @@ parseInner = do e1 <- parseExpression _ <- lSymbol "," e2 <- parseExpression - return $ Inner e1 e2 + return $ Integrate $ Multiply e1 e2 "inner product" parseSum = do diff --git a/src/TopLevel.hs b/src/TopLevel.hs index 3b4fe20..81ad69e 100644 --- a/src/TopLevel.hs +++ b/src/TopLevel.hs @@ -23,7 +23,7 @@ data Expression = ConstReal Double | ConstInteger Integer | Negate Expression | - Inner Expression Expression | + Integrate Expression | Laplacian Expression | Sum Expression String | Multiply Expression Expression | @@ -135,7 +135,7 @@ promoteType IntegerType IntegerType = IntegerType getType :: OFL -> Expression -> BaseType getType _ (ConstReal _) = RealType getType _ (ConstInteger _) = IntegerType -getType _ (Inner _ _) = RealType +getType _ (Integrate _) = RealType getType _ (Laplacian _) = FunctionType getType _ (PositionComponent _) = FunctionType getType ofl (IndexedIdentifier name _) = getValueType ofl name @@ -213,11 +213,9 @@ validateExpression _ (ConstInteger _) = validationSuccess validateExpression ofl (Negate e) = validateExpression ofl e -validateExpression ofl (Inner a b) = do +validateExpression ofl (Integrate a) = do validateExpression ofl a - validateExpression ofl b isFunction ofl a - isFunction ofl b validateExpression ofl (Laplacian e) = do validateExpression ofl e