From 1e68be6f6ed2e424222d9e584e58f7fe36f7decb Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Fri, 16 Feb 2018 11:24:43 -0500 Subject: fix compilation when not using blas --- src/lossdistrib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/lossdistrib.c') diff --git a/src/lossdistrib.c b/src/lossdistrib.c index 494fed7..27b4a28 100644 --- a/src/lossdistrib.c +++ b/src/lossdistrib.c @@ -4,7 +4,9 @@ #include #include "lossdistrib.h" +#ifdef USE_BLAS #include +#endif #ifdef BUILD_TESTS #include @@ -131,7 +133,14 @@ void exp_trunc(const double *p, const int *np, const double *w, const double *S, lossdistrib(p, np, w, S, N, &T, &flag, qtemp); double* val = malloc(T * sizeof(double)); posK(T, *K, lu, val); + #if USE_BLAS *r = cblas_ddot(T, val, 1, qtemp, 1); + #else + r = 0; + for(int i=0; i < T; i++) { + *r += val[i] * qtemp[i]; + } + #endif free(qtemp); } @@ -292,14 +301,27 @@ void joint_default_averagerecov_distrib(const double *p,const int *np, index[n] = (unsigned int) temp; } if(j < i+1) { + #if USE_BLAS cblas_dscal(*N, 1-p[i], q+(*N)*j, 1); + #else + double* temp = q + (*N) * j; + for( int k = 0; k < *N; k++) { + temp[k] *= 1 - p[i]; + } + #endif } for(int k = 0; k < *N; k++) { q[j*(*N)+index[k]+1] += weights[k] * p[i] * q[(j-1)*(*N)+k]; q[j*(*N)+index[k]] += (1-weights[k]) * p[i] * q[(j-1)*(*N)+k]; } } + #if USE_BLAS cblas_dscal(*N, 1-p[i], q, 1); + #else + for(int k = 0; k < *N; k++) { + q[k] *= 1 - p[i]; + } + #endif } free(newrecov); free(index); -- cgit v1.2.3-70-g09d2