Jikka-5.0.11.2: A transpiler from Python to C++ for competitive programming
Safe HaskellNone
LanguageHaskell2010

Jikka.Core.Language.ArithmeticalExpr

Synopsis

Basic functions

parseArithmeticalExpr :: Expr -> ArithmeticalExpr Source #

parseArithmeticalExpr converts a given expr to a normal form \(\sum_i \prod_j e _ {i,j})\). This assumes given exprs have the type \(\mathbf{int}\).

Advanced functions

unNPlusKPattern :: ArithmeticalExpr -> Maybe (VarName, Integer) Source #

unNPlusKPattern recognizes a pattern of \(x + k\) for a variable \(x\) and an integer constant \(k \in \mathbb{Z}\).

makeVectorFromArithmeticalExpr :: Vector VarName -> ArithmeticalExpr -> Maybe (Vector ArithmeticalExpr, ArithmeticalExpr) Source #

makeVectorFromArithmeticalExpr makes a vector \(f\) and a expr \(c\) from a given vector of variables \(x_0, x_1, \dots, x _ {n - 1}\) and a given expr \(e\) s.t. \(f\) and \(c\) don't have \(x_0, x_1, \dots, x _ {n - 1}\) as free variables and \(e = c + f \cdot (x_0, x_1, \dots, x _ {n - 1})\) holds. This assumes given variables and exprs have the type \(\mathbf{int}\).

  • The returned exprs are normalized with normalizeArithmeticalExpr.

makeAffineFunctionFromArithmeticalExpr :: VarName -> ArithmeticalExpr -> Maybe (ArithmeticalExpr, ArithmeticalExpr) Source #

makeAffineFunctionFromArithmeticalExpr is a specialized version of makeVectorFromArithmeticalExpr. This function returns \(a, b\) for a given variable \(x\) and a given expr \(e = a x + b\) where \(a, b\) which doesn't use \(x\) free.