Tag Info

Hot answers tagged

22

OK, here's a quick go using Experimental`OptimizeExpression, which is used internally by Compile. I'm not claiming that this is a polished solution to your problem, but hopefully it can be used as a place to start. (Also, forgive any Fortran mistakes, I haven't looked at Fortran for a long time...) xx = x /. Solve[{x^2 + y^2 + z^2 == 1, x + y + z == a, ...


16

Here are three very simple examples to show how to call a Fortran subroutine using LibraryLink. First the subroutine is compiled into object file. Then a wrapper is used to call the Fortran subroutine and compiled into dynamic library. At the end, the library is loaded into Mathematica and run. In the examples Mathematica Version 8 is used. FIRST EXAMPLE ...


6

For simplicity and elegance I use Verbeia's nice Riffle-ing for continuation. While it is possible to format real numbers as requested in FortranForm I always thought that this is way too complicated in Mathematica (the code below is slightly modified from my old FeynCalc-Write2 function described here myFortrantoggle=False; (* needed to avoid recursion *) ...


6

You can get a long way to your goal using FortranForm in Mathematica and some replacement rules. ToExpression and ToString are very useful for this kind of application. (I'm giving this one a name for later use below.) step1 = FortranForm[(-48*Sqrt[6]* E^((-2*S[1, x]^2)/bx - (S[1, y]^2)/bx - (S[1, z]^2)/ bz - (S[2, x]^2)/bx - (S[2, y]^2)/bx - (S[2, ...


4

Mathematicas invocation of the compiler doesn't know about where to find the Fortran library. With a little help, however, we can point the way. Mind you this was done on a Mac but the Linux variant of Unix will behave similar. Needs["CCompilerDriver`"]; CreateLibrary[{"MMA.cc", "fadd.o"}, "myadd", "Debug" -> True, "TargetDirectory" -> ".", ...



Only top voted, non community-wiki answers of a minimum length are eligible