summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--polymatrix/__init__.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/polymatrix/__init__.py b/polymatrix/__init__.py
index 8ee1488..2863164 100644
--- a/polymatrix/__init__.py
+++ b/polymatrix/__init__.py
@@ -440,38 +440,38 @@ def to_matrix_repr(
initial=(state, tuple()),
))
- if variables is None:
+ # if variables is None:
- def gen_used_variables():
- def gen_used_auxillary_variables(considered):
- monomial_terms = state.auxillary_equations[considered[-1]]
- for monomial in monomial_terms.keys():
- for variable in monomial:
- yield variable
+ # def gen_used_variables():
+ # def gen_used_auxillary_variables(considered):
+ # monomial_terms = state.auxillary_equations[considered[-1]]
+ # for monomial in monomial_terms.keys():
+ # for variable in monomial:
+ # yield variable
- if variable not in considered and variable in state.auxillary_equations:
- yield from gen_used_auxillary_variables(considered + (variable,))
+ # if variable not in considered and variable in state.auxillary_equations:
+ # yield from gen_used_auxillary_variables(considered + (variable,))
- for underlying in underlying_list:
- for row in range(underlying.shape[0]):
- for col in range(underlying.shape[1]):
+ # for underlying in underlying_list:
+ # for row in range(underlying.shape[0]):
+ # for col in range(underlying.shape[1]):
- try:
- underlying_terms = underlying.get_poly(row, col)
- except KeyError:
- continue
+ # try:
+ # underlying_terms = underlying.get_poly(row, col)
+ # except KeyError:
+ # continue
- for monomial in underlying_terms.keys():
- for variable, _ in monomial:
- yield variable
+ # for monomial in underlying_terms.keys():
+ # for variable, _ in monomial:
+ # yield variable
- if variable in state.auxillary_equations:
- yield from gen_used_auxillary_variables((variable,))
+ # if variable in state.auxillary_equations:
+ # yield from gen_used_auxillary_variables((variable,))
- ordered_variable_index = tuple(sorted(set(gen_used_variables())))
+ # ordered_variable_index = tuple(sorted(set(gen_used_variables())))
- else:
- state, ordered_variable_index = get_variable_indices(state, variables)
+ # else:
+ state, ordered_variable_index = get_variable_indices(state, variables)
variable_index_map = {old: new for new, old in enumerate(ordered_variable_index)}
@@ -557,18 +557,17 @@ def to_matrix_repr(
return init_state_monad(func)
-def to_constant_matrix(
+def to_constant_repr(
expr: Expression,
) -> StateMonadMixin[ExpressionState, np.ndarray]:
def func(state: ExpressionState):
state, underlying = expr.apply(state)
- A = np.zeros(underlying.shape, dtype=np.float32)
+ A = np.zeros(underlying.shape, dtype=np.double)
for (row, col), polynomial in underlying.get_terms():
for monomial, value in polynomial.items():
-
if len(monomial) == 0:
A[row, col] = value