On Thu, 15 Aug 2024 at 16:51, Florent Bulkilol <bulki...@gmail.com> wrote:
>
> Hi,
>
> I need to perform a Smith decomposition on (a priori not square) matrices to 
> find a certain change of basis related to the Smith invariants.
>
> The Smith normal form is already implemented in SymPy in 
> `sympy.matrices.normalforms`, but it returns only the Smith normal form, not 
> its decomposition itself.
>
> In general, the Smith decomposition of a matrix A is defined in terms of 
> three matrices V, D, W so that
>
> A = V * D * W
>
> where V,W are both square, invertible, and integer-valued matrices. Is there 
> any way of obtaining those matrices without reimplementing the algorithm 
> myself? I assume that these matrices are computed at least implicitely, but I 
> could not find a way of returning them.

Just following up on this. The Smith normal form with the transform
matrices is now available in SymPy's master branch (thanks to Isuru
Fernando):

  https://github.com/sympy/sympy/pull/17451

To test it you can install sympy from master like:

   pip install git+https://github.com/sympy/sympy.git@master

It returns the inverses of the matrices V and W that you were expecting:

In [4]: from sympy.matrices.normalforms import smith_normal_decomp

In [5]: A = randMatrix(3, 4)

In [6]: D, v, w = smith_normal_decomp(A)

In [7]: D == v*A*w
Out[7]: True

In [9]: V, W = v.inv(), w.inv()

In [10]: A == V*D*W
Out[10]: True

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxRZ34TC5g%3DbtEPHG-axU1EvUeRY6zm0N-cvuSuWJzOASg%40mail.gmail.com.

Reply via email to