Skip to content

Commit

Permalink
Replace uint with unsigned int
Browse files Browse the repository at this point in the history
- Replace `uint` typedef with explicit unsigned int
  since `uint` is not universal (older GCC on Windows)
  • Loading branch information
michaelweylandt committed Apr 13, 2020
1 parent 80a00fd commit f032cb9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/biclustering_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class ConvexBiClustering {
Rcpp::Named("gamma_path") = gamma_path);
}

void tick(uint iter){
void tick(unsigned int iter){
sp.update(nzeros_row + nzeros_col,
V_row.squaredNorm() + V_col.squaredNorm(),
iter,
Expand Down
2 changes: 1 addition & 1 deletion src/clustering_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ConvexClustering {
Rcpp::Named("gamma_path") = gamma_path);
}

void tick(uint iter){
void tick(unsigned int iter){
sp.update(nzeros, V.squaredNorm(), iter, gamma);
}

Expand Down
10 changes: 5 additions & 5 deletions src/get_cluster_assignments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Rcpp::List get_cluster_assignments_impl(const Eigen::MatrixXi& E,
std::set<int> all_vertices_seen;

// Iterate over all possible edges - this big loop is a no-op where edge_ind == 0
for(uint i = 0; i < edge_ind.size(); i++){
for(unsigned int i = 0; i < edge_ind.size(); i++){

if(edge_ind(i) != 0){ // If the edge is present
int edge_begin = E(i, 0);
Expand All @@ -21,7 +21,7 @@ Rcpp::List get_cluster_assignments_impl(const Eigen::MatrixXi& E,
// We begin by looking for the first vertex (here called "begin") in each component
bool found_component_begin = false;

for(uint j = 0; j < components.size(); j++){
for(unsigned int j = 0; j < components.size(); j++){
std::set<int>& component_j = components[j];

if(contains(component_j, edge_begin)){
Expand All @@ -38,7 +38,7 @@ Rcpp::List get_cluster_assignments_impl(const Eigen::MatrixXi& E,
}

// Now check other components
for(uint k = 0; k < components.size(); k++){
for(unsigned int k = 0; k < components.size(); k++){
if(k != j){ // We handled k == j above

std::set<int>& component_k = components[k];
Expand Down Expand Up @@ -75,7 +75,7 @@ Rcpp::List get_cluster_assignments_impl(const Eigen::MatrixXi& E,
// If it is, then we add edge_begin to the same component
bool found_component_end_inner = false;

for(uint j = 0; j < components.size(); j++){
for(unsigned int j = 0; j < components.size(); j++){
std::set<int>& component_j = components[j];
if(contains(component_j, edge_end)){
// We didn't find edge_begin, but we do have edge_end, so let's add
Expand Down Expand Up @@ -127,7 +127,7 @@ Rcpp::List get_cluster_assignments_impl(const Eigen::MatrixXi& E,
// Assign labels - loop over components and then elements within components
// Requires irregular access to component_indicators, but it's O(1) (=O(n) total) instead
// of searching through all the sets repeatedly
for(uint i = 0; i < components.size(); i++){
for(unsigned int i = 0; i < components.size(); i++){
std::set<int>& component_i = components[i];
component_sizes[i] = component_i.size();

Expand Down
20 changes: 10 additions & 10 deletions src/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class StatusPrinter {

public:
StatusPrinter(bool show_progress,
uint total_fusions,
unsigned int total_fusions,
std::string format = "",
int width = Rf_GetOptionWidth() - 2) :

Expand Down Expand Up @@ -60,7 +60,7 @@ class StatusPrinter {
this->v_norm_init = v_norm_init;
}

void update(int fusions_, double v_norm_, uint iter_, double gamma_) {
void update(int fusions_, double v_norm_, unsigned int iter_, double gamma_) {
double time_since_last_tick = (std::clock() - last_tick) / ((double) CLOCKS_PER_SEC);

if(time_since_last_tick < CLUSTRVIZ_STATUS_UPDATE_TIME_SECS){
Expand All @@ -70,7 +70,7 @@ class StatusPrinter {
force_update(fusions_, v_norm_, iter_, gamma_);
}

void force_update(int fusions_, double v_norm_, uint iter_, double gamma_){
void force_update(int fusions_, double v_norm_, unsigned int iter_, double gamma_){
Rcpp::checkUserInterrupt(); // Check essentially every time we do the progress bar

if(!show_progress){
Expand Down Expand Up @@ -99,20 +99,20 @@ class StatusPrinter {

private:
const bool show_progress; // Do we print output?
uint count; // Number of times we have updated the printer
unsigned int count; // Number of times we have updated the printer
const bool output_supported; // Do we support the desired print location?
std::string format; // Bar template -- hard coded above
int width; // Width of progress bar (used to set template and control print length)
std::string last_draw; // Last progress bar drawn
std::clock_t last_tick; // Time of last PB tick

// ClustRviz-specific measures of progress
const uint total_fusions; // Number of edges that need to be fused before termination
uint fusions; // Number of edges fused so far
double v_norm_init; // Initial squared Frobenius norm of V
double v_norm; // Current squared Frobenius norm of V
uint iter; // What iteration we are on
double gamma; // Current regularization level
const unsigned int total_fusions; // Number of edges that need to be fused before termination
unsigned int fusions; // Number of edges fused so far
double v_norm_init; // Initial squared Frobenius norm of V
double v_norm; // Current squared Frobenius norm of V
unsigned int iter; // What iteration we are on
double gamma; // Current regularization level

void update_format(){
if(this->width >= 120){
Expand Down
8 changes: 4 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ Rcpp::NumericVector smooth_u_clustering(Rcpp::NumericVector U_old, Rcpp::List cl

for(Eigen::Index q = 0; q < Q; q++){
Rcpp::List cluster_info = cluster_info_list[q];
uint n_clusters = Rcpp::as<uint>(cluster_info[2]);
unsigned int n_clusters = Rcpp::as<unsigned int>(cluster_info[2]);

Rcpp::IntegerVector cluster_ids = cluster_info[0];
Rcpp::IntegerVector cluster_sizes = cluster_info[1];

Eigen::MatrixXd U_old_slice = Eigen::Map<Eigen::MatrixXd>(&U_old[N * P * q], N, P);
Eigen::MatrixXd U_new(N, P);

for(uint j = 1; j <= n_clusters; j++){ // Cluster IDs are 1-based (per R conventions)
for(unsigned int j = 1; j <= n_clusters; j++){ // Cluster IDs are 1-based (per R conventions)
Eigen::VectorXd vec = Eigen::VectorXd::Zero(P);

// Manually work out new mean
for(uint n = 0; n < N; n++){
for(unsigned int n = 0; n < N; n++){
if(cluster_ids[n] == j){
vec += U_old_slice.row(n);
}
Expand All @@ -141,7 +141,7 @@ Rcpp::NumericVector smooth_u_clustering(Rcpp::NumericVector U_old, Rcpp::List cl
vec /= cluster_sizes[j - 1]; // Subtract 1 to adjust to C++ indexing

// Assign new mean where needed...
for(uint n = 0; n < N; n++){
for(unsigned int n = 0; n < N; n++){
if(cluster_ids[n] == j){
U_new.row(n) = vec;
}
Expand Down

0 comments on commit f032cb9

Please sign in to comment.