Skip to content
Prev 85647 / 398502 Next

Matrix variable in C code

Selon Gabor Csardi <csardi at rmki.kfki.hu>:
Sorry, i make a mistake writing the small code, the correct one is the following
with the correct dim for ZT

========================================
X<-c(4,2,3,2)
Z<-c(40,21,30,20)
dX<-c(2,1,1)

dyn.load("test.so")

Phi<-function(z,a,b)
{
	Phi<-z
}

VPEfron<-function(XType,ZType,dXType,G,c0,c1)
{
	####################
	ZT<-matrix(0,3,2)
	ZT[1,1]<-Z[2]
	ZT[1,2]<-Z[4]
	ZT[2,1]<-Z[3]
	ZT[3,1]<-Z[1]
	####################

	# A OPTIMISER
      VPCEfron<-function(f,XT,ZT,dXT,tailleS=length(XT))
      {
		f.check<-function(x) {
            x<-f(x)
            }
     
.Call("VPCEfron",body(f.check),as.double(XT),as.double(ZT),as.integer(dXT),as.integer(tailleS),new.env())
	}
GG<-function(z) G(z,c0,c1)

Vraisemblancepartielle<-VPCEfron(GG,XType,ZType,dXType)
}

resultat<-VPEfron(X,Z,dX,Phi,0,0)
==========================================

The new piece of code is between ###.


Thanks,

Alex