23 #ifndef HELPERS_INL_HH 24 #define HELPERS_INL_HH 34 #include <blitz/array.h> 53 const blitz::Array<T, 2>& profiles,
54 const std::vector< ptrdiff_t >& labels,
55 const std::set< ptrdiff_t >& selected_clusters) {
60 typedef list<blitz::Array<float, 1> > ClusterList;
64 map<const ptrdiff_t, ClusterList > profiles_by_cluster;
66 for (ptrdiff_t row = 0; row < profiles.extent(0); ++row) {
67 ptrdiff_t label = labels[row];
69 if (selected_clusters.find(label) != selected_clusters.end()) {
70 ClusterList &cluster_list = profiles_by_cluster[label];
72 cluster_list.push_back(profile);
77 std::vector<blitz::Array<T, 2> > selected_profiles(selected_clusters.size());
78 ptrdiff_t num_samples = profiles.extent(1);
80 for(std::set<ptrdiff_t>::const_iterator it = selected_clusters.begin();
81 it != selected_clusters.end(); ++it, ++i){
82 ptrdiff_t label = *it;
83 ClusterList &cluster_list = profiles_by_cluster[label];
84 blitz::Array<float, 2> &cluster_profiles = selected_profiles[i];
85 cluster_profiles.resize(cluster_list.size(), num_samples);
87 for (ClusterList::const_iterator it = cluster_list.begin();
88 it != cluster_list.end(); ++it, ++row) {
92 return selected_profiles;
std::vector< blitz::Array< T, 2 > > collectSelectedClusterProfiles(const blitz::Array< T, 2 > &profiles, const std::vector< ptrdiff_t > &labels, const std::set< ptrdiff_t > &selected_clusters)
Builds a vector of blitz Arrays (profiles) for selected clusters each element of the vector correspon...
bool all(blitz::TinyMatrix< bool, NRows, NColumns > const &matrix)
all() reduction for boolean blitz::TinyMatrix.