419 views
0 votes
0 votes

I am not getting the problem which is given below. Please help

Matrix transposition must be a familiar task. This problem is a generalization of it.  We can assume matrix transposition as a permutation of the two dimensions of the matrix. Suppose the matrix dimensions are 16 x 8, the permutation for transpose is "1 0" where "1" means the first dimension of output comes from the 2nd (starting from 0) dimension of input and "0" means the second dimension of output comes from the first dimension of input. The only other permutation possible here is "0 1" which gives output same as input. For a 3D array, we can have 3!= 6 possible permutations possible. Now we can generalize this problem. Given any higher dimensional array -- called a tensor -- and a given permutation, we should produce the output tensor. Input must be read from a file and should be of the following form:

5   15 14 13 12 11       4 3 2 1 0

where the first entry denotes the number of dimensions followed by as many dimension values (lowest most or fastest varying dimension first) followed by the required permutation - explanation given in the previous paragraph.

The program template and input files are attached. Answer verification is done by doing a reverse transposition and then comparing the original tensor with the final one. All these codes are included and you only need to write the transposition algorithm. (Hint: Code required is not more than 50 lines)

Please submit the final code only.

Hint: Given an array index values we can linearize them and get to the memory location. Now, for each tensor element, try to do the reverse and get the dimension values of the input tensor and then again linearize and get the location in the output tensor.

file1

transpose

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
0 votes
0 votes
1 answer
3
sidjha57 asked Jan 18, 2022
465 views
Why am I not able to access the course content that is to enroll in the courses on go classroom?It says that it has been ended on 21st July is there any other way to acce...
0 votes
0 votes
0 answers
4
sakharam asked Oct 17, 2018
236 views
What is Squareroot(L) and Square(L)?