gnu-octave / symbolic

A Symbolic Package for Octave using SymPy
https://octave.sourceforge.io/symbolic/
GNU General Public License v3.0
151 stars 36 forks source link

unexpected error creating a matrix: octave_base_value::map_value(): wrong type argument 'scalar' #1254

Closed NRJank closed 1 year ago

NRJank commented 1 year ago

over on the octave.discourse.group, a user reports the following running fine in Matlab symbolic, but giving warnings and errors in Octave (verifiied in Octave 8.2.0 with bundled symbolic 3.1.1)

pkg load symbolic
m1 = 123.25; Tetta1 = 6.57; 
syms Omega

Ua = [1, 0, 0, 0; 0, 1, 0, 0; -m1*(Omega)^2, 0, 1, 0; 0, -Tetta1*(Omega)^2, 0, 1];

Symbolic pkg v3.1.1: Python communication link active, SymPy v1.10.1.
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
    double_to_sym_heuristic at line 50 column 7
    sym at line 379 column 13
    mtimes at line 54 column 5
    C:/Users/dimeskib/AppData/Local/Temp/octave_lmTcGp.m at line 4 column 4

warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
    double_to_sym_heuristic at line 50 column 7
    sym at line 379 column 13
    mtimes at line 54 column 5
    C:/Users/dimeskib/AppData/Local/Temp/octave_lmTcGp.m at line 4 column 4

error: octave_base_value::map_value(): wrong type argument 'scalar'

the warnings are understandable but the error is unexpected.

the user was able to avoid the error by instead using:

Ua = cell2sym({1, 0, 0, 0; 0, 1, 0, 0; -m1*(Omega)^2, 0, 1, 0; 0, -Tetta1*(Omega)^2, 0, 1});

but reports that he was 'unable to solve the system'

cbm755 commented 1 year ago

Almost certainly because of #8, long time limitation of the upstream Octave parser.

My preferred workaround would be to ensure every row has at least one sym:


m1 = sym(12325)/100
Tetta1 = sym(657)/100
Ua = [sym(1), 0, 0, 0; sym(0), 1, 0, 0; -m1*(Omega)^2, 0, 1, 0; 0, -Tetta1*(Omega)^2, 0, 1];