diff options
| author | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2014-08-25 13:35:53 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@serenitascapital.com> | 2014-08-25 13:35:53 -0400 |
| commit | ab75289ea2856b37e15e98b7fd70860f9723696f (patch) | |
| tree | 590be219e10e766bf9a6a0a4a5e8d1e2ad7d88a2 /R | |
| parent | adf5f229e7858c6b9967c57fe978bb823dc53c14 (diff) | |
| download | lossdistrib-ab75289ea2856b37e15e98b7fd70860f9723696f.tar.gz | |
small cleanups
Diffstat (limited to 'R')
| -rw-r--r-- | R/tranche_functions.R | 32 |
1 files 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 )
}
|
