Skip to content

Commit 2dc4254

Browse files
authored
Add support for matrices (#58)
This PR fixes issues #56 and #57. - Added support for 2D matrices - Supported operations: - Addition - Subtraction - Multiplication (both scalar and matrix) - Inverse - Power (with positive integers only) - Submatrix - Join matrices on the left or right - Transpose - Supported generation methods - Zeros (`Matrix::zeros`) - Ones (`Matrix::ones`) - Diagonal (`Matrix::diag`) - Changed numerous handling mechanisms - ARM platforms now are officially supported, including Windows on ARM and ARM Linux. - Added more functions to the Python API. <summary> **Changelog** <details> - **Fix accuracy issues for `exp`.** - **Fix build errors** - **Add `#include` for `<cstdint>`** - **Upgrade Windows version** Signed-off-by: Andy Zhang <[email protected]># Using Python to show GUI - **Trying to fix build issue on Windows** - **Fixed Windows build issues** - **Added support for 2D matrices** - Removed imgui directory for switching to Python tkinter. - Add matrix support `mat2d.hpp` - [BREAKING] `Number` objects now round to 10 decimal places by default. - [BREAKING] Steppable public headers are now in `include/steppable`. - **Small fixes to improve accuracy of `ref` result.** - Automatically rounds off numbers in matrix after `ref` operation. - `roundOff` now supports simplifying the zero polarity to always ensure positive zero. - Fix build issues. - **Fix rounding issues** - **Allow building on ARM** - **Improve precision of `Number` operations.** - [BREAKING] `Number` does not support implicit conversions from now on. - **Fixed build issues with Nanobind.** - Added back `const` qualifier to Number::operator/ and Number::operator*. - **Cleaned up configuration files** - **Enable special build hacks to be specified.** - Changed localization behavior: when no translations are found, defaults to en-US - Allow value inspections to be specified - Change rounding behavior to pad numbers automatically - **Fixed bugs in multiply** - [#56] Fix `isPowerOfTen` detection flaw - [WIP] Trying to address matrix rref issues. - **Fixed bugs in multiply** - [#57] Fix `isPowerOfTen` handling flaw - **Fixed rounding errors** - Address segmentation fault in util.cpp by adding empty checks - Fix incorrect rounding of negative decimals (like -2.99) to -1 - **Reformat** - **Add matrix symbols and pretty-printing using better symbols** - **Added unary operator support to `Number` and `Fraction`** - Unary operators are now supported for `Number` and `Fraction`. One can now use `+number` and `-number` to get the positive / negative instances of the number. - Python bindings now include the unary operators. - `*.pyi` files have been updated to include signatures of unary operators. - `Matrix` objects now support addition. - **Add operators for matrices** - Add `operator-`, `operator*`, `operator==` to `Matrix` - Add mat2d test targets - Add concepts to diffrentiate different types of objects (std::string, .present() methods and numeric) - Add support for assertIsEqual and assertIsNotEqual for other types of data - **Moved out bindings to separate modules** - Added bindings for `Matrix` to Python - Added support for implicit conversion between Python numerals and Steppable `Number` - Fix build errors by renaming `assert` to `_assertCondition` method in testing.cpp - **Add determinant for matrices** - Add the `det` function. - [BREAKING] `ref` now refer to the `rref` function. The `ref` function now does row echelon form without reduction. - Add the bindings for `det` and `ref` to Python. - **Allow matrix joining laterally.** - Matrices can now be joined using the `<<` and `>>` operators - [BREAKING] Matrix indices are now standardized to be (row, column) - **Add `rank` method for matrix.** - Add `rank` method to `Matrix` - Add corresponding bindings - Add support for iterating through the matrix, in C++ and Python - Changed order of Matrix::zeros arguments - Add literal `_n` to specify a number - **Allow matrix powers** - Allow matrix powers - Allow matrix inverse by specifying -1 as power. - **Fix build errors** - Add parameters to Python - Add `diag` method to Python bindings. - **Add documentation to Python binding stubs** - [BREAKING] Change stub file names to underscores to prevent accessing - Add documentation - Corrected typing annotations in stubs - **Add copyright headers** - Not requiring too many GIthub Actions for pull requests - **Fixed build errors** - Fixed return type of Matrix::diag. </details> </summary>
2 parents 3edb3da + 7505463 commit 2dc4254

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3798
-1084
lines changed

.github/workflows/benchmark.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
push:
77
branches: ["develop"]
88

9-
pull_request:
10-
branches: ["main"]
11-
129
workflow_dispatch:
1310

1411
jobs:

.github/workflows/cmake-multi-platform.yml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ on:
1010
- "**.hpp"
1111
- "**.py"
1212
- "**.yml"
13-
14-
pull_request:
15-
branches: ["main"]
1613
jobs:
1714
build:
1815
runs-on: ${{ matrix.os }}
@@ -26,22 +23,27 @@ jobs:
2623
#
2724
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2825
matrix:
29-
os: [ubuntu-latest, windows-2019, macos-13, macos-14, macos-15]
30-
build_type: [Release]
26+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-13, macos-14, macos-15]
27+
build_type: [Debug, Release]
3128
c_compiler: [clang, cl]
3229
python_version: ['3.11', '3.12', '3.13']
3330
include:
34-
- os: windows-2019
31+
- os: windows-latest
32+
c_compiler: cl
33+
cpp_compiler: cl
34+
cmake_extra_options: ''
35+
- os: windows-11-arm
3536
c_compiler: cl
3637
cpp_compiler: cl
3738
cmake_extra_options: ''
3839
- os: ubuntu-latest
3940
c_compiler: clang
4041
cpp_compiler: clang++
4142
cmake_extra_options: '-GNinja'
42-
# - os: macos-latest
43-
# c_compiler: gcc
44-
# cpp_compiler: g++
43+
- os: ubuntu-24.04-arm
44+
c_compiler: clang
45+
cpp_compiler: clang++
46+
cmake_extra_options: ''
4547
- os: macos-13
4648
c_compiler: clang
4749
cpp_compiler: clang++
@@ -55,10 +57,14 @@ jobs:
5557
cpp_compiler: clang++
5658
cmake_extra_options: '-GNinja'
5759
exclude:
58-
- os: windows-2019
60+
- os: windows-latest
61+
c_compiler: clang
62+
- os: windows-11-arm
5963
c_compiler: clang
6064
- os: ubuntu-latest
6165
c_compiler: cl
66+
- os: ubuntu-24.04-arm
67+
c_compiler: cl
6268
- os: macos-13
6369
c_compiler: cl
6470
- os: macos-14
@@ -79,17 +85,6 @@ jobs:
7985
echo "CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}" >> "$GITHUB_ENV"
8086
echo "CMAKE_OPTIONS=${{ matrix.cmake_extra_options }}" >> "$GITHUB_ENV"
8187
82-
- name: Set up Homebrew
83-
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' || matrix.os == 'ubuntu-latest'}}
84-
id: set-up-homebrew
85-
uses: Homebrew/actions/setup-homebrew@master
86-
87-
- name: Install LLVM
88-
if: ${{ matrix.os == 'macos-13' || matrix.os == 'macos-14' || matrix.os == 'macos-15' || matrix.os == 'ubuntu-latest' }}
89-
run: |
90-
brew install llvm ninja
91-
echo "PATH=$(brew --prefix llvm)/bin:$PATH" >> "$GITHUB_ENV"
92-
9388
- name: Set up Python
9489
uses: actions/setup-python@v5
9590
with:
@@ -108,6 +103,6 @@ jobs:
108103
uses: actions/[email protected]
109104
with:
110105
# Artifact name
111-
name: PyBuild ${{ matrix.os }}-cp${{ matrix.python_version }}
106+
name: steppable-${{ matrix.os }}-cp${{ matrix.python_version }}-${{ matrix.build_type }}
112107
# A file, directory or wildcard pattern that describes what to upload
113108
path: ${{ steps.strings.outputs.py-build-output-dir }}

.idea/.name

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/Steppable.iml

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dictionaries/project.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/launch.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
{
22
"configurations": [
3+
{
4+
"name": "Matrix::rref",
5+
"type": "cppdbg",
6+
"request": "launch",
7+
"program": "${workspaceFolder}/build/src/matrix_ref",
8+
"args": [],
9+
"cwd": "${workspaceFolder}",
10+
"environment": [],
11+
"externalConsole": true,
12+
"MIMode": "lldb",
13+
"internalConsoleOptions": "openOnSessionStart",
14+
"preLaunchTask": "CMake: build",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
},
21+
{
22+
"description": "Set Disassembly Flavor to Intel",
23+
"text": "-gdb-set disassembly-flavor intel",
24+
"ignoreFailures": true
25+
}
26+
]
27+
},
328
{
429
"name": "Division",
530
"type": "cppdbg",
631
"request": "launch",
7-
"program": "${workspaceFolder}/build/src/division",
32+
"program": "${workspaceFolder}/build/src/calc_division",
833
"args": [
934
"1",
1035
"2"
@@ -14,6 +39,7 @@
1439
"environment": [],
1540
"externalConsole": false,
1641
"MIMode": "lldb",
42+
"internalConsoleOptions": "openOnSessionStart",
1743
"setupCommands": [
1844
{
1945
"description": "Enable pretty-printing for gdb",
@@ -31,13 +57,14 @@
3157
"name": "Add",
3258
"type": "cppdbg",
3359
"request": "launch",
34-
"program": "${workspaceFolder}/build/src/add",
60+
"program": "${workspaceFolder}/build/src/calc_add",
3561
"args": [
3662
"-5",
3763
"6"
3864
],
3965
"cwd": "${workspaceFolder}/build",
4066
"preLaunchTask": "CMake: build",
67+
"internalConsoleOptions": "openOnSessionStart",
4168
"setupCommands": [
4269
{
4370
"description": "Enable pretty-printing for gdb",
@@ -50,14 +77,15 @@
5077
"type": "cppdbg",
5178
"request": "launch",
5279
"name": "Multiply",
53-
"program": "${workspaceFolder}/build/src/multiply",
80+
"program": "${workspaceFolder}/build/src/calc_multiply",
5481
"args": [
5582
"56",
5683
"76",
5784
"+profile"
5885
],
5986
"cwd": "${workspaceFolder}",
60-
"preLaunchTask": "CMake: build"
87+
"preLaunchTask": "CMake: build",
88+
"internalConsoleOptions": "openOnSessionStart",
6189
}
6290
]
6391
}

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# SOFTWARE. #
2121
#####################################################################################################
2222

23+
INCLUDE(cmake/build_special_hacks.cmake)
24+
2325
CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
2426
PROJECT(Steppable)
2527

@@ -109,11 +111,11 @@ SET(COMPONENTS
109111
calc::root
110112
calc::subtract
111113
calc::trig
112-
)
114+
matrix::ref)
113115
# NEW_COMPONENT: PATCH Do NOT remove the previous comment.
114116

115117
SET(TARGETS ${COMPONENTS} util)
116-
SET(TEST_TARGETS_TEMP util fraction number factors format ${COMPONENTS})
118+
SET(TEST_TARGETS_TEMP util fraction number mat2d factors format ${COMPONENTS})
117119

118120
FOREACH(TEST_TARGET IN LISTS TEST_TARGETS_TEMP)
119121
SET(TARGET_NAME "test")
@@ -131,7 +133,6 @@ ENDFOREACH()
131133
ADD_SUBDIRECTORY(src/)
132134
ADD_SUBDIRECTORY(lib/)
133135
ADD_SUBDIRECTORY(tests/)
134-
ADD_SUBDIRECTORY(gui/)
135136
ADD_SUBDIRECTORY(include/) # The CMakeLists file there adds the include/ directory to everything
136137

137138
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)

azure-pipelines.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

cmake/build_special_hacks.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
IF(STP_DEB_CALC_DIVISION_RESULT_INSPECT)
2+
ADD_COMPILE_DEFINITIONS(STP_DEB_CALC_DIVISION_RESULT_INSPECT)
3+
ENDIF()
4+
5+
IF(STP_DEB_CALC_MULTIPLY_RESULT_INSPECT)
6+
ADD_COMPILE_DEFINITIONS(STP_DEB_CALC_MULTIPLY_RESULT_INSPECT)
7+
ENDIF()
8+
9+
IF(STP_DEB_MATRIX_REF_RESULT_INSPECT)
10+
ADD_COMPILE_DEFINITIONS(STP_DEB_MATRIX_REF_RESULT_INSPECT)
11+
ENDIF()

gui/CMakeLists.txt

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)