symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.41k stars 145 forks source link

matrix.py operations not returning <class 'symforce.geo.matrix'> types #185

Closed lowjunen closed 2 years ago

lowjunen commented 2 years ago

I noticed that if I wanted to do jacobian after playing around with some matrix math, the output is a <class 'symengine.lib.symengine_wrapper.Add'> and not something like <class 'symforce.geo.matrix.Matrix31'>. To reproduce:

v1 = v.T*v
v2 = v.squared_norm()

dv1 = v1.jacobian(v)
dv2 = v2.jacobian(v)

dv2 will throw an error. Is this by design?

hayk-skydio commented 2 years ago

v.squared_norm() will return a scalar type, so it has .diff() defined instead of .jacobian(). To make a vector, you can call geo.V1(v2). Does that help?