Smith Form Decomposition

178 views
Skip to first unread message

Florent Bulkilol

unread,
Aug 15, 2024, 11:51:31 AM8/15/24
to sympy
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.

thanks!

Chris Smith

unread,
Aug 16, 2024, 10:38:52 AM8/16/24
to sympy
As far as I can tell, these matrices are not computed implicitly. You would have to copy the appropriate actions onto an augmented identity matrix to see what has happened (https://www.youtube.com/watch?v=UhyzLfiO4Ow).

/c

Oscar Benjamin

unread,
Aug 16, 2024, 10:44:45 AM8/16/24
to sy...@googlegroups.com
It would be good to have this in SymPy but unfortunately it is not
implemented yet.

It is also not available in python-flint or Flint either.
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/7d884ae9-5b11-4e9e-a4ef-1e4f918410a4n%40googlegroups.com.

Sangyub Lee

unread,
Aug 16, 2024, 4:07:41 PM8/16/24
to sympy
You can check Add full option to smith_normal_form by isuruf · Pull Request #17451 · sympy/sympy (github.com).
Although the PR is based on outdated branch, you may have easier time following the algorithms based on that

Chris Smith

unread,
Aug 17, 2024, 1:46:27 PM8/17/24
to sympy
I left a modified version in the comment here,  Add full option to smith_normal_form by isuruf · Pull Request #17451 · sympy/sympy (github.com) , that will compute the decomposition.

Oscar Benjamin

unread,
Oct 17, 2024, 12:53:55 PM10/17/24
to sy...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages