简体   繁体   中英

How to rearrange vector to be cols not rows?

I am solving systems of equations using Armadillo . I make a matrix from one array of doubles, specifying the rows and columns. The problem is that it doesn't read it the way I make the array, (it's a vector but then converted to an array) so I need to manipulate the vector.

To be clear, it takes a vector with these values:

2 0 0 0 2 1 1 1 0 1 1 0 3 0 0 1 1 1 1 0 0 1 0 1 2

And it makes this matrix: 2 1 1 1 0 0 1 0 1 1 0 1 3 1 0 0 0 0 1 1 2 1 0 0 2

But I want this matrix: 2 0 0 0 2 1 1 1 0 1 1 0 3 0 0 1 1 1 1 0 0 1 0 1 2

How do I manipulate my vector to make it like this?

I feel as if you are looking for a transposition of a matrix . There is relevant documentation here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM