Reading in data from file in certain format
I have a multivalued function (created in some other software Mathematica) that looks like f[8.7,5.4]=4.8+8.7*I. In other words it's a complex valued function of two variables. I store the output of this function over a range of parameters in a text file that looks like:
Code:
f[1,2]=9.8+8.7I;
f[4,5]=5.6-5.21I;
.
.
I could store it differently if that is easier, but essentially I just want some c++ code to read this in and store it, either in a vector type structure or Dictionary? (I don't think a double array will work as I don't know how long list of data is in advance).
Could anyone help toward this? thanks
Re: Reading in data from file in certain format
I never ever recommend writing your own file format, put it in text format and use XML, JSON, YAML, INI... These formats exist for a reason :)
Re: Reading in data from file in certain format
XML is fine with me, could you give me some pointers on how to do this? should the input file look like say
Code:
<param1>8</param1> <param2>9</param2> <value>2.5+8.9*I </value>
<param1>56</param1> <param2>5.6</param2> <value>5.6+4.9*I </value>
then if this is correct how do I read this in, and what would be the best object to store the data in?