-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (61 loc) · 3.07 KB
/
main.cpp
File metadata and controls
76 lines (61 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <imeth/geometry/2D.hpp>
#include <imeth/geometry/3D.hpp>
#include <imeth/linear/algebra.hpp>
#include <imeth/linear/matrix.hpp>
#include <imeth/operation/arithmetic.hpp>
int main() {
imeth::Circle circle(5);
imeth::Square square(4);
imeth::Sphere sphere(3);
imeth::Cube cube(2);
std::cout << "=== SHAPE TESTS ===\n";
std::cout << "Circle area: " << circle.area() << ", perimeter: " << circle.perimeter() << "\n";
std::cout << "Square area: " << square.area() << ", perimeter: " << square.perimeter() << "\n";
std::cout << "Sphere area: " << sphere.area() << ", volume: " << sphere.volume() << "\n";
std::cout << "Cube area: " << cube.area() << ", volume: " << cube.volume() << "\n\n";
std::cout << "=== LINEAR EQUATION TESTS ===\n";
auto x1 = imeth::LinearAlgebra::solve_1v(2, 4);
if (x1)
std::cout << "Equation 1 Variable: x = " << *x1 << "\n";
else
std::cout << "Equation 1 Variable: No solution\n";
auto xy = imeth::LinearAlgebra::solve_2v(2, 3, 8, 4, -2, 0);
if (xy)
std::cout << "Equation 2 Variables: x = " << xy->first << ", y = " << xy->second << "\n";
else
std::cout << "Equation 2 Variables: No solution\n";
imeth::Matrix A{{2, 1}, {5, 7}};
imeth::Vector b{11, 13};
auto x = imeth::Solver::gaussian_elimination(A, b);
std::cout << "Solution: ";
for (size_t i = 0; i < x.size(); ++i)
std::cout << x[i] << " ";
std::cout << "\n\n";
std::cout << "=== ARITHMETIC TESTS ===\n";
// Basic operations
std::cout << "10 + 5 = " << imeth::Arithmetic::add(10, 5) << "\n";
std::cout << "10 * 5 = " << imeth::Arithmetic::multiply(10, 5) << "\n";
std::cout << "2^5 = " << imeth::Arithmetic::power(2, 5) << "\n";
std::cout << "Square root of 144 = " << imeth::Arithmetic::square_root(144) << "\n\n";
// Percentages
std::cout << "25% of 80 = " << imeth::Arithmetic::percent_of(25, 80) << "\n";
std::cout << "20 is what % of 50? = " << imeth::Arithmetic::what_percent(20, 50) << "%\n\n";
// Statistics
const std::vector<double> grades = {85, 90, 78, 92, 88};
std::cout << "Grades: 85, 90, 78, 92, 88\n";
std::cout << "Average: " << imeth::Arithmetic::average(grades) << "\n";
std::cout << "Median: " << imeth::Arithmetic::median(grades) << "\n";
std::cout << "Highest: " << imeth::Arithmetic::maximum(grades) << "\n";
std::cout << "Lowest: " << imeth::Arithmetic::minimum(grades) << "\n\n";
// Number properties
std::cout << "Is 17 prime? " << (imeth::Arithmetic::is_prime(17) ? "Yes" : "No") << "\n";
std::cout << "Is 20 even? " << (imeth::Arithmetic::is_even(20) ? "Yes" : "No") << "\n";
std::cout << "GCD of 48 and 18 = " << imeth::Arithmetic::greatest_common_divisor(48, 18) << "\n\n";
// Quadratic equation
if (auto result = imeth::QuadraticEquation::solve(1, -5, 6); std::holds_alternative<std::pair<double, double>>(result)) {
auto [x1, x2] = std::get<std::pair<double, double>>(result);
std::cout << "x1 = " << x1 << ", x2 = " << x2 << "\n";
}
}
// thank you gpt lmao