Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Compile for different parameter types

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97403] Re: Compile for different parameter types
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 12 Mar 2009 05:42:15 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <gpacur$mu6$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

one of the reasons why CompiledFunction[]s are faster, is
that the types are fixed and the pattern matcher has not to search
what rule should be used. So you must make a function

f[a_?MatrixQ,b_?MatrixQ]:=CompiledFMatrixMatrix[a,b]
f[a_?VectorQ,b_?MatrixQ]:=CompiledFVectorMatrix[a,b]
f[a_?VectorQ,b_?VectorQ]:=CompiledFVectorVector[a,b]
..

Regards
   Jens

Sebastian Meznaric wrote:
> Say I want to have a compiled function that works for tensors of rank
> 2 or 3. Let's call this function f. Then
> 
> f = Compile[{{A,_Real,2},{B,_Real,2}}, expr]
> 
> would make function f for tensor of rank 2. Is it possible to expand
> this function to work for both tensors of rank 2 and 3? Eventually I
> would like to obtain a compiled function that works for a wide (but
> limited) range of combinations of tensor ranks. All tensor ranks are
> less than 15 so we are talking about at most 15^2=225 combinations.
> 


  • Prev by Date: Re: How to get data from Histogram
  • Next by Date: Re: General form of a summation as a function of 2 variables
  • Previous by thread: Re: Compile for different parameter types
  • Next by thread: Re: Compile for different parameter types