Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: C-formatted strings back to Expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70007] Re: C-formatted strings back to Expressions
  • From: dimmechan at yahoo.com
  • Date: Sat, 30 Sep 2006 05:12:34 -0400 (EDT)
  • References: <efdkii$v7$1@smc.vnet.net><efga7d$pn3$1@smc.vnet.net>

As Daniel <dh at metrohm.ch>  pointed me out I was totally wrong.
I must admit I did not know that. Here comes his message which
mention my mistake.
I apologise for the situation.

---------------------------------------------------------------------------------------------------
Hi,
you are fooling yourself. CForm does not alter the expression at all,
it
is only a wrapper that  affects printing. You can convince yourself by
changing the output to a string: ToSTring[CForm[expression]]. Then try
to read this back. Now the original expression is no longer available.

Daniel
-------------------------------------------------------------------------------------------------------

Regards
Dimitris


Î?/Î? dimmechan at yahoo.com έγÏ?αÏ?ε:
> Hello.
>
> It is very easily to convert one form to another.
>
> CForm[Expand[(x+Sqrt[y])^2]]
> Power(x,2) + 2*x*Sqrt(y) + y
>
> InputForm[%]
> x^2 + 2*x*Sqrt[y] + y
>
> StandardForm[%]
> \!\(x\^2 + 2\ x\ \@y + y\)
>
> CForm[Expand[(x+Sqrt[y])^2]]
> Power(x,2) + 2*x*Sqrt(y) + y
>
> FortranForm[%]
> x**2 + 2*x*Sqrt(y) + y
>
> StandardForm[%]
> \!\(x\^2 + 2\ x\ \@y + y\)
>
> TeXForm[Sqrt[x^2+y^2]]
> \sqrt{x^2+y^2}
>
> MathMLForm[%]
> <math>
>  <msqrt>
>   <mrow>
>    <msup>
>     <mi>x</mi>
>     <mn>2</mn>
>    </msup>
>    <mo>+</mo>
>    <msup>
>     <mi>y</mi>
>     <mn>2</mn>
>    </msup>
>   </mrow>
>  </msqrt>
> </math>
>
> OutputForm[%]
>       2    2
> Sqrt[x  + y ]
>
> As another example consider
>
> str=FromCharacterCode[Table[Random[Integer,{90,120}],{20},{2}]]
> {x],rm,]q,_i,v`,to,jm,pq,mh,jx,Zi,a],]n,gm,r^,ci,`w,qf,kg,e[}
>
> CForm[str]
> List("x]","rm","]q","_i","v`","to","jm","pq","mh","jx","Zi","a]","]n","gm","r^","ci","`w","qf","kg","e[")
>
> InputForm[%]
> {"x]", "rm", "]q", "_i", "v`", "to", "jm", "pq", "mh", "jx", "Zi",
> "a]", "]n", "gm", "r^", "ci", "`w", "qf", "kg", "e["}


  • Prev by Date: Re: Re: mapping of function
  • Next by Date: Re: Re: Performance comparison Mac OSX vs. Windows XP
  • Previous by thread: Re: C-formatted strings back to Expressions
  • Next by thread: mapping of function