Skip to content

Returned solution of A*x=b via A.LUsolve(b) cannot be worked with #442

@hpaantee

Description

@hpaantee

I have a system of equations Ax=b. A has a shape of 576x576.
Here, A is a sparse matrix where some entries might contain a symbol.
I can use x = A.LUsolve(b) just fine (~30) to solve for a symbolic solution of x.

However, I can't do anything with the result. Lambdify gives the following RuntimeError:

f = symengine.Lambdify([v], x)
File "symengine_wrapper.pyx", line 5276, in symengine.lib.symengine_wrapper.Lambdify
File "symengine_wrapper.pyx", line 4856, in symengine.lib.symengine_wrapper._Lambdify.__init__
File "symengine_wrapper.pyx", line 5091, in symengine.lib.symengine_wrapper.LLVMDouble._init
RuntimeError: -1.14183378644392e+50 + 8.20975478115991e+48*I

Substituting x and converting to numpy or printing the first element does never return.
Here is my code, matrix A is loaded from a file via sympy:

import sympy
from sympy.parsing.sympy_parser import parse_expr
import symengine

with open('matrix_A.txt', 'r') as f:
    A = parse_expr(f.read())
b = sympy.zeros(576, 1)
b[0,0] = 1
A = symengine.Matrix(A)
b = symengine.Matrix(b)
x = A.LUsolve(b)
print('solved!')
v = symengine.var('w01 Efield_01')
f = symengine.Lambdify([v], x)

Am I doing something wrong or am I just hitting some limitation?
Here is the attached file:
matrix_A.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions