aboutsummaryrefslogtreecommitdiffstats
path: root/R/tranche_functions.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/tranche_functions.R')
-rw-r--r--R/tranche_functions.R19
1 files changed, 19 insertions, 0 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 087f5d75..9ad62feb 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -241,6 +241,15 @@ lossdistC <- function(p, w, S, N, defaultflag=FALSE){
as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), q = double(N))$q
}
+lossdistCblas <- function(p, w, S, N, defaultflag=FALSE){
+ ## C version of lossdistrib2, roughly 50 times faster
+ if(!is.loaded("lossdistrib_blas")){
+ dyn.load(file.path(root.dir, "code", "R", paste0("lossdistrib", .Platform$dynlib.ext)))
+ }
+ .C("lossdistrib_blas", as.double(p), as.integer(length(p)),
+ as.double(w), as.double(S), as.integer(N), as.logical(defaultflag), q = double(N))$q
+}
+
lossdistCZ <- function(p, w, S, N, defaultflag=FALSE, rho, Z, wZ){
if(!is.loaded("lossdistrib_Z")){
dyn.load(file.path(root.dir, "code", "R", paste0("lossdistrib", .Platform$dynlib.ext)))
@@ -279,6 +288,16 @@ lossdistC.joint <- function(p, w, S, N, defaultflag=FALSE){
as.double(S), as.integer(N), as.logical(defaultflag), q = matrix(0, N, N))$q
}
+lossdistC.jointblas <- function(p, w, S, N, defaultflag=FALSE){
+ ## C version of lossdistrib.joint, roughly 20 times faster
+ if(!is.loaded("lossdistrib_joint_blas")){
+ dyn.load(file.path(root.dir, "code", "R", paste0("lossdistrib", .Platform$dynlib.ext)))
+ }
+ .C("lossdistrib_joint_blas", as.double(p), as.integer(length(p)), as.double(w),
+ as.double(S), as.integer(N), as.logical(defaultflag), q = matrix(0, N, N))$q
+}
+
+
lossdistC.jointZ <- function(dp, w, S, N, defaultflag = FALSE, rho, Z, wZ){
## N is the size of the grid
## dp is of size n.credits