Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose MatrixSymbol, BlockMatrix, BlockDiagMatrix, etc. #36

Open
translunar opened this issue Apr 6, 2016 · 6 comments
Open

Expose MatrixSymbol, BlockMatrix, BlockDiagMatrix, etc. #36

translunar opened this issue Apr 6, 2016 · 6 comments

Comments

@translunar
Copy link
Contributor

It'd be great if I could do differentiation on vectors and matrices. (Is this something that can be done in Python SymEngine right now?)

http://docs.sympy.org/latest/modules/matrices/expressions.html

I'd like to be able to compute (and evaluate) Jacobians.

@isuruf
Copy link
Member

isuruf commented Apr 7, 2016

MatrixSymbol, BlockMatrix, BlockDiagMatrix are not in SymEngine yet. They are only in SymPy.

In SymEngine there's support for DenseMatrix which can do jacobian among other functionalities.

I have a question about how to wrap this. Should symengine.rb wrap DenseMatrix class and its functionalities or use NMatrix with dtype equal to object.

I tried matrix functionalities with NMatrix and most algorithms require a < operator defined on the objects, but SymEngine doesn't have < operator overloaded, because in SymEngine only structural comparison is implemented. Mathematical comparison is not yet implemented.

@translunar
Copy link
Contributor Author

I'm confused about what you're asking in the last paragraph. Can you give me an example?

@isuruf
Copy link
Member

isuruf commented Apr 7, 2016

@translunar
Copy link
Contributor Author

Okay, so I believe this is the (or a) cause (then also a few other similar lines, like 52). That doesn't necessarily help you, but I wanted to track it down and make sure I understood the problem. It's called by the C version of getrf we've written for Ruby objects.

The problem is that the LAPACK/BLAS functions are primarily numeric algorithms, so they do use </> comparisons.

What happens if you call det_exact on an NMatrix object instead of det? This one shouldn't call any LAPACK functions, so I think it'd skip the calls to < and >.

@isuruf
Copy link
Member

isuruf commented Apr 7, 2016

I get this

DataTypeError: Conversion to RubyObject requested from unknown/invalid data type (did you try to convert from a VALUE?)
(pry):32:in `det_exact'
(pry):32:in `<main>'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:355:in `eval'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:355:in `evaluate_ruby'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:323:in `handle_line'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:242:in `catch'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:242:in `block in eval'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:241:in `catch'
/home/isuru/.gem/ruby/2.1.0/gems/pry-0.10.3/lib/pry/pry_instance.rb:241:in `eval'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/backend.rb:65:in `eval'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/backend.rb:12:in `eval'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/kernel.rb:87:in `execute_request'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/kernel.rb:47:in `dispatch'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/kernel.rb:37:in `run'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/command.rb:70:in `run_kernel'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/lib/iruby/command.rb:34:in `run'
/home/isuru/.gem/ruby/2.1.0/gems/iruby-0.2.8/bin/iruby:5:in `<top (required)>'
/home/isuru/.gem/ruby/2.1.0/bin/iruby:23:in `load'
/home/isuru/.gem/ruby/2.1.0/bin/iruby:23:in `<main>'

@translunar
Copy link
Contributor Author

This puzzled me for a while, and then I realized it's definitely a bug in NMatrix. Let me get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants