You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Such a formatting option is lacking at the moment. A simple way to do
it, given that you don't need high precision, is to use the standard
float formatting mechanism:
>>> a = randmatrix(3,3)/10
>>> for x in a: print "%0.4f" % x
...
0.0069
0.0423
0.0615
0.0302
0.0290
0.0041
0.0934
0.0538
0.0654
You'll need to adapt this code to print the matrix elements line by
line and aligned, but this shouldn't be hard. Let me know if you need
further help.
archeryguru2000
unread,
Aug 18, 2009, 2:55:43 PM8/18/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Oh no! Don't say that! You've made me cry. :( I should probably
mention that my matrix is a minimum of 12x12. And more generally this
12x12 would only be one-fourth (a quadrant) of the entire solution.
This would yield 144 elements to cycle through, potentially 576
elements... minimum! I'm assuming this could be some serious
computing time? However, this is still better than nothing.
I'm thinking I will try to write a script to actually set the
precision/accuracy within a matrix. I'll do some debugging, and see
what I can come up with. I may have to find a way to 'fix' this size
of the the numbers before they enter the matrix. Any suggestions?
And thank you VERY much for your reply. An unwanted answer is much
better than no answer. ;-)
~~archery~~
Message has been deleted
Fredrik Johansson
unread,
Aug 18, 2009, 3:02:52 PM8/18/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Hmm, looks like Google Groups ate my code. It should be 'for x in a:
print "%0.4f" % x'.
It will take no time at all to cycle through even several thousand
elements with this :-) E.g. a 24x24 matrix takes 0.004 seconds on my
computer.
archeryguru2000
unread,
Aug 18, 2009, 3:17:39 PM8/18/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Uh oh! I've made a boo-boo
for L in Loo:
print '%.4f' % L
[code]
Traceback (most recent call last):
File "./L-matrix", line 113, in <module>
print '%.4f' % L
TypeError: float argument required, not numpy.ndarray
[/code]
So I tried to force a float with
for L in Loo:
print '%.4f' % float(L)
But then received this error
[code]
TypeError: only length-1 arrays can be converted to Python scalars
[/code]
Any suggestions?
~~archery~~
Fredrik Johansson
unread,
Aug 18, 2009, 3:23:41 PM8/18/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
If A is a numpy matrix then the easiest way to iterate over it may be
something like:
for row in range(3):
... for col in range(3):
... print '%.4f' % A[row,col]
Vinzent Steinberg
unread,
Aug 19, 2009, 10:47:32 AM8/19/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
This is trivial to fix, see my patch [1], however there is a problem,
so I could not yet commit it.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Thank you very much Vinzent. Now for the easy question... how do I
add this patch? For other patches (that were contained in a file) I
would run something like:
$: patch --backup-if-mismatch </name/of/folder/containing-patch-
files>
I'm assuming it should be something similar, say:
$ patch --backup-if-mismatch /path/to/nstr-pass-args.patch
Or am I totally wrong on this? Thanks again for your assistance.
~~archery~~
Vinzent Steinberg
unread,
Aug 20, 2009, 8:08:13 AM8/20/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
For me
$ patch -p0 < nstr-pass-args.patch
works. (I'm also not familiar with this tool :).
Vinzent
archeryguru2000
unread,
Aug 20, 2009, 11:20:28 AM8/20/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpmath
Thank you very much. The patch worked great. Now if could just get
you to write my thesis for me as well. ;-)