Hi,

On Sat, Jan 16, 2010 at 9:38 PM, Kakaz <kazimierz.k...@gmail.com> wrote:
>  I would like to ask: how to create in Sage table of numbers with
> three indexes, something like C[i,j,k]?

Sage is based on Python, so creating multidimensional tables in Sage
is similar to how you would do it in Python. You can do it using lists
of lists:

sage: A = [1..5]
sage: B = [i**2 for i in A]
sage: C = [i**3 for i in A]
sage: L1 = [A, B, C]
sage: L2 = [B, C, A]
sage: L3 = [C, A, B]
sage: T = [L1, L2, L3]
sage: T[0]
[[1, 2, 3, 4, 5], [1, 4, 9, 16, 25], [1, 8, 27, 64, 125]]
sage: T[0][0]
[1, 2, 3, 4, 5]
sage: T[0][0][0]
1


Or you can use NumPy:

sage: import numpy
sage: T = numpy.array([L1, L2, L3])
sage: T[0]
array([[  1,   2,   3,   4,   5],
       [  1,   4,   9,  16,  25],
       [  1,   8,  27,  64, 125]])
sage: T[0, 0]
array([1, 2, 3, 4, 5])
sage: T[0, 0, 0]
1

-- 
Regards
Minh Van Nguyen
-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to