Sha256: 73fcd8151513417584e7a624748f8e724550cb4cb92586514ca41a5c028b0731
Contents?: true
Size: 776 Bytes
Versions: 6
Compression:
Stored size: 776 Bytes
Contents
#ifndef KMEANS_COMPUTE_WCSS_HPP #define KMEANS_COMPUTE_WCSS_HPP #include <vector> namespace kmeans { template<typename DATA_t = double, typename INDEX_t = int, typename CLUSTER_t = int> std::vector<DATA_t> compute_wcss(int ndim, INDEX_t nobs, const DATA_t* data, CLUSTER_t ncenters, const DATA_t* centers, const CLUSTER_t* clusters) { std::vector<DATA_t> wcss(ncenters); for (INDEX_t obs = 0; obs < nobs; ++obs) { auto cen = clusters[obs]; auto curcenter = centers + cen * ndim; auto& curwcss = wcss[cen]; auto curdata = data + obs * ndim; for (int dim = 0; dim < ndim; ++dim, ++curcenter, ++curdata) { curwcss += (*curdata - *curcenter) * (*curdata - *curcenter); } } return wcss; } } #endif
Version data entries
6 entries across 6 versions & 1 rubygems