linear-grammar-0.0.1.6: A simple grammar for building linear equations and inclusive inequalities.

Safe HaskellSafe
LanguageHaskell2010

Linear.Grammar

Contents

Synopsis

User-facing API

data LinAst Source

User-facing abstract syntax tree

Instances

(.+.) :: LinAst -> LinAst -> LinAst infixr 8 Source

class Coefficient x y where Source

Methods

(.*.) :: x -> y -> LinAst infixr 9 Source

multLin :: LinAst -> LinAst Source

Pushes ECoeff down the tree, leaving EAdd at the top level. After using this funciton, all ECoeff constructors LinAst parameter will be EVar.

Linear Expressions

data LinVar Source

Constructors

LinVar 

Fields

varName :: String
 
varCoeff :: Double
 

Instances

Eq LinVar Source 
Ord LinVar Source

For sorting tableaus

Show LinVar Source 
Arbitrary LinVar Source 

eqLinVar :: LinVar -> LinVar -> Bool Source

Boolean equality with e^-6 precision.

data LinExpr Source

Linear expressions suited for normal and standard form.

Constructors

LinExpr 

Fields

exprVars :: [LinVar]
 
exprConst :: Double
 

Instances

eqLinExpr :: LinExpr -> LinExpr -> Bool Source

Boolean equality with e^-6 precision.

addLin :: LinAst -> LinExpr Source

Turns LinAst to LinExpr - should be done after multLin.

removeDupLin :: LinExpr -> LinExpr Source

Merged duplicate LinVars in a LinExpr. Should be used after addLin.

Linear Inequalities

data Ineq Source

Instances

(.==.) :: LinAst -> LinAst -> Ineq infixl 7 Source

(.<=.) :: LinAst -> LinAst -> Ineq infixl 7 Source

(.=>.) :: LinAst -> LinAst -> Ineq infixl 7 Source

Standard Form

eqIneqStdForm :: IneqStdForm -> IneqStdForm -> Bool Source

Boolean equality with e^-6 precision.

standardForm :: Ineq -> IneqStdForm Source

Turns a user-level AST to a structurally standard from inequality.

standardize :: Ineq -> Ineq Source

Standardizes user-level inequalities - to be used before standardForm.