MathGroup Archive 1998

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

Search the Archive

Re: Convert expr from CForm to InputFrom

  • To: mathgroup at
  • 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: <72jdhk$>
  • Sender: owner-wri-mathgroup at

In article <72jdhk$39r at>, Anton Antonov 
<anton at> 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[1]= dj[3]*conc[2] + ( dj[13] + rc[10]*conc[2] )*conc[9] |> 
|> 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

P.J. Hinton	
Mathematica Programming Group		paulh at Wolfram Research,
Inc. Disclaimer: Opinions expressed
herein are those of the author alone.

  • Prev by Date: Re: Levy Distribution
  • Next by Date: Re: Simple MathLink question
  • Previous by thread: Convert expr from CForm to InputFrom
  • Next by thread: Mathematica vs MacOS 8.5