Skip to content

Commit

Permalink
Merge branch 'bug_fix_and_changes'
Browse files Browse the repository at this point in the history
  • Loading branch information
fenilgmehta committed Jun 21, 2019
2 parents 7d9fae4 + 3945418 commit ceecdd2
Show file tree
Hide file tree
Showing 23 changed files with 5,817 additions and 2,492 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake-build-debug/*
CMakeList.txt

ProgressReport.md
ProgressReport_sorting.md
references/*
test/*.out

Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
cmake_minimum_required(VERSION 3.8)
project(project_Sorting)
project(project_Sorting C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE on)

add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(references)

#file(GLOB sourceFILES *.cpp *.c)
#file(GLOB sourceFILES *.cpp *.c *.hpp)
#FOREACH (sourceFile ${sourceFILES})
# #get_filename_component(sourceFile_Path ${sourceFile} PATH)
# get_filename_component(sourceFile_Name ${sourceFile} NAME)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Details
5. Can be called on all containers with RandomAccessIterator
6. Requirements:
* [first, last) is a valid range.
* RandomAccessIter value_type is mutable.
* RandomAccessIter value_type is LessThanComparable.
* RandomAccessIter value_type supports the operator>>, which returns an integer-type right-shifted a specified number of bits.
* RandomAccessIter supports the operator[], which returns the i'th element of the container.
* RandomAccessIterator value_type is mutable.
* RandomAccessIterator value_type is LessThanComparable.
* RandomAccessIterator value_type supports the operator>>, which returns an integer-type right-shifted a specified number of bits.
* RandomAccessIterator supports the operator[], which returns the i'th element of the container.


Features
Expand Down Expand Up @@ -60,15 +60,15 @@ The graphs above shows how ir_sort::integer_sort starts performing better with h
Usage
----------------------------------
For projects:
```
// copy the following four files to the project folder: "basic_sorts.hpp", "integer_sort.hpp", "integer_sort.cpp" and "integer_sort_objects_small.cpp"
```c++
// copy the following four files to the project folder: "basic_sorts.hpp", "ir_commons.hpp", "integer_sort.cpp" and "integer_sort_objects_small.cpp"

// paste the following lines in the file start
include "integer_sort.cpp"
```

For competitions:
```
```c++
// copy the namespace "ir_sort" from "ir_sort_competitions.cpp" to the main ".cpp" program file

// to call the function, from the namespace "ir_sort"
Expand Down
57 changes: 57 additions & 0 deletions graphs_and_analysis/Swapping Optimization Stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Size each object/element = 1000\*64 bits

--------------------------------------
| Array Length | Size |
--------------------------------------
| 10 | 78.1 Kilo Bytes |
| 100 | 781.2 Kilo Bytes |
| 1000 | 7.6 Mega Bytes |
| 10000 | 76.2 Mega Bytes |
| 100000 | 762.9 Mega Bytes |
| 400000 | 3051.7 Mega Bytes |
--------------------------------------

-------------------------------------------------------------------
| Array Length | std::sort | std::sort with swapping optimization |
-------------------------------------------------------------------
| 10 | 1 | 0.5285277077764 |
| 100 | 1 | 0.4710165788783 |
| 1000 | 1 | 0.4057255466440 |
| 10000 | 1 | 0.3525010783507 |
| 100000 | 1 | 0.2993293913040 |
| 400000 | 1 | 0.2834329893917 |
-------------------------------------------------------------------

-------------------------------------------------------------------
| Array Length | pdqsort | pdqsort with swapping optimization |
-------------------------------------------------------------------
| 10 | 1 | 0.6823455747541 |
| 100 | 1 | 0.4675638045956 |
| 1000 | 1 | 0.4135459923537 |
| 10000 | 1 | 0.3613480052967 |
| 100000 | 1 | 0.2978379938026 |
| 400000 | 1 | 0.2766001987139 |
-------------------------------------------------------------------

-------------------------------------------------------------------
| Array Length | spinsort | spinsort with swapping optimization |
-------------------------------------------------------------------
| 10 | 1 | 0.6826073837106 |
| 100 | 1 | 0.3770882784316 |
| 1000 | 1 | 0.1934754654256 |
| 10000 | 1 | 0.1536743141055 |
| 100000 | 1 | 0.1262359018549 |
| 400000 | 1 | |
-------------------------------------------------------------------

----------------------------------------------------------------------------------
| Array Length | flat_stable_sort | flat_stable_sort with swapping optimization |
----------------------------------------------------------------------------------
| 10 | 1 | 0.1550813004327 |
| 100 | 1 | 0.2773391993192 |
| 1000 | 1 | 0.1978331585708 |
| 10000 | 1 | 0.1472313289969 |
| 100000 | 1 | 0.1160065037227 |
| 400000 | 1 | 0.1106390146959 |
----------------------------------------------------------------------------------

40 changes: 24 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
cmake_minimum_required(VERSION 3.8)
project(project_Sorting)
project(project_Sorting C CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE on)

#file(GLOB sourceFILES *.cpp *.c)
#FOREACH (sourceFile ${sourceFILES})
# #get_filename_component(sourceFile_Path ${sourceFile} PATH)
# get_filename_component(sourceFile_Name ${sourceFile} NAME)
#
# MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
# #MESSAGE(STATUS "Process file, path: ${sourceFile}")
#
# add_executable("${sourceFile_Name}" ${sourceFile})
#endforeach (sourceFile)
file(GLOB sourceFILES *.cpp *.c)
FOREACH (sourceFile ${sourceFILES})
#get_filename_component(sourceFile_Path ${sourceFile} PATH)
get_filename_component(sourceFile_Name ${sourceFile} NAME)

add_executable(basic_sorts.cpp basic_sorts.cpp)
add_executable(integer_sort.hpp integer_sort.hpp)
add_executable(integer_sort.cpp integer_sort.cpp)
add_executable(integer_sort_objects_small.cpp integer_sort_objects_small.cpp)
add_executable(ir_sort_competitions.cpp ir_sort_competitions.cpp)
MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
#MESSAGE(STATUS "Process file, path: ${sourceFile}")

add_executable("${sourceFile_Name}" ${sourceFile})
endforeach (sourceFile)

file(GLOB sourceFILES *.hpp *.h)
FOREACH (sourceFile ${sourceFILES})
get_filename_component(sourceFile_Name ${sourceFile} NAME)
MESSAGE(STATUS "Process file, name: ${sourceFile_Name}")
add_executable("${sourceFile_Name}" ${sourceFile})
set_target_properties(${sourceFile_Name} PROPERTIES LINKER_LANGUAGE CXX)
endforeach (sourceFile)

#add_executable(basic_sorts.cpp basic_sorts.cpp)
#add_executable(ir_commons.hpp ir_commons.hpp)
#add_executable(integer_sort.cpp integer_sort.cpp)
#add_executable(integer_sort_objects_small.cpp integer_sort_objects_small.cpp)
#add_executable(ir_sort_competitions.cpp ir_sort_competitions.cpp)
Loading

0 comments on commit ceecdd2

Please sign in to comment.