Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*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 1996

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

Search the Archive

Compiled functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4594] Compiled functions
  • From: Stefan Schulz <sschulz at chemie.fu-berlin.de>
  • Date: Wed, 21 Aug 1996 03:25:16 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

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]],
             aux,
             a1       = Prepend[a, 0],
             i
           },
        aux = 1/b[[1]];
        solution[[1]] = r[[1]] aux;
        Do[{
            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}];
        Do[{
            solution[[i]] -= aux1[[i+1]] solution[[i+1]]
           },
        {i, n-1, 1, -1}];
        solution
        ]
       ]

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.


Regards,



Stefan



=-=-=-=-this message is transmitted on 100 % recycled electrons-=-=-=-=
|                              |                                      |
| sschulz at chemie.fu-berlin.de  |            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             |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Matching random numbers
  • Next by Date: List of x,y pairs to use with ListPlot
  • Previous by thread: Re: Matching random numbers
  • Next by thread: Re: Compiled functions