MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Importing complex numbers into mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37495] Re: [mg37464] Importing complex numbers into mathematica
  • From: Liguo Song <Liguo.Song at vanderbilt.edu>
  • Date: Fri, 1 Nov 2002 01:44:00 -0500 (EST)
  • References: <200210310941.EAA18338@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, Mike,

Using Export["Test.dat", {3 + 2 I, 1 + 0.5 I}, "Expression"] will get you the 
file with the following content:

{3 + 2*I, 1 + 0.5*I}

Then, use Import["Test.dat","Expression"] will get {3+2 I, 1+0.5 I}. So, try to 
make your program out in this format and then import as Expression.

Hope it helps.


Liguo



mike wrote:
> Hi
> 
> This may be a stupid question but is there an easy way to import
> complex numbers from a file into mathematica.  I have written some c++
> code that outputs a set of complex numbers to a file and I have been
> trying to get them into mathematica.  What format should I use?
> 
> To give myself a clue I exported a couple of complex numbers from
> Mathematica to see what the file would look like:
> 
> Export["test.dat", {3 + 2 I, 1 + 0.5 I}, "List"];
> 
> which gives me the following test.dat:
> 3 + 2 I
> 1 + 0.5 I
> 
> so far so good - looks like thats the format I need my c++ code to
> output but when i try
> 
> test = Import["test.dat", "List"];
> i get the following output
> test = {3, "+", 2, "I", 1, "+", 0.5, "I"}
> 
> Can anyone help me?  I want to be able to Import the file directly - I
> would rather not simply import a big list of numbers and write a
> function that makes the relavent ones complex.  Any help would be much
> appreciated
> 
> Mike




  • Prev by Date: Re: OO in Mathematica
  • Next by Date: Re: Importing complex numbers into mathematica
  • Previous by thread: Re: Importing complex numbers into mathematica
  • Next by thread: Re: Importing complex numbers into mathematica