Re: [sage-support] The matrix function

64 views
Skip to first unread message

David Joyner

unread,
Oct 21, 2012, 3:40:52 PM10/21/12
to sage-s...@googlegroups.com
On Sun, Oct 21, 2012 at 3:32 PM, E. Mehmet Kıral <luz...@gmail.com> wrote:
> Hello,
>
> When I write matrix(2,2,1) or matrix(QQ,3,3,1) I do not get the identitiy matrix.

To get the 3x3 identity matrix, type

identity_matrix(3)

or

MatrixSpace(QQ, 3, 3)(1)

There are probably several other ways. Type

matrix?

for lots of examples.

>
> The only way the matrix function works is when I type
> matrix()
> and it gives me an empty matrix.
>
> Why is this so? Have I not installed some package correctly? Below is the error message that I get.
> sage: matrix(2)
> ---------------------------------------------------------------------------
> AttributeError Traceback (most recent call last)
>
> /home/eren/sage/<ipython console> in <module>()
>
> /home/eren/sage/local/lib/python2.7/site-packages/sage/matrix/constructor.pyc in matrix(*args, **kwds)
> 497 # check to see if the number of rows is specified
> 498 try:
> --> 499 import numpy
> 500 if isinstance(args[0], numpy.ndarray):
> 501 raise TypeError
>
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/__init__.py in <module>()
> 134 return loader(*packages, **options)
> 135
> --> 136 import add_newdocs
> 137 __all__ = ['add_newdocs']
> 138
>
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
> 7 # core/fromnumeric.py, core/defmatrix.py up-to-date.
> 8
> ----> 9 from numpy.lib import add_newdoc
> 10
> 11 ###############################################################################
>
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
> 11
> 12 import scimath as emath
> ---> 13 from polynomial import *
> 14 #import convertcode
> 15 from utils import *
>
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
> 9 import re
> 10 import warnings
> ---> 11 import numpy.core.numeric as NX
> 12
> 13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack
>
> AttributeError: 'module' object has no attribute 'core'
>
> Thank you again
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To post to this group, send email to sage-s...@googlegroups.com.
> To unsubscribe from this group, send email to sage-support...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
>
>

E. Mehmet Kıral

unread,
Oct 21, 2012, 4:24:33 PM10/21/12
to sage-s...@googlegroups.com
I understand that for the identity matrix there are other methods. But I do get the same error message for simply
matrix(2)
which according to the manual matrix?, should give me the 2by2 zero matrix. Or I get the same error when I try to construct a matrix out of vectors. This should not happen. I have my sage running in ubuntu 12.10 inside a virtual machine and I am using the version 5.3 of sage

Johan Grönqvist

unread,
Oct 21, 2012, 4:37:44 PM10/21/12
to sage-s...@googlegroups.com
2012-10-21 22:24, E. Mehmet Kıral skrev:
> I understand that for the identity matrix there are other methods. But I do get the same error message for simply
> matrix(2)
> which according to the manual matrix?, should give me the 2by2 zero matrix. Or I get the same error when I try to construct a matrix out of vectors. This should not happen. I have my sage running in ubuntu 12.10 inside a virtual machine and I am using the version 5.3 of sage
>

Size and empty list of entries:
sage: matrix(2, [])
[0 0]
[0 0]

#Rows and #columns:
sage: matrix(2, 2)
[0 0]
[0 0]
sage: matrix(2, 3)
[0 0 0]
[0 0 0]

#Rows and list of entries
sage: matrix(2, [1, 0, 2, 0, 1, 2])
[1 0 2]
[0 1 2]

#rows, #columns and list of entries
sage: matrix(2, 3, [1, 0, 2, 0, 1, 2])
[1 0 2]
[0 1 2]

#rows, #columns and a function to supply elements
sage: matrix(6, 4, lambda i, j: i+j)
[0 1 2 3]
[1 2 3 4]
[2 3 4 5]
[3 4 5 6]
[4 5 6 7]
[5 6 7 8]


Hope it helps,

johan

Martin Albrecht

unread,
Oct 21, 2012, 4:50:40 PM10/21/12
to sage-s...@googlegroups.com
Guys, the OP's installation is broken:

On Sunday 21 Oct 2012, E. Mehmet Kıral wrote:
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/lib/polynomial.py
> in <module>() 9 import re
> 10 import warnings
> ---> 11 import numpy.core.numeric as NX
> 12
> 13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack
>
> AttributeError: 'module' object has no attribute 'core'

This is not a "how do I use Sage" thread but a thread about repairing a broken
Sage installation.
Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://martinralbrecht.wordpress.com/
_jab: martinr...@jabber.ccc.de

E. Mehmet Kıral

unread,
Oct 21, 2012, 4:57:35 PM10/21/12
to sage-s...@googlegroups.com, martinr...@googlemail.com
Yes I tried those syntaxes but it doesn't work.

It seems to be a problem about importing numpy. When I try to import numpy just alone it gives me the same problem.

I do have numpy in my spkg.

I have tried to reload the whole sage, only to return worse results. Sage wouldn't even build.

Dima Pasechnik

unread,
Oct 22, 2012, 12:34:31 AM10/22/12
to sage-s...@googlegroups.com
On 2012-10-21, E Mehmet Kıral <luz...@gmail.com> wrote:
> Hello,
>
> When I write matrix(2,2,1) or matrix(QQ,3,3,1) I do not get the identitiy matrix.
>
> The only way the matrix function works is when I type
> matrix()
> and it gives me an empty matrix.
>
> Why is this so? Have I not installed some package correctly? Below is the error message that I get.


No, you don't need any extra packages to have this working in Sage.
It could be that you managed to break your Sage installation, though.
Did you install any opional/experimental Sage packages?
Did you install anything into Sage's Python tree, using easy_install or
something similar?
> /home/eren/sage/local/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
> 9 import re
> 10 import warnings
> ---> 11 import numpy.core.numeric as NX
> 12
> 13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack
>
> AttributeError: 'module' object has no attribute 'core'
>
> Thank you again
>

Dima Pasechnik

unread,
Oct 22, 2012, 12:37:10 AM10/22/12
to sage-s...@googlegroups.com
On 2012-10-21, E Mehmet Kıral <luz...@gmail.com> wrote:
What do you mean by "reload"? Rebuilding from source? If yes please
specify the version of Sage, and information about your system (OS
version, CPU, etc)


>

E. Mehmet Kıral

unread,
Oct 22, 2012, 12:56:55 AM10/22/12
to sage-s...@googlegroups.com
Hello.

I downloaded sage from the source again. I downloaded the latest version 5.3 and it downloaded without any problem.

However I still have a problem importing numpy, and thus using the matrix(2) function

I work inside a virtual machine and in there I run ubuntu 12.10. The ram allocated to this virtual machine is 2 GB.

Volker Braun

unread,
Oct 22, 2012, 6:16:34 AM10/22/12
to sage-s...@googlegroups.com
By building from source, we mean compiling Sage from source (takes quite some time). It seems like you downloaded a pre-compiled version of Sage. It seems like the pre-compiled version is incompatible with your distribution and CPU. Since we currently don't have a Ubuntu 12.10 binary, this kind of mismatch sounds quite likely.

You might want to try our pre-built virtual machine, see http://wiki.sagemath.org/SageAppliance
Reply all
Reply to author
Forward
0 new messages