Mercurial > hg > qm-dsp
changeset 269:a63c7b6191b5
* Add direct support for ATLAS version of CLAPACK
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 13 Feb 2008 12:49:47 +0000 |
parents | 9aedf5ea8c35 |
children | 54e09b1962db |
files | dsp/segmentation/ClusterMeltSegmenter.cpp hmm/hmm.c qm-dsp.pro |
diffstat | 3 files changed, 30 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/dsp/segmentation/ClusterMeltSegmenter.cpp Thu Feb 07 10:01:38 2008 +0000 +++ b/dsp/segmentation/ClusterMeltSegmenter.cpp Wed Feb 13 12:49:47 2008 +0000 @@ -112,13 +112,13 @@ int ClusterMeltSegmenter::getWindowsize() { - return static_cast<int>(windowSize * samplerate); + return static_cast<int>(windowSize * samplerate + 0.001); } int ClusterMeltSegmenter::getHopsize() { - return static_cast<int>(hopSize * samplerate); + return static_cast<int>(hopSize * samplerate + 0.001); } void ClusterMeltSegmenter::extractFeatures(const double* samples, int nsamples)
--- a/hmm/hmm.c Thu Feb 07 10:01:38 2008 +0000 +++ b/hmm/hmm.c Wed Feb 13 12:49:47 2008 +0000 @@ -12,7 +12,21 @@ #include <stdlib.h> #include <float.h> #include <time.h> /* to seed random number generator */ + #include <clapack.h> /* LAPACK for matrix inversion */ + +#ifdef ATLAS_ORDER +#define HAVE_ATLAS 1 +#endif + +#ifdef HAVE_ATLAS +// Using ATLAS C interface to LAPACK +#define dgetrf_(m, n, a, lda, ipiv, info) \ + clapack_dgetrf(CblasColMajor, *m, *n, a, *lda, ipiv) +#define dgetri_(n, a, lda, ipiv, work, lwork, info) \ + clapack_dgetri(CblasColMajor, *n, a, *lda, ipiv) +#endif + #ifdef _MAC_OS_X #include <vecLib/cblas.h> #else @@ -671,9 +685,9 @@ for (i=0; i < L; i++) a[j*L+i] = cov[i][j]; - long M = (long) L; - long* ipiv = (long*) malloc(L*L*sizeof(int)); - long ret; + int M = (int) L; + int* ipiv = (int *) malloc(L*L*sizeof(int)); + int ret; /* LU decomposition */ ret = dgetrf_(&M, &M, a, &M, ipiv, &ret); /* ret should be zero, negative if cov is singular */ @@ -700,20 +714,24 @@ *detcov = det; /* allocate required working storage */ - long lwork = -1; - double lwbest; +#ifndef HAVE_ATLAS + int lwork = -1; + double lwbest = 0.0; dgetri_(&M, a, &M, ipiv, &lwbest, &lwork, &ret); - lwork = (long) lwbest; + lwork = (int) lwbest; double* work = (double*) malloc(lwork*sizeof(double)); +#endif /* find inverse */ dgetri_(&M, a, &M, ipiv, work, &lwork, &ret); - + for(j=0; j < L; j++) for (i=0; i < L; i++) icov[i][j] = a[j*L+i]; +#ifndef HAVE_ATLAS free(work); +#endif free(a); }