R/fun.hcvxitr1.R

Defines functions fun.hcvxitr1

Documented in fun.hcvxitr1

fun.hcvxitr1 <-
function(bc,Data,Parameters)
########################################################
#fun.hcvxitr1(bc,Data,Parameters)
#######################################################
# version 0.1
# May 19, 2012
# Junlong Sun
# return [po,s]
#######################################################
# May 19, 2012 - v0.1 Create
#######################################################
{
#-----------------------------------------------------------------#
## loading data
#-----------------------------------------------------------------#
	#jh <- Parameters$jh
    jh <- 0.01
    ep <- .001
    maxIteration3 <- 100

	 m <- 5
    	 b <- bc %*% matrix(1,nrow = 1, ncol = m) + matrix(c(0,0,jh,0,-jh,-0,0,jh,-0,-jh),nrow = 2, ncol = m)        

	data10 <- fun.oldp2(b,m,Data)
	s <- data10$s
	ru <- data10$ru 
	u <- data10$u

	h <- t(cbind((u[,2]-u[,3])/jh/2,(u[,4]-u[,5])/jh/2))
      h[1,2] <- h[1,2]/2 + h[2,1]/2
      h[2,1] <- h[1,2]

    cr <- 0

#-----------------------------------------------------------------#
    while  (((det(h) > ep) * (h[1,1] >0) * (h[2,2]>0)<1) & (cr<maxIteration3)) {
        ep <- 2*ep
        cr <- cr + 1
        h <- h + ep * matrix(diag(rep(1,2)),nrow=2,ncol=2)
    }
#-----------------------------------------------------------------#

    po <- -solve(h) %*% u[,1]

#-----------------------------------------------------------------#
## Output Resuts 
#-----------------------------------------------------------------#
    output<- list(po=po,s=s)
    return(output)
#-----------------------------------------------------------------#

}

Try the YPmodel package in your browser

Any scripts or data that you put into this service are public.

YPmodel documentation built on Oct. 23, 2020, 5:15 p.m.