File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
src/Linear/Constraint/Linear Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ -- |
2+ -- Module: Linear.Constraint.Linear.Util
3+ -- Description: Utility functions for linear constraints
4+ -- Copyright: (c) Junaid Rasheed, 2024
5+ -- License: BSD-3
6+ -- Maintainer: Junaid Rasheed <jrasheed178@gmail.com>
7+ -- Stability: experimental
8+ module Linear.Constraint.Linear.Util where
9+
10+ import qualified Data.Set as Set
11+ import Linear.Constraint.Linear.Types (LinearEquation (.. ))
12+ import Linear.Expr.Types (ExprVarsOnly )
13+ import Linear.Expr.Util
14+ ( exprVarsOnlyMaxVar
15+ , exprVarsOnlyVars
16+ , substVarExprVarsOnly
17+ )
18+ import Linear.Var.Types (Var )
19+
20+ -- | Get the variables in a linear equation
21+ linearEquationVars :: LinearEquation -> Set. Set Var
22+ linearEquationVars (LinearEquation lhs _) = exprVarsOnlyVars lhs
23+
24+ findHighestVar :: LinearEquation -> Var
25+ findHighestVar (LinearEquation lhs _) = exprVarsOnlyMaxVar lhs
26+
27+ substVarWith ::
28+ Var -> ExprVarsOnly -> LinearEquation -> LinearEquation
29+ substVarWith var expr (LinearEquation lhs rhs) = LinearEquation (substVarExprVarsOnly var expr lhs) rhs
You can’t perform that action at this time.
0 commit comments