Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.06 KB | None | 0 0
  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index f9ba042..74a1e6f 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -4,9 +4,13 @@ project(klasters)
  6.  
  7.  set(CMAKE_BUILD_TYPE Debug)
  8.  set(CMAKE_CXX_STANDART 11)
  9. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
  10. -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
  11. +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -std=c++11")
  12.  
  13. -file(GLOB CPPS "*.cpp")
  14. +file(GLOB CPPS "${PROJECT_SOURCE_DIR}/klasters/*.cpp")
  15. +include_directories(${PROJECT_SOURCE_DIR}/klasters)
  16.  
  17. -add_executable(${PROJECT_NAME} ${CPPS})
  18. \ No newline at end of file
  19. +add_executable(${PROJECT_NAME} ${CPPS})
  20. +
  21. +if (UNIX)
  22. +    target_link_libraries(${PROJECT_NAME} pthread)
  23. +endif (UNIX)
  24. diff --git a/klasters/Cluster.cpp b/klasters/Cluster.cpp
  25. index e38e540..9d45170 100644
  26. --- a/klasters/Cluster.cpp
  27. +++ b/klasters/Cluster.cpp
  28. @@ -1,6 +1,6 @@
  29.  /* Copyright 2020 Igor Lyamin */
  30.  
  31. -#include "cluster.h"
  32. +#include "Cluster.h"
  33.  
  34.  cluster::cluster() {
  35.    n_ = 0;
  36. diff --git a/klasters/functions.cpp b/klasters/functions.cpp
  37. index 6c674b2..5d3056d 100644
  38. --- a/klasters/functions.cpp
  39. +++ b/klasters/functions.cpp
  40. @@ -1,14 +1,10 @@
  41.  /* Copyright 2020 Igor Lyamin */
  42.  
  43.  #include "functions.h"
  44. +#include <thread>
  45.  
  46.  int getCountOfThreads() {
  47. -  SYSTEM_INFO sysinfo;
  48. -  GetSystemInfo(&sysinfo);
  49. -  int numCPU = sysinfo.dwNumberOfProcessors;
  50. -  numCPU = std::thread::hardware_concurrency() == 0 ?
  51. -      numCPU : std::thread::hardware_concurrency();
  52. -  return numCPU - 1;
  53. +    return std::thread::hardware_concurrency() - 1;
  54.  }
  55.  
  56.  int getDistance(const point& X, const point& Y) {
  57. diff --git a/klasters/functions.h b/klasters/functions.h
  58. index 7e2b0cf..f8451f4 100644
  59. --- a/klasters/functions.h
  60. +++ b/klasters/functions.h
  61. @@ -3,7 +3,6 @@
  62.  #pragma once
  63.  
  64.  /* global */
  65. -#include <windows.h>
  66.  #include <thread>
  67.  #include <mutex>
  68.  
  69. diff --git a/klasters/kmeans.cpp b/klasters/kmeans.cpp
  70. index b3ac156..7944c04 100644
  71. --- a/klasters/kmeans.cpp
  72. +++ b/klasters/kmeans.cpp
  73. @@ -1,8 +1,6 @@
  74.  /* Copyright 2020 Igor Lyamin */
  75.  
  76.  /* global */
  77. -#include <stdio.h>
  78. -#include <windows.h>
  79.  #include <iostream>
  80.  #include <list>
  81.  #include <vector>
  82. @@ -16,7 +14,7 @@
  83.  
  84.  /* local */
  85.  #include "point.h"
  86. -#include "cluster.h"
  87. +#include "Cluster.h"
  88.  #include "functions.h"
  89.  
  90.  int main() {
  91. diff --git a/klasters/point.cpp b/klasters/point.cpp
  92. index 67a85a4..9218d1e 100644
  93. --- a/klasters/point.cpp
  94. +++ b/klasters/point.cpp
  95. @@ -17,19 +17,14 @@ point::point(const std::valarray<float>& income) {
  96.  
  97.  bool point::operator==(const point& right) const {
  98.    auto r = this->v_arr == right.v_arr;
  99. -  for (auto& bull : r) {
  100. -    if (bull == 0) return false;
  101. +  for (size_t i = 0; i < r.size(); ++i) {
  102. +    if (!r[i]) return false;
  103.    }
  104.    return true;
  105.  }
  106.  
  107.  bool point::operator!=(const point& right) const {
  108. -  auto r = this->v_arr == right.v_arr;
  109. -  bool tmp = true;
  110. -  for (auto& bull : r) {
  111. -    if (bull == 0) return true;
  112. -  }
  113. -  return false;
  114. +    return ! ((*this) == right);
  115.  }
  116.  
  117.  bool point::operator<(const point& right) const {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement