MathGroup Archive 1999

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

Search the Archive

CompiledFunction for matrices ??

  • To: mathgroup at
  • Subject: [mg16069] CompiledFunction for matrices ??
  • From: "Ersek, Ted R" <ErsekTR at>
  • Date: Tue, 23 Feb 1999 03:45:22 -0500
  • Sender: owner-wri-mathgroup at

While writing some code to answer a question Peter Klamser sent in I found
myself wanting to write a CompiledFunction that takes a length (n) vector of
real numbers.
The best solution I could find is to explicitly write out (n) variables as
foo=Compile[{x1,x2,x3, ... , xn}, expr]

Then I can evaluate something like:
Apply[foo, {6.2,4.1,2.5,8.6,7.7,9.1,2.2,1.4}]

If I want to write a CompiledFunction that takes an (m) by (n) matrix of
real numbers it's also a real chore by any method I know of.

The documentation says:
Compile[{{x1, t1, n1}, ... }, expr] assumes that xi is a 
rank ni array of objects each of a type which matches ti.

I used to think this allowed the sort of thing I am looking for, but  I
didn't think about it long enough.  It seems
Compile[{{m,_Real,n}}, expr]   (for n>2) takes a tensor.


So how can we write a CompiledFunction that takes a large vector or large

Ted Ersek

  • Prev by Date: On Integrator Output
  • Next by Date: Bug using Options[]
  • Previous by thread: Re: On Integrator Output
  • Next by thread: Re: CompiledFunction for matrices ??