diff options
| -rw-r--r-- | R/lossdistrib.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/R/lossdistrib.c b/R/lossdistrib.c index 36be7be3..ecf16abf 100644 --- a/R/lossdistrib.c +++ b/R/lossdistrib.c @@ -718,10 +718,10 @@ void BClossdist(double *defaultprob, int *dim1, int *dim2, computes the loss and recovery distribution over time with a flat gaussian
correlation
inputs:
- Survprob: matrix of size dim1 x dim2. dim1 is the number of issuers
+ defaultprob: matrix of size dim1 x dim2. dim1 is the number of issuers
and dim2 number of time steps
- recov: vector of recoveries (length dim1)
issuerweights: vector of issuer weights (length dim2)
+ recov: vector of recoveries (length dim1)
Z: vector of factor values (length n)
w: vector of factor weights (length n)
rho: correlation beta
@@ -745,6 +745,8 @@ void BClossdist(double *defaultprob, int *dim1, int *dim2, Rw = malloc((*N) * (*n) * sizeof(double));
for(t=0; t < (*dim2); t++) {
+ memset(Lw, 0, (*N) * (*n) * sizeof(double));
+ memset(Rw, 0, (*N) * (*n) * sizeof(double));
for(i=0; i < *n; i++){
for(j=0; j < (*dim1); j++){
g = defaultprob[j + (*dim1) * t];
@@ -752,13 +754,13 @@ void BClossdist(double *defaultprob, int *dim1, int *dim2, Sshocked[j] = shockseverity(1-recov[j], Z[i], *rho, g);
Rshocked[j] = 1 - Sshocked[j];
}
- lossdistrib_blas(gshocked, dim1, issuerweights, Sshocked, N, defaultflag,
- Lw + i * (*N));
- lossdistrib_blas(gshocked, dim1, issuerweights, Rshocked, N, defaultflag,
- Rw + i * (*N));
+ lossdistrib(gshocked, dim1, issuerweights, Sshocked, N, defaultflag,
+ Lw + i * (*N));
+ lossdistrib(gshocked, dim1, issuerweights, Rshocked, N, defaultflag,
+ Rw + i * (*N));
}
dgemv_("n", N, n, &alpha, Lw, N, w, &one, &beta, L + t * (*N), &one);
- dgemv_("n", N, n, &alpha, Rw, N, w, &one, &beta, L + t * (*N), &one);
+ dgemv_("n", N, n, &alpha, Rw, N, w, &one, &beta, R + t * (*N), &one);
}
Free(gshocked);
Free(Rshocked);
|
