Re: Convert expr from CForm to InputFrom
- To: mathgroup at smc.vnet.net
- Subject: [mg14796] Re: Convert expr from CForm to InputFrom
- From: paulh (P.J. Hinton)
- Date: Wed, 18 Nov 1998 01:28:57 -0500
- Organization: Wolfram Research, Inc.
- References: <firstname.lastname@example.org>
- Sender: owner-wri-mathgroup at wolfram.com
In article <72jdhk$39r at smc.vnet.net>, Anton Antonov <anton at unidhp1.uni-c.dk> writes: |> Do you know how I can convert expression in CForm to expression in |> InputFrom. |> I can do of course the opposite CForm[expr]. For example I want the C |> expression ( f, dj, conc, rc are arrays): |> |> f(1)= dj(3)*conc(2) + ( dj(13) + rc(10)*conc(2) )*conc(9) |> |> to have |> |> f= dj*conc + ( dj + rc*conc )*conc |> |> Now I am using some perl program for this convertion. Mathematica does not support this form of backward translation. The only Mathematica format types for which one could possibly guarantee complete conversion in both ways are FullForm InputForm StandardForm Other format types, like TraditionalForm, TeXForm, and CForm, are intended to be for one way-only print forms. I don't know of any existing converters for backparsing like this. What is your motivation for doing this form of translation? If it is because you have a large amount of existing C functions that you would like to call from Mathematica, perhaps you should consider adding function templates to your C source code and recompiling the source code with linkage against the MathLink library for your platform. This will allow you to "Install" the executable so that your C functions are callable with Mathematica level functions. See _The Mathematica Book_ (Third Edition), Section 2.12.3 ff for more information. -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc. http://www.wolfram.com/~paulh/ Disclaimer: Opinions expressed herein are those of the author alone.