Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tebogoyungmercykay/mathematical_expressions_calculator
Polynomials are mathematical objects which are expressions of variables and coefficients added to-gether. These polynomials can use operator overloading in a very intuitive manner since most of the operators that we can overload are mathematical operators, which can also be applied to polynomials.
https://github.com/tebogoyungmercykay/mathematical_expressions_calculator
bivariate coverage generalisation inheritance linear linux makefile memory-management operator-overloading operators polymorphism polynomials quadratic testing univariate valgrind
Last synced: 12 days ago
JSON representation
Polynomials are mathematical objects which are expressions of variables and coefficients added to-gether. These polynomials can use operator overloading in a very intuitive manner since most of the operators that we can overload are mathematical operators, which can also be applied to polynomials.
- Host: GitHub
- URL: https://github.com/tebogoyungmercykay/mathematical_expressions_calculator
- Owner: TebogoYungMercykay
- Created: 2023-10-01T10:11:40.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-12T22:31:56.000Z (over 1 year ago)
- Last Synced: 2024-11-20T16:06:10.423Z (2 months ago)
- Topics: bivariate, coverage, generalisation, inheritance, linear, linux, makefile, memory-management, operator-overloading, operators, polymorphism, polynomials, quadratic, testing, univariate, valgrind
- Language: C++
- Homepage: https://github.com
- Size: 535 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Polynomial Calculator
- Polynomials are mathematical objects which are expressions of variables and coefficients added to-gether. These polynomials can use operator overloading in a very intuitive manner since most of the operators that we can overload are mathematical operators, which can also be applied to polynomials.
- In this implementation I will create a polynomial class, as well as a few derived classes, which will inherit some of the basic functionality of polynomials but add their own restrictions.---
- ## Section 1: Polynomial Calculator Classes
- ##### `term`:
- This class will be used as the terms inside polynomials. A term in a polynomial consists of a coefficient, which for simplicity reasons, will be an integer value. A term will also contain a number of variables. Every variable will have a positive power.
- Note that a variable to the power 0, won’t be stored because this is the same as multiplying by 1. Negative powers are not allowed since polynomials can only contain positive powers.
- ##### `polynomial`:
- This is an abstract class that will be used to represent a polynomial.
- A polynomial is a collection of terms which are added together.- ##### `univariate`:
- Univariate inherits publicly from polynomial. This is a specialized version of polynomial, with 2 restrictions.
- The first restriction is that the polynomial can only contain one type of variable.
- The second restriction is a degree restriction.
- The univariate class has a degree variable. All terms in the univariate must have a degree less than or equal to the degree variable.- ##### `bivariate`:
- Bivariate inherits publicly from polynomial. This is a specialized version of polynomial, with 2 restrictions.
- The first restriction is that the polynomial can have at most 2 types of variables.
- The second restriction is a degree restriction.
- The bivariate class has a degree variable. All terms in the bivariate must have a degree less than or equal to the degree variable.- ##### `linear`:
- Linear inherits publicly from univariate. This is a specialised version of univariate.
- In this class, the degree variable is set to 1- ##### `quadratic`:
- Quadratic inherits publicly from univariate. This is a specialised version of univariate.
- In this class, the degree variable is set to 2
- ##### `circle`:
- Circle inherits publicly from bivariate. This is a specialised version of bivariate.
- In this class, the degree variable is set to 2. Additionally, we will only be using circles centred around the origin. Thus only three terms are allowed.
- The first and second terms must have a degree of 2, and the last term must have a degree of 0.
- The first two terms must also have the same coefficient.- ##### `ellipse`:
- Ellipse inherits publicly from bivariate. This is a specialised version of bivariate. In this class, the degree variable is set to 2. Additionally, we will only be using ellipses centred around the origin.
- Thus only three terms are allowed. The first and second terms must have a degree of 2, and the last term must have a degree of 0.
- ## Section 2: Memory Management- As memory management is a core part of C++, the aim is to ensure, at all times, that the code correctly de-allocates all the memory that was allocated.
- The following command is used:
```C++
valgrind --leak-check=full ./main
```
- ###### `Testing`:- As testing is a vital skill that all software developers need to know and be able to perform daily, In order to determine the coverage of your testing the gcov tool, specifically the following version gcov (Debian 8.3.0-6) 8.3.0, will be used.
- The following set of commands will be used to run gcov:
```C++
g++ --coverage *.cpp -o main
./main
gcov -f -m -r -j term polynomial univariate bivariate linear quadratic circle ellipse
```
---- ## Section 3: Requirements before running Code:
- Install an `IDE` that compiles and runs C++ codes.
- 1st Recommendation: `VS Code`
- 2nd Recommendation: `IntelliJ IDEA`
- 3rd Recommendation: `Visual Studio`
- Setup Video:
- Title: How to set up WSL Ubuntu terminal shell and run it from Visual Studio Code
- Video Link: [Youtube-Video-Link](https://www.youtube.com/watch?v=fp45HpZuhS8&t=112s)
- Installing Coverage (Linux (Debian/Ubuntu)):
- sudo apt-get update
- sudo apt-get install gcov
- sudo apt-get install lcov
- which gcov
- which lcov
- Installing Valgrind (Linux (Debian/Ubuntu)):
- sudo apt-get install valgrind- ###### NB: The makefile is included to compile and run the code on the terminal.
- ###### `Commands:=`
- `make` (to build the main executable).
- `make clean` (to clean up generated files).
- `make run` (to run the program with valgrind (assuming you have installed `valgrind`)).
- `make tar` (to create a tarball of your project).
- `make untar` (to extract the contents of the `tarball`).
- `make coverage` (to generate coverage reports (assuming you have installed `lcov`)).---
```C++
main:
g++ -g *.cpp -std=c++98 -pedantic -o mainclean:
rm -f *.o *.tar.gz main
reset
clearrun:
valgrind --leak-check=full ./maintar:
tar -cvz *.* -f Code.tar.gzuntar:
tar -zxvf *.tar.gztest:
g++ --coverage *.cpp -o main
gcov -f -m -r -j term polynomial univariate bivariate linear quadratic circle ellipse
./main
lcov -c -d . -o coverage.info
genhtml coverage.info -o coverage_report```
---
---
The End, Thank You
---
---