| 464 | |

| 465 | def smith_form(self): |

| 466 | r""" |

| 467 | Returns matrices S, U, and V such that S = U\*self\*V, and S is in |

| 468 | Smith normal form. Thus S is diagonal with diagonal entries the |

| 469 | ordered elementary divisors of S. |

| 470 | |

| 471 | This version is for sparse matrices and simply makes the matrix |

| 472 | dense and calls the version for dense integer matrices. |

| 473 | |

| 474 | .. warning:: |

| 475 | |

| 476 | The elementary_divisors function, which returns the |

| 477 | diagonal entries of S, is VASTLY faster than this function. |

| 478 | |

| 479 | The elementary divisors are the invariants of the finite abelian |

| 480 | group that is the cokernel of this matrix. They are ordered in |

| 481 | reverse by divisibility. |

| 482 | |

| 483 | EXAMPLES:: |

| 484 | |

| 485 | sage: A = MatrixSpace(IntegerRing(), 3, sparse=True)(range(9)) |

| 486 | sage: D, U, V = A.smith_form() |

| 487 | sage: D |

| 488 | [1 0 0] |

| 489 | [0 3 0] |

| 490 | [0 0 0] |

| 491 | sage: U |

| 492 | [ 0 1 0] |

| 493 | [ 0 -1 1] |

| 494 | [-1 2 -1] |

| 495 | sage: V |

| 496 | [-1 4 1] |

| 497 | [ 1 -3 -2] |

| 498 | [ 0 0 1] |

| 499 | sage: U*A*V |

| 500 | [1 0 0] |

| 501 | [0 3 0] |

| 502 | [0 0 0] |

| 503 | |

| 504 | It also makes sense for nonsquare matrices:: |

| 505 | |

| 506 | sage: A = Matrix(ZZ,3,2,range(6), sparse=True) |

| 507 | sage: D, U, V = A.smith_form() |

| 508 | sage: D |

| 509 | [1 0] |

| 510 | [0 2] |

| 511 | [0 0] |

| 512 | sage: U |

| 513 | [ 0 1 0] |

| 514 | [ 0 -1 1] |

| 515 | [-1 2 -1] |

| 516 | sage: V |

| 517 | [-1 3] |

| 518 | [ 1 -2] |

| 519 | sage: U * A * V |

| 520 | [1 0] |

| 521 | [0 2] |

| 522 | [0 0] |

| 523 | |

| 524 | The examples above show that Trac ticket #10626 has been implemented. |

| 525 | |

| 526 | |

| 527 | .. seealso:: |

| 528 | |

| 529 | :meth:`elementary_divisors` |

| 530 | """ |

| 531 | return self.dense_matrix().smith_form() |

| 532 | * No newline at end of file* |