kmeans
A C++ library for k-means
Loading...
Searching...
No Matches
MockMatrix.hpp
Go to the documentation of this file.
1#ifndef KMEANS_MOCK_MATRIX_HPP
2#define KMEANS_MOCK_MATRIX_HPP
3
9namespace kmeans {
10
18public:
22 MockMatrix(int num_dim, int num_obs, const double* data) : my_num_dim(num_dim), my_num_obs(num_obs), my_data(data), my_long_num_dim(num_dim) {}
27public:
33 typedef double data_type;
34
39 typedef int index_type;
40
45 typedef int dimension_type;
46
47private:
48 dimension_type my_num_dim;
49 index_type my_num_obs;
50 const data_type* my_data;
51 size_t my_long_num_dim;
52
53public:
58 return my_num_obs;
59 }
60
65 return my_num_dim;
66 }
67
68public:
75
82
98
107
118 const index_type* sequence;
119 size_t at = 0;
123 };
124
134
135public:
142 return my_data + static_cast<size_t>(i) * my_long_num_dim; // avoid overflow during multiplication.
143 }
144
150 return my_data + (workspace.at++) * my_long_num_dim; // everything is already a size_t.
151 }
152
158 return my_data + static_cast<size_t>(workspace.sequence[workspace.at++]) * my_long_num_dim; // avoid overflow during multiplication.
159 }
160};
161
162}
163
164#endif
Implements the variance partitioning method of Su and Dy (2007).
Definition InitializeVariancePartition.hpp:164
Compile-time interface for matrix data.
Definition MockMatrix.hpp:17
double data_type
Definition MockMatrix.hpp:33
int index_type
Definition MockMatrix.hpp:39
IndexedAccessWorkspace create_workspace(const index_type *sequence, index_type length) const
Definition MockMatrix.hpp:131
const data_type * get_observation(ConsecutiveAccessWorkspace &workspace) const
Definition MockMatrix.hpp:149
ConsecutiveAccessWorkspace create_workspace(index_type start, index_type length) const
Definition MockMatrix.hpp:104
index_type num_observations() const
Definition MockMatrix.hpp:57
const data_type * get_observation(int i, RandomAccessWorkspace &workspace) const
Definition MockMatrix.hpp:141
const data_type * get_observation(IndexedAccessWorkspace &workspace) const
Definition MockMatrix.hpp:157
int dimension_type
Definition MockMatrix.hpp:45
RandomAccessWorkspace create_workspace() const
Definition MockMatrix.hpp:79
dimension_type num_dimensions() const
Definition MockMatrix.hpp:64
Namespace for k-means clustering.
Definition compute_wcss.hpp:12
Workspace for access to consecutive observations.
Definition MockMatrix.hpp:88
Workspace for access to a indexed subset of observations.
Definition MockMatrix.hpp:113
Workspace for random access to observations.
Definition MockMatrix.hpp:74