MathGroup Archive 2005

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

Search the Archive

Re: How can I get a nonscalar logical variable into a compiled function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56278] Re: How can I get a nonscalar logical variable into a compiled function?
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 20 Apr 2005 05:33:05 -0400 (EDT)
  • References: <d3t3o2$8og$1@smc.vnet.net> <d42kdb$398$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi All,
the trouble seems to be that only numerical arrays are allowed inside a 
compiled function.
The Mathematica book, chapter 2.6.15 gives a hint:

Compile nevertheless also allows integers, complex numbers and logical 
variables (True or False), as well as arrays of numbers.

Sincerely, Daniel

dh wrote:
> Hi Ben,
> as arrays of boolean may not be fed to a compile function, you could 
> simply represent True/False by 0/1 for the Input/Output of your 
> function. Inside the functio, you may either choose to convert to 
> True/False or you can proceed with 0/1, whatever suits you better.
> Sincerely, Daniel
> 
> barrowes at alum.mit.edu wrote:
> 
>>I can't seem to figure out how to get a nonscalar logical variable into
>>a compiled function.
>>
>>I can get a nonscalar variable of other kinds into compiled function or
>>a scalar True or False into a compiled function.
>>
>>For example the following two things work:
>>
>>fun1=Compile[{{x,_Real,2}}
>>Print[x];
>>];
>>
>>fun2=Compile[{{x,True|False}}
>>Print[x];
>>];
>>
>>but how can I specify a two-dimensional input variable into the second
>>case?
>>fun2=Compile[{{x,True|False,1}}
>>Print[x];
>>];
>>doesn't work. It returns:
>>gg = {False, True, True, True, True, True, True}
>>fun2[gg]
>>CompiledFunction::cfsa: Argument {False, True, True, True, True, True,
>>True} \
>>at position 1 should be a True or False.
>>
>>Can only scalar logical variables be input into compiled functions? Am
>>I missing something?
>>
>>Thanks,
>>Ben
>>
> 
> 


  • Prev by Date: Re: holding boxes verbatim
  • Next by Date: Guide to get tex-stuff working in Suse 9.2
  • Previous by thread: Re: How can I get a nonscalar logical variable into a compiled function?
  • Next by thread: Re: Trouble with Limit[I ... k]/k, k-> Infinity]