Re: Compile ReplacePart
- To: mathgroup at smc.vnet.net
- Subject: [mg52597] Re: Compile ReplacePart
- From: Joerg Schaber <schaber at molgen.mpg.de>
- Date: Fri, 3 Dec 2004 03:54:23 -0500 (EST)
- References: <comh1m$9ht$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Yehuda, here I constructed you a code that shows that it works in principle but not in a compiled fucntion. Maybe you have an idea, best, joerg <<Statistics`ContinuousDistributions` x={-0.9,0.98,0.97,-0.96,1.1,1.1,1.2,1.03,-1.3,2.9,2.9,-0.89,0.90}; lu={{0,0,0,0,0,0,0,0,0,0,0,0,0},{1,1,1,1,1,1,1,1,1,100,100,100,1}}; CheckXBounds=Compile[{{x,_Real,1},{lb,_Real,1},{ub,_Real,1}}, p=Position[Thread[lb<=x<=ub]/.{True\[Rule]1,False\[Rule]0},0], {{p,_Integer,2}}]; In[56]:= CheckXBounds[x,lu[[1]],lu[[2]]] Out[56]= {{1},{4},{5},{6},{7},{8},{9},{12}} (* CheckXBounds works *) p=CheckXBounds[x,lu[[1]],lu[[2]]]; new=x+RandomArray[NormalDistribution[0,1],Length[x]] x2=ReplacePart[x,new,p,p] (* The above also works but the same code in a compiled function gives we the mentioned error *) CheckParameters=Compile[{{x,_Real,1},{lb,_Real, 1},{ub,_Real,1}},Module[{x2,p,new}, p=CheckXBounds[x,lb,ub]; new=x+RandomArray[NormalDistribution[0,1],Length[x]]; x2=ReplacePart[x2,new,p,p]; Return[x2] ] ]; yehuda ben-shimol wrote: > It is difficult to comment to your posting without an exact reference to the > line (or block of code) that caused the problem. Can you send it so we will > be able to figure out what is wrong? > yehuda > > -----Original Message----- > From: Joerg Schaber [mailto:schaber at molgen.mpg.de] To: mathgroup at smc.vnet.net > Subject: [mg52597] Compile ReplacePart > > Hi, > > using ReplacePart with 4 arguments in a Compiled Function gives me the > error 'ReplacePart::argrx: ReplacePart called with 4 arguments; 3 > arguments are expected', even though ReplacePart is defined also for 4 > arguments in regular Mathematica code. > What's the problem here? > > best, > > joerg > >