Open translunar opened 8 years ago
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.
I'm confused about what you're asking in the last paragraph. Can you give me an example?
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 >
.
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>'
This puzzled me for a while, and then I realized it's definitely a bug in NMatrix. Let me get back to you.
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.