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

Creating a matrix from data file

Tags: None
(comma "," separated)
omabbasi
Registered Member
Posts
3
Karma
0
OS

Creating a matrix from data file

Sat Feb 19, 2011 6:32 am
Hi everyone,

I am new to Eigen and would like to know if its possible that Eigen assign values from a data file directly to a matrix.

I mean something like the following suppose I have the following text file.

1 2 2.3 8
2 3.2 4 1.2

Is there way to assign these values to:
MatrixXd x

Regards,
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
No, you have to implement this yourself. The main reason is that there is no clear standard format to store matrices, so we prefer to let users do their own cooking here.
omabbasi
Registered Member
Posts
3
Karma
0
OS
Alright, thanks.
mattd
Registered Member
Posts
28
Karma
0
ggael wrote:No, you have to implement this yourself. The main reason is that there is no clear standard format to store matrices, so we prefer to let users do their own cooking here.


Perhaps CSV support would be possible in the future?

It's standardized (RFC 4180) and seems to be _the_ lowest-common-denominator data-exchange format supported by a very wide range of software, from spreadsheets (e.g. Gnumeric, Microsoft Excel, Open Office), through scientific computing software (e.g. Mathematica, MATLAB, GNU Octave, Scilab), to a variety of statistical packages (E-Views, Ox, OxMetrics, R, SAS, STATA, ...).

Ideally, overloading the operator<< so that in addition to current functionality it accepts a csv-file as a right-operand would fit with the way Eigen does things -- and "comma-initialization" description would still fit perfectly!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ok, thank you for the suggestion. Seeing the amount of software supporting this format it might indeed make sense to have it in Eigen. I'm adding an entry on our bugzilla to not forget about it. Patch welcome ;)
omabbasi
Registered Member
Posts
3
Karma
0
OS
That will be great :)
mattd
Registered Member
Posts
28
Karma
0
Great! :-)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora