[vlfeat] 13/44: vl_fisher.c: fix no data point case
Dima Kogan
dima at secretsauce.net
Wed Sep 16 21:05:28 UTC 2015
This is an automated email from the git hooks/post-receive script.
dkogan-guest pushed a commit to branch master
in repository vlfeat.
commit c0abc039acf179c66ac5d59ad26add48277c0147
Author: Andrea Vedaldi <vedaldi at gmail.com>
Date: Sat Oct 4 14:13:06 2014 +0100
vl_fisher.c: fix no data point case
---
toolbox/fisher/vl_fisher.c | 2 +-
vl/fisher.c | 37 +++++++++++++++++++------------------
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/toolbox/fisher/vl_fisher.c b/toolbox/fisher/vl_fisher.c
index c8768a5..d5233c0 100644
--- a/toolbox/fisher/vl_fisher.c
+++ b/toolbox/fisher/vl_fisher.c
@@ -159,7 +159,7 @@ mexFunction (int nout VL_UNUSED, mxArray * out[], int nin, const mxArray * in[])
if (verbosity) {
mexPrintf("vl_fisher: sparsity of assignments: %.2f%% (%d non-negligible assignments)\n",
- 100.0 * (1.0 - (double)numTerms/((double)numData*(double)numClusters)),
+ 100.0 * (1.0 - (double)numTerms/((double)numData*(double)numClusters+1e-12)),
numTerms) ;
}
}
diff --git a/vl/fisher.c b/vl/fisher.c
index 83c1724..7307b21 100644
--- a/vl/fisher.c
+++ b/vl/fisher.c
@@ -438,12 +438,13 @@ VL_XCAT(_vl_fisher_encode_, SFX)
}
}
- uprefix = 1/(numData*sqrt(priors[i_cl]));
- vprefix = 1/(numData*sqrt(2*priors[i_cl]));
-
- for(dim = 0; dim < dimension; dim++) {
- *(uk + dim) = *(uk + dim) * uprefix;
- *(vk + dim) = *(vk + dim) * vprefix;
+ if (numData > 0) {
+ uprefix = 1/(numData*sqrt(priors[i_cl]));
+ vprefix = 1/(numData*sqrt(2*priors[i_cl]));
+ for(dim = 0; dim < dimension; dim++) {
+ *(uk + dim) = *(uk + dim) * uprefix;
+ *(vk + dim) = *(vk + dim) * vprefix;
+ }
}
}
@@ -513,24 +514,24 @@ VL_XCAT(_vl_fisher_encode_, SFX)
** @param flags options.
** @return number of averaging operations.
**
- ** @a means and @a covariances have @a dimension rows and @a numCluster columns.
- ** @a priors is a vector of size @a numCluster. @a data has @a dimension
- ** rows and @a numData columns. @a enc is a vecotr of size equal
- ** to twice the product of @a dimension and @a numClusters.
- ** All these vectors and matrices have the same class, as specified
- ** by @a dataType.
+ ** @a means and @a covariances have @a dimension rows and @a
+ ** numCluster columns. @a priors is a vector of size @a
+ ** numCluster. @a data has @a dimension rows and @a numData
+ ** columns. @a enc is a vecotr of size equal to twice the product of
+ ** @a dimension and @a numClusters. All these vectors and matrices
+ ** have the same class, as specified by @a dataType, and must be
+ ** stored in column-major format.
**
** @a flag can be used to control several options:
** ::VL_FISHER_FLAG_SQUARE_ROOT, ::VL_FISHER_FLAG_NORMALIZED,
** ::VL_FISHER_FLAG_IMPROVED, and ::VL_FISHER_FLAG_FAST.
**
** The function returns the number of averaging operations actually
- ** computed. The upper bound is the number of input features by the
- ** number of GMM modes; however, in practice assignments are usually
- ** failry sparse, so this number is less. In particular, with the
- ** ::VL_FISHER_FLAG_FAST, this number should be equal to the number
- ** of input features only. This information can be used for
- ** diagnostic purposes.
+ ** performed. The upper bound is the number of input features by the
+ ** number of GMM modes; however, assignments are usually failry
+ ** sparse, so this number is often much smaller. In particular, with
+ ** the ::VL_FISHER_FLAG_FAST, is equal to the number of input
+ ** features. This information can be used for diagnostic purposes.
**
** @sa @ref fisher
**/
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/vlfeat.git
More information about the debian-science-commits
mailing list