770 | def zeros(ctx, *args, **kwargs): |
771 | """ |
772 | Create matrix m x n filled with zeros. |
773 | One given dimension will create square matrix n x n. |
774 | |
775 | Example: |
776 | >>> from mpmath import zeros, mp |
777 | >>> mp.pretty = False |
778 | >>> zeros(2) |
779 | matrix( |
780 | [['0.0', '0.0'], |
781 | ['0.0', '0.0']]) |
782 | """ |
783 | if len(args) == 1: |
784 | m = n = args[0] |
785 | elif len(args) == 2: |
786 | m = args[0] |
787 | n = args[1] |
788 | else: |
789 | raise TypeError('zeros expected at most 2 arguments, got %i' % len(args)) |
790 | A = ctx.matrix(m, n, **kwargs) |
791 | for i in xrange(m): |
792 | for j in xrange(n): |
793 | A[i,j] = 0 |
794 | return A |