Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
90c9b0d
Cpp and Cmake .gitignore
Eric-Butcher Dec 30, 2024
483a42b
main.cpp created.
Eric-Butcher Dec 30, 2024
03235e5
Created initial code to get basic min and max from the commandline.
Eric-Butcher Dec 31, 2024
9640844
Setting up directory structures for building
Eric-Butcher Dec 31, 2024
01a9a93
Merge pull request #1 from Eric-Butcher/feature/cli-parse
Eric-Butcher Dec 31, 2024
ba0d457
Basic prng class structure set up.
Eric-Butcher Jan 1, 2025
f7a5814
initial PseudoRandomNumberGenerator abstract base class.
Eric-Butcher Jan 1, 2025
6b998b9
Moved class interface to header file.
Eric-Butcher Jan 1, 2025
f00ee7b
Template for the MersenneTwister.
Eric-Butcher May 10, 2025
93334b3
Added linear congruential generator template.
Eric-Butcher May 10, 2025
befb9a5
Refactored the prng files.
Eric-Butcher May 10, 2025
5635542
Starting on the implementation of the Linear Congruential Generator.
Eric-Butcher May 10, 2025
62124f1
Moved the definition of LinearCongruentialGenerator into .hpp and imp…
Eric-Butcher May 10, 2025
718cdae
Re-arranged directory structure and fixed CMake file.
Eric-Butcher May 10, 2025
e486055
Updated vscode settings for CMakeLists.txt location.
Eric-Butcher May 10, 2025
07e97df
Upped the minimum versino for cmake to version 3.21
Eric-Butcher May 11, 2025
cbfd109
Fixed bug where LCG did not properly assign the initial value to seed…
Eric-Butcher May 11, 2025
84abb7c
Got debugging working in vscode
Eric-Butcher May 11, 2025
5461055
Updated PRNG and LCG to support unit normailzed floats as outputs.
Eric-Butcher May 11, 2025
c8e46a4
Fully bug fixed the LCF unit normal generation.
Eric-Butcher May 11, 2025
1334534
Implemented XORShift PRNG
Eric-Butcher May 11, 2025
287c16b
Merge pull request #2 from Eric-Butcher/feature/prng
Eric-Butcher May 11, 2025
6f8c421
Started code for getting command line arguments and parsing them with…
Eric-Butcher May 17, 2025
57ad7e0
Moving argument extraction into ProgramRunner class and included new …
Eric-Butcher May 17, 2025
77c3159
Implemented functions for identifying from command line input how the…
Eric-Butcher May 18, 2025
fafe1f1
Eliminated lines of code that were no longer needed
Eric-Butcher May 18, 2025
cca0971
Added help option to determine program configuration code
Eric-Butcher May 18, 2025
cf6a2c6
Moved part of determine_program_configuration into determine_generati…
Eric-Butcher May 18, 2025
e3f5965
Moved parts of determine_program_configuration into determine_user_me…
Eric-Butcher May 18, 2025
5e7826d
Moved some program config code into determine_generation_type_configu…
Eric-Butcher May 18, 2025
6e0d09e
Moved logic for determine_program_configuration into determine_count_…
Eric-Butcher May 18, 2025
e33466a
Templated parse_value and parse_min_and_max_numbers so that seperate …
Eric-Butcher May 19, 2025
5ca4d85
Got ProgramRunner working to print error, help, and version messages
Eric-Butcher May 19, 2025
18907ee
Removed old code from main
Eric-Butcher May 19, 2025
7c7a1d1
Merge pull request #3 from Eric-Butcher/feature/command-line-parsing
Eric-Butcher May 19, 2025
ff39bb4
Started to add testing infrastructure with CMake
Eric-Butcher May 12, 2025
6f4b222
Got an example test running with GoogleTest and CMake
Eric-Butcher May 24, 2025
ffb5bad
Added simple test case for LCG contructor.
Eric-Butcher May 24, 2025
0d3ed50
Added test_XORShift.cpp to make sure multiple test files are usable
Eric-Butcher May 24, 2025
1b8cf7f
Merge pull request #4 from Eric-Butcher/feature/google-test
Eric-Butcher May 24, 2025
d6f7b22
Test cases for the lcg constructors
Eric-Butcher May 24, 2025
d85b70d
Added test cases for the lcg's generateUnitNormalRangeValu()
Eric-Butcher May 24, 2025
201ef65
Added tests for XORShift
Eric-Butcher May 24, 2025
5f3d4b1
Renamed occurences of std::uint64_t to uint64_t
Eric-Butcher May 24, 2025
4f114c8
Added const everywhere appropriate.
Eric-Butcher May 24, 2025
c37b56c
Finished tests for equidistribution
Eric-Butcher May 25, 2025
61b5191
Increased the number of iterations to 10000 fir GenerateUntNormalRand…
Eric-Butcher May 25, 2025
904fa48
Merge pull request #5 from Eric-Butcher/feature/testing-prngs
Eric-Butcher May 25, 2025
c67d441
Reconfigured the print_error method to use he program_name variable i…
Eric-Butcher May 25, 2025
e24f165
Test declarations for ProgramRunner
Eric-Butcher May 26, 2025
f605eae
Changed the determine_program_configuration method to take a referenc…
Eric-Butcher May 26, 2025
5659cef
Added ArgvBuilder in the ProgramRunner tests to simulate cli arguments
Eric-Butcher May 29, 2025
49f02fc
Added the ProgramStatus struct to be returned by iterate() and run() …
Eric-Butcher May 29, 2025
224ed0c
Added the test cases for the cli args
Eric-Butcher May 29, 2025
4ba4f08
Added the pointer to prng in the program runner
Eric-Butcher May 29, 2025
26cecd5
Added the virtual methods for generating floats and ints to the prng
Eric-Butcher May 30, 2025
4f1af2e
Changed the min and max's to be floats and i32s instead of doubles an…
Eric-Butcher May 30, 2025
801e911
Finished the iterate() method in runner
Eric-Butcher May 30, 2025
0b14474
Completed the iterate() and run() methods
Eric-Butcher May 30, 2025
42246ea
Fixed up tests to reflect changes to min and max types
Eric-Butcher May 30, 2025
c9c5718
Fixed up code to use the POSIXly correct option in getopt which allow…
Eric-Butcher May 31, 2025
077d4b6
Fixed bug where there was no_argument given as a setting for the type…
Eric-Butcher May 31, 2025
37af76d
Fixed some test cases with erroneous inputs of specifying a min and m…
Eric-Butcher Jun 1, 2025
290dcbb
Fixed error in TestProgramRunner.ExplicitCount test where it over loo…
Eric-Butcher Jun 1, 2025
84ddd7b
Added check to return an error if the user supplied a count value of 0
Eric-Butcher Jun 1, 2025
77f1fb9
Fixed test case TestProgramRunner.CountExcessvePositiveMagnitude to u…
Eric-Butcher Jun 1, 2025
d8d4ef2
Fixed the misformatting a short args in the DefaultType test case
Eric-Butcher Jun 1, 2025
702d663
Fixed invald command line argument in the TestProgramRunner.ExplicitA…
Eric-Butcher Jun 1, 2025
0eda6b3
Merge pull request #6 from Eric-Butcher/feature/program-runner
Eric-Butcher Jun 1, 2025
14fde31
Added github actions workflow for testing with ctest
Eric-Butcher Jun 1, 2025
5b135c6
Renamed the testing workflow to CTest
Eric-Butcher Jun 1, 2025
26a440d
Default codeql.yml from gh
Eric-Butcher Jun 1, 2025
5a82d6c
Updated code scanning workflow
Eric-Butcher Jun 1, 2025
10932c6
Merge pull request #7 from Eric-Butcher/feature/gh-actions-tests
Eric-Butcher Jun 1, 2025
3c39552
Added -Wall -Wextra -Wshadow -Wconversion -Wpedantic -Werror to all c…
Eric-Butcher Jun 1, 2025
d6ff342
Made modifications to source code to fix warnings with type conversions
Eric-Butcher Jun 1, 2025
4eadba7
Merge pull request #8 from Eric-Butcher/feature/compile-with-warnings
Eric-Butcher Jun 1, 2025
ed9777f
Made it so that main() prints out status.
Eric-Butcher Jun 1, 2025
3a331dc
Merge pull request #9 from Eric-Butcher/feature/main-prints-values
Eric-Butcher Jun 1, 2025
691cbb6
Fixed problem with the inclusive range for integer generation
Eric-Butcher Jun 1, 2025
bbe5a04
Merge pull request #10 from Eric-Butcher/bugfix/generation-distribution
Eric-Butcher Jun 1, 2025
6e203ca
Added the warmup function
Eric-Butcher Jun 1, 2025
7eda7de
Added the call to warmup in main
Eric-Butcher Jun 1, 2025
e573844
Merge pull request #11 from Eric-Butcher/feature/warmup
Eric-Butcher Jun 1, 2025
b7a6ed7
Added test file for Mersenne Twister
Eric-Butcher Jun 5, 2025
e5e8db9
Added the mersenne twister header
Eric-Butcher Jun 5, 2025
7952698
Updated the method signature for initializeRecurrenceState in the mer…
Eric-Butcher Jun 6, 2025
9110079
Added the initializeRecurrenceState method definition
Eric-Butcher Jun 6, 2025
3cbe85f
Changed constants to be class members
Eric-Butcher Jun 6, 2025
f966446
Private helper methods for computing random values with the Mersenne …
Eric-Butcher Jun 28, 2025
acfbb6b
Completed the Mersenne Twister class.
Eric-Butcher Jun 28, 2025
973c559
Added Mersenne Twister algorithm to be runnable at the command line b…
Eric-Butcher Jun 28, 2025
259c221
Merge pull request #12 from Eric-Butcher/feature/mersenne-twister
Eric-Butcher Jun 28, 2025
9a90618
Fixed the problem with segfaulting due to warming up when the user ne…
Eric-Butcher Jun 28, 2025
75d2f5e
Merge pull request #13 from Eric-Butcher/bugfix/non-generation-segfaults
Eric-Butcher Jun 28, 2025
84ac79d
Added test cases for inclusive ranges when generating integers
Eric-Butcher Jun 29, 2025
3340c0f
Fixed the problem with the inclusive range when engative numbers are …
Eric-Butcher Jun 29, 2025
641a644
Merge pull request #14 from Eric-Butcher/bugfix/negative-range-inclusive
Eric-Butcher Jun 29, 2025
ae0d5e5
Removed virtual function definition and implementation for generateUn…
Eric-Butcher Jun 29, 2025
cd5517c
Merge pull request #15 from Eric-Butcher/feature/refactor-unit-normal…
Eric-Butcher Jun 29, 2025
71685c1
packaging as .deb and .rpm with cpack.
Eric-Butcher Jul 2, 2025
0a58aa3
CMake configuration for cpack to crate .deb and .rpm.
Eric-Butcher Jul 5, 2025
98dae05
Containers for ubuntu and fedora with the program installed.
Eric-Butcher Jul 5, 2025
cc3f5ee
Replaced ubuntu container with a debian one becuase ubuntu container …
Eric-Butcher Jul 6, 2025
17bc726
Fedora image Containerfile.
Eric-Butcher Jul 6, 2025
cafd105
Reworded and formatted the help message.
Eric-Butcher Jul 6, 2025
a5296b5
Added the man page.
Eric-Butcher Jul 6, 2025
23843b3
Updated root CMakeLists.txt to create the .deb and .rpm packages with…
Eric-Butcher Jul 6, 2025
c1af49e
Merge pull request #16 from Eric-Butcher/feature/packaging
Eric-Butcher Jul 6, 2025
8054d8e
Wrote README.md.
Eric-Butcher Jul 6, 2025
86caa01
Fixed CMakeLists so that tests always compile but are no included in …
Eric-Butcher Jul 6, 2025
f1333e3
Merge pull request #18 from Eric-Butcher/feature/build
Eric-Butcher Jul 6, 2025
b1161b2
Merge pull request #17 from Eric-Butcher/chore/readme
Eric-Butcher Jul 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: "CodeQL Advanced"

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
schedule:
- cron: '34 0 * * 2'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: autobuild
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
# or others). This is typically only required for manual builds.
# - name: Setup runtime (example)
# uses: actions/setup-example@v1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
27 changes: 27 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CTest

on:
push:
branches: ["main", "dev"]
pull_request:
branches: ["main", "dev"]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y cmake g++

- name: Configure CMake
run: cmake -S . -B build

- name: Build
run: cmake --build build

- name: Run tests
run: ctest --test-dir build --output-on-failure
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Project structure
build/*

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
CMakeUserPresets.json
34 changes: 34 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": ["--algorithm", "xor", "-m", "0", "-M=10", "--count", "5", "-t", "int"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "CMake: build"
}

]
}
83 changes: 83 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"files.associations": {
"random": "cpp",
"algorithm": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"__nullptr": "cpp",
"any": "cpp",
"variant": "cpp",
"__locale": "cpp",
"charconv": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"__tree": "cpp",
"queue": "cpp",
"stack": "cpp",
"filesystem": "cpp"
},
"cmake.sourceDirectory": "/home/eric/Projects/Randomizer/"
}
59 changes: 59 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
cmake_minimum_required(VERSION 3.22)
project(randomizer VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Include directories
include_directories(include)

# Automatically collect all source and header files
file(GLOB_RECURSE SOURCES "src/*.cpp")
file(GLOB_RECURSE HEADERS "include/*.hpp")

# Define a library target for the main code
add_library(randomizer_lib ${SOURCES} ${HEADERS})
target_include_directories(randomizer_lib PUBLIC ${CMAKE_SOURCE_DIR}/include)


# Define main executable
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE randomizer_lib)

# Make CPack install the binary in /usr/bin
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)

# Make CPack install the man page
include(GNUInstallDirs)
install(FILES "${CMAKE_SOURCE_DIR}/docs/randomizer.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")

# Add compiler warnings only for GCC and Clang
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(randomizer_lib PRIVATE
-Wall
-Wextra
-Wshadow
-Wconversion
-Wpedantic
-Werror
)
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall
-Wextra
-Wshadow
-Wconversion
-Wpedantic
-Werror
)
endif()


enable_testing()

add_subdirectory(tests)

add_subdirectory(packaging)
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright (c) 2025, Eric Butcher
Loading