From ab75289ea2856b37e15e98b7fd70860f9723696f Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Mon, 25 Aug 2014 13:35:53 -0400 Subject: small cleanups --- R/tranche_functions.R | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/R/tranche_functions.R b/R/tranche_functions.R index ca8f98c..9592bd5 100644 --- a/R/tranche_functions.R +++ b/R/tranche_functions.R @@ -296,25 +296,27 @@ lossdistC.jointZ <- function(dp, w, S, N, defaultflag = FALSE, rho, Z, wZ){ as.double(Z), as.double(wZ), as.integer(length(Z)), q = matrix(0, N, N))$q } -lossdistC.prepay.joint <- function(dp, pp, w, S, N, defaultflag=FALSE){ +lossdistC.prepay.jointblas <- function(dp, pp, w, S, N, defaultflag=FALSE){ ## C version of lossdist.prepay.joint - r <- .C("lossdistrib_prepay_joint", as.double(dp), as.double(pp), as.integer(length(dp)), + r <- .C("lossdistrib_prepay_joint_blas", as.double(dp), as.double(pp), as.integer(length(dp)), as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), q=matrix(0, N, N))$q return(r) } lossdistC.prepay.jointZ <- function(dp, pp, w, S, N, defaultflag = FALSE, rho, Z, wZ){ - ## N is the size of the grid - ## dp is of size n.credits - ## pp is of size n.credits - ## w is of size n.credits - ## S is of size n.credits by nZ - ## rho is a double - ## Z is a vector of length nZ - ## w is a vector if length wZ + ## N is the size of the grid + ## dp is of size n.credits + ## pp is of size n.credits + ## w is of size n.credits + ## S is of size n.credits by nZ + ## rho is a vector of doubles of size n.credits + ## Z is a vector of length nZ + ## w is a vector if length wZ + r <- .C("lossdistrib_prepay_joint_Z", as.double(dp), as.double(pp), as.integer(length(dp)), as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), as.double(rho), - as.double(Z), as.double(wZ), as.integer(length(Z)), q = matrix(0, N, N))$q + as.double(Z), as.double(wZ), as.integer(length(Z)), output = matrix(0,N,N)) + return(r$output) } lossrecovdist <- function(defaultprob, prepayprob, w, S, N, defaultflag=FALSE, useC=TRUE){ @@ -1030,13 +1032,11 @@ MFlossdist.prepay.joint <- function(w, Z, rho, defaultprob, defaultprobmod, defaultprob[i,t], defaultprobmod[i,t]) } } - Q <- array(0, dim=c(ncol(defaultprob), Ngrid, Ngrid)) for(t in 1:ncol(defaultprob)){ - S <- 1 - Rstoch[,,t] - Q[t,,] <- lossdistC.prepay.jointZ(defaultprobmod[,t], prepayprobmod[,t], issuerweights, - S, Ngrid, defaultflag, rho, Z, w) - } + S <- 1 - Rstoch[,,t] + Q[t,,] <- lossdistC.prepay.jointZ(defaultprobmod[,t], prepayprobmod[,t], issuerweights) + } return( Q ) } -- cgit v1.2.3-70-g09d2