The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Topic: Compiled functions
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Stefan Schulz

Posts: 1
Registered: 12/7/04
Compiled functions
Posted: Aug 7, 1996 4:05 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Mathematica users,

is it possible to compile a mathematica expression that uses
vectors of real numbers as input? Since in my application I need
to solve a symmetric tridiagonal linear system which is diagonally
dominate quite often I am thinking about defining
a compiled function that could look something like

SymmTridiagonalSolve = Compile[{{a, _List}, {b, _List}, {r, _List}},
Module[{ n = Length[r],
solution = Array[0, Length[r]],
aux1 = Array[0, Length[r]],
a1 = Prepend[a, 0],
aux = 1/b[[1]];
solution[[1]] = r[[1]] aux;
aux1[[i]] = a1[[i]] aux,
aux = 1/(b[[i]]-a1[[i]] aux1[[i]]),
solution[[i]] = (r[[i]]-a1[[i]] solution[[i-1]]) aux
{i, 2, n}];
solution[[i]] -= aux1[[i+1]] solution[[i+1]]
{i, n-1, 1, -1}];

Since according to the Mathematica book, the only types that can be
specified for compilation are _Integer, _Real, _Complex, and True | False
I know that this construct does not work, but
has somebody perhaps come up with a clever workaround
to make it possible to also pass vectors as arguments?

Many thanks in advance.



=-=-=-=-this message is transmitted on 100 % recycled electrons-=-=-=-=
| | |
| | Stefan Schulz |
| Tel. ++49/30/838 5384 | FU Berlin - Theoretical Chemistry |
| ++49/30/838 2351 | Takustrasse 3 |
| FAX. ++49/30/838 4792 | D-14195 Berlin |

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.