bugGNU Octave - Bugs: bug #45423, symbolic package fails to...

 
 

bug #45423: symbolic package fails to construct matrices

Submitter:  None
Submitted:  Sat 27 Jun 2015 10:52:04 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Duplicate Assigned to:  None
Originator Name:  Rock Storm Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.2
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 04 Jul 2015 01:27:42 PM UTC, comment #9: 

Marked as duplicate of bug #42152

Carnë Draug <carandraug>
Group Member
Sat 04 Jul 2015 09:48:16 AM UTC, comment #8: 

Honestly don't see how to mark a dupe on this bug tracker... or maybe I just don't have permission?

Colin Macdonald <cbm>
Sat 04 Jul 2015 09:46:36 AM UTC, comment #7: 

Yes, I think this is a core octave bug:

https://savannah.gnu.org/bugs/index.php?42152

Also noted here, with workarounds:
https://github.com/cbm755/octsympy/issues/8

Colin Macdonald <cbm>
Sat 04 Jul 2015 12:03:58 AM UTC, comment #6: 

Adding maintainer of the symbolic package to cc

Carnë Draug <carandraug>
Group Member
Sun 28 Jun 2015 11:27:29 AM UTC, comment #5: 

I believe the problem is related to how octave and sympy communicate. According to sympy's documentation http://docs.sympy.org/latest/tutorial/matrices.html, sympy will not recognize octave's matrix notation. It requires rows to have their own brackets.

If this workaround is used from the very beginning it works just fine:

octave:2> syms a
octave:3> A = [[1, 2]; [a, 4]]
A = (sym 2×2 matrix)

  ⎡1  2⎤
  ⎢    ⎥
  ⎣a  4⎦


So for now, as long as matrices are typed in following sympy's notation right from the start, it works.

Anonymous
Sat 27 Jun 2015 06:10:11 PM UTC, comment #4: 

this fails

A = [ a, 2; 6, 4 ]

so the first item in each row must be a sym

Doug Stewart <dastew>
Sat 27 Jun 2015 05:09:36 PM UTC, comment #3: 

I did some more digging:


syms a
this works
A = sym([ a, 2; a, 4 ])
and this works
A = [ a, 2; a, 4 ]
but this does not work
A = [ 1, 2; a, 4 ]
A = sym([ 1, 2; a, 4 ])

so if the first item in the matrix is a sym then it works

Doug Stewart <dastew>
Sat 27 Jun 2015 03:08:34 PM UTC, comment #2: 

one more workaround

cmd={
"a= symbols('a')" ;
"B=Matrix([[1, -1], [3, a], [0, 2]]);return ( B,)"
};
dd=python_cmd(cmd)

Doug Stewart <dastew>
Sat 27 Jun 2015 01:53:55 PM UTC, comment #1: 

this might be a workaround

syms a b c d f m n p ;
n =sym( [ a; b;  c; 4 ] )
d=reshape(n,2,2)

p = sym([sym(0); 1; sym(2); 3])
m=reshape(p, 2, 2)
f=inv(d)
m*f

So we can make a col. vec. and then reshape it.

Doug Stewart <dastew>
Sat 27 Jun 2015 10:52:04 AM UTC, original submission:  

I am using octave forge package "symbolic", and it basically fails when constructing multiple-rows matrices that combine real numbers and symbolic variables.


Package Name  | Version | Installation directory
--------------+---------+-----------------------
    symbolic *|   2.2.1 | /home/rock/octave/symbolic-2.2.1


Simple example of the error:

syms a
A = [1, 2; a, 4]


This code produces the following error:

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


Without any knowledge of the internals of this package this error seems somehow related to this other filed bug #42152

The workaround suggested at https://github.com/cbm755/octsympy/issues/8 also produces an error:

octave:4> B = [[1 2];[a 4]]
error: class cannot be indexed with {
error: evaluating argument list element number 2
error: called from:
error:   /home/rock/octave/symbolic-2.2.1/@sym/horzcat.m at line 51, column 11


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by cbm (Posted a comment)
  • -email is unavailable- added by carandraug (Colin Macdonald - maintainer of symbolic package)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-22 mtmiller Open/ClosedOpen Closed
    2015-07-04 carandraug StatusNone Duplicate
        Dependencies- Depends on bugs #42152
    2015-07-04 carandraug Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code