Have you looked into numpy module? It is not specific to Sage, but it
should work. Also, the indexing is a little bit friendlier.

sage: import numpy
sage: C = numpy.array([[[[1, 2], [3, 4]], [[3, 4], [5, 6]]], [[[7, 8], [9,
10]], [[-1, -2], [-3, -4]]]])
sage: C
array([[[[ 1,  2],
         [ 3,  4]],

        [[ 3,  4],
         [ 5,  6]]],


       [[[ 7,  8],
         [ 9, 10]],

        [[-1, -2],
         [-3, -4]]]])
sage: C[0]
array([[[1, 2],
        [3, 4]],

       [[3, 4],
        [5, 6]]])
sage: C[0,1]
array([[3, 4],
       [5, 6]])
sage: C[0,1,1]
array([5, 6])
sage: C[0,1,1,0]
5



On Sun, May 19, 2013 at 11:49 PM, P Purkayastha <ppu...@gmail.com> wrote:

> On 05/20/2013 01:52 PM, Santanu Sarkar wrote:
>
>> Is the any way to write four dimensional array in Sage like C
>> int M[10][10][10][10]?  For two dimensional case I use Matrix.
>>
>
> How do you intend to use it? You can simply create a nested list.
>
> sage: C = [[[[1,2], [3]], [[3], [4]]], [[[1,2],[3]],[[3],[4]]]]
> sage: C[0][1][1][0]
> 4
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> sage-support+unsubscribe@**googlegroups.com<sage-support%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/sage-support?hl=en<http://groups.google.com/group/sage-support?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to