MathGroup Archive 1999

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

Search the Archive

Re: CompiledFunction for matrices ??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16115] Re: [mg16069] CompiledFunction for matrices ??
  • From: David Withoff <withoff>
  • Date: Thu, 25 Feb 1999 08:25:05 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

> 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
> in:
> 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
> matrix?
> 
> Thanks,
> Ted Ersek

Are you confusing rank with length?

Compile[{{x, _Real, 1}}, ...] takes any vector (large or small) of real
numbers as an argument, and Compile[{{x, _Real, 2}}, ...] takes an argument
that is a matrix of real numbers.

Dave Withoff
Wolfram Research


  • Prev by Date: Re: Q: Union and SameTest Option
  • Next by Date: RE: Re: Win 98 Printing Problems
  • Previous by thread: CompiledFunction for matrices ??
  • Next by thread: Re: CompiledFunction for matrices ??