Closed achbogga closed 6 years ago
Hello,
Not sure to understand your issue nor the behavior you expect from transpose. Here is a small example of transpose
with its output, everything works as expected:
xarray<int> a = { {1, 2, 3}, {4, 5, 6} };
auto b = transpose(a);
std::cout << "shape: (" << a.shape()[0] << ", " << a.shape()[1] << ")" << std::endl;
std::cout << a << std::endl;
std::cout << "shape: (" << b.shape()[0] << ", " << b.shape()[1] << ")" << std::endl;
std::cout << b << std::endl;
The output is:
shape: (2, 3)
{{1, 2, 3},
{4, 5, 6}}
shape: (3, 2)
{{1, 4},
{2, 5},
{3, 6}}
The dimension after the stack is not what you are expecting -- it's 3D.
Thanks, my bad. @wolfv and @JohanMabille .
No problem!
For the future, examples with really minimal amount of code are much preferred!
Cheers,
Wolf
Hello @wolfv, The transpose changes the shape altogether instead of just interchanging dimensions. However, after explicitly reshaping the output of the transpose, it produces the correct shape. Please find the code below to reproduce.