This forum has been archived. All content is frozen. Please use KDE Discuss instead.

"Flatten" matrix to vector

Tags: None
(comma "," separated)
fbeyer
Registered Member
Posts
8
Karma
0

"Flatten" matrix to vector

Wed Jan 16, 2013 9:34 am
Is there as "smart" built-in way to flatten a NxM matrix to a N*M vector by concatenating columns/rows, and vice versa?

For example:
Code: Select all
     3x5                         15x1
[ A D G J M ]
[ B E H K N ]  <==> [ A B C D E F G H I J K L M N O ]
[ C F I L O ]


For dense contiguous matrices, I could simply use a Map to re-interpret the underlying array, but this is very verbose. Am I missing something?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: "Flatten" matrix to vector

Thu Jan 17, 2013 9:37 pm
Nothing better than Map yet. To make it less verbose, you can easily write a small wrapper function for your purpose.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]