Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/CMakeLists.txt b/CMakeLists.txt
- index f9ba042..74a1e6f 100644
- --- a/CMakeLists.txt
- +++ b/CMakeLists.txt
- @@ -4,9 +4,13 @@ project(klasters)
- set(CMAKE_BUILD_TYPE Debug)
- set(CMAKE_CXX_STANDART 11)
- -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
- -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
- +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -std=c++11")
- -file(GLOB CPPS "*.cpp")
- +file(GLOB CPPS "${PROJECT_SOURCE_DIR}/klasters/*.cpp")
- +include_directories(${PROJECT_SOURCE_DIR}/klasters)
- -add_executable(${PROJECT_NAME} ${CPPS})
- \ No newline at end of file
- +add_executable(${PROJECT_NAME} ${CPPS})
- +
- +if (UNIX)
- + target_link_libraries(${PROJECT_NAME} pthread)
- +endif (UNIX)
- diff --git a/klasters/Cluster.cpp b/klasters/Cluster.cpp
- index e38e540..9d45170 100644
- --- a/klasters/Cluster.cpp
- +++ b/klasters/Cluster.cpp
- @@ -1,6 +1,6 @@
- /* Copyright 2020 Igor Lyamin */
- -#include "cluster.h"
- +#include "Cluster.h"
- cluster::cluster() {
- n_ = 0;
- diff --git a/klasters/functions.cpp b/klasters/functions.cpp
- index 6c674b2..5d3056d 100644
- --- a/klasters/functions.cpp
- +++ b/klasters/functions.cpp
- @@ -1,14 +1,10 @@
- /* Copyright 2020 Igor Lyamin */
- #include "functions.h"
- +#include <thread>
- int getCountOfThreads() {
- - SYSTEM_INFO sysinfo;
- - GetSystemInfo(&sysinfo);
- - int numCPU = sysinfo.dwNumberOfProcessors;
- - numCPU = std::thread::hardware_concurrency() == 0 ?
- - numCPU : std::thread::hardware_concurrency();
- - return numCPU - 1;
- + return std::thread::hardware_concurrency() - 1;
- }
- int getDistance(const point& X, const point& Y) {
- diff --git a/klasters/functions.h b/klasters/functions.h
- index 7e2b0cf..f8451f4 100644
- --- a/klasters/functions.h
- +++ b/klasters/functions.h
- @@ -3,7 +3,6 @@
- #pragma once
- /* global */
- -#include <windows.h>
- #include <thread>
- #include <mutex>
- diff --git a/klasters/kmeans.cpp b/klasters/kmeans.cpp
- index b3ac156..7944c04 100644
- --- a/klasters/kmeans.cpp
- +++ b/klasters/kmeans.cpp
- @@ -1,8 +1,6 @@
- /* Copyright 2020 Igor Lyamin */
- /* global */
- -#include <stdio.h>
- -#include <windows.h>
- #include <iostream>
- #include <list>
- #include <vector>
- @@ -16,7 +14,7 @@
- /* local */
- #include "point.h"
- -#include "cluster.h"
- +#include "Cluster.h"
- #include "functions.h"
- int main() {
- diff --git a/klasters/point.cpp b/klasters/point.cpp
- index 67a85a4..9218d1e 100644
- --- a/klasters/point.cpp
- +++ b/klasters/point.cpp
- @@ -17,19 +17,14 @@ point::point(const std::valarray<float>& income) {
- bool point::operator==(const point& right) const {
- auto r = this->v_arr == right.v_arr;
- - for (auto& bull : r) {
- - if (bull == 0) return false;
- + for (size_t i = 0; i < r.size(); ++i) {
- + if (!r[i]) return false;
- }
- return true;
- }
- bool point::operator!=(const point& right) const {
- - auto r = this->v_arr == right.v_arr;
- - bool tmp = true;
- - for (auto& bull : r) {
- - if (bull == 0) return true;
- - }
- - return false;
- + return ! ((*this) == right);
- }
- bool point::operator<(const point& right) const {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement