4

When I input a value of N, a N-dimensional matrix is generated automatically. I want to index automatically the N-dimensional matrix based on the value of N.

For example, if the dimension of the matrix A is 3:

temp = A[a + 1, a + 2, a + 3]

If it is 4:

temp = A[a + 1, a + 2, a + 3, a + 4]

Because my entire code generates many matrices with various dimenstions through the value of N, I seek ways that meet my needs.

Thanks.

1
  • You mean square matrices ? Commented Feb 16, 2013 at 16:47

1 Answer 1

3

Simply build a tuple containing the required index, and use that tuple to index into temp.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.