Units with matrix inversion
See original GitHub issueWhen inverting a matrix with units using numpy.linalg.inv, the units of the inverted matrix stay the same as the input matrix. The units should also be inverted. As an example:
import numpy
import astropy.units
scale = numpy.matrix([[-1, 0], [0, 1]])*astropy.units.arcsec/astropy.units.pixel
numpy.linalg.inv(scale)
The returned value should be in units of pix/arcsec but are instead kept as arcsec/pix.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
What are the units of an inverse matrix? - Math Stack Exchange
As you know from the cofactor formula, the entries of the inverse matrix are homogeneous ...
Read more >What happens with a matrix unit if its inverse is taken? - Quora
The units of the inverse matrix of a matrix whose elements have physical units is: 1/units of the original matrix).
Read more >How do units flow through matrix operations? - Stack Overflow
Answer to 4): the units of the inverse of a matrix A are given by which means that the units are the element-wise...
Read more >Invertible matrix - Wikipedia
In linear algebra, an n-by-n square matrix A is called invertible (also nonsingular or nondegenerate), if there exists an n-by-n square matrix B...
Read more >Definition, Formulas, Steps to Find Inverse Matrix, Examples
For example, 2 × 2, 2 × 3, 3 × 2, 3 × 3, 4 × 4 and so on. We can find...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting!
Indeed,
np.matrix
is not supported with units (it is a differentnp.ndarray
subclass). Note that it is also deprecated on the numpy side, where it is suggested just to use arrays with the relevant shape.In principle, I would hope that we can eventually support
linalg
with quantity arrays (with matrix shape), but we’re not there yet (needs implementation of the new__array_function__
, and numpy >=1.17. So, I fear that for now you’ll just have to do things by hand…@mhvk - I’m removing this from the milestone, but keeping the big tracking one in, just a little bit longer.