Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
ef0f415
Добавлен Tvector
DeveloperDeveloper123 Sep 16, 2025
93de87b
Добавлен vector.cpp
DeveloperDeveloper123 Sep 16, 2025
123493f
Добавлены тесты на Tvector
DeveloperDeveloper123 Sep 16, 2025
6154b19
Добавлено объявление класса MathVector
DeveloperDeveloper123 Sep 18, 2025
651f9e2
Добавлен класс MathVector с заголовочным файлом
DeveloperDeveloper123 Sep 18, 2025
cf7252e
Добавлено объявление класса Matrix
DeveloperDeveloper123 Sep 18, 2025
2eb45df
Небольшие изменения (оператор вывода теперь внутри класса)
DeveloperDeveloper123 Sep 18, 2025
ce08148
Добавлено объявление класса Triangle Matrix
DeveloperDeveloper123 Sep 18, 2025
bf8c4e6
Исправлен оператор умножения матрицы на вектор (была ошибка с типом в…
DeveloperDeveloper123 Sep 18, 2025
7117587
Добавлена реализация интерфейса калькулятора матриц
DeveloperDeveloper123 Sep 18, 2025
3a852a2
Добавлена реализация интерфейса калькулятора матриц с надписями на ан…
DeveloperDeveloper123 Sep 18, 2025
60a7ff1
Добавлена реализация операторов *, /, *=, /= (вектор и число)
DeveloperDeveloper123 Sep 26, 2025
545ef53
Добавлены операторы +, -, *, +=, -= (вектор и вектор)
DeveloperDeveloper123 Sep 26, 2025
40f0e25
Добавлен оператор вывода, изменено this->get_data()[i] на (*this)[i] …
DeveloperDeveloper123 Sep 26, 2025
4853d6f
Изменены названия в тестах для проверки конструкторов
DeveloperDeveloper123 Sep 27, 2025
7bb4195
Добавлены тесты на конструкторы
DeveloperDeveloper123 Sep 27, 2025
46eacd1
Реализация оператора вывода теперь внутри класса MathVector, во избеж…
DeveloperDeveloper123 Sep 27, 2025
44c0071
Исправлены тесты на конструкторы
DeveloperDeveloper123 Sep 27, 2025
192eeac
Добавлены тесты на операторы *, / (в том числе, на исключение при дел…
DeveloperDeveloper123 Sep 27, 2025
2882780
Исправлены синтаксические ошибки в названиях тестов
DeveloperDeveloper123 Sep 27, 2025
cfd7002
Добавлены тесты на операторы *=, /= (вектора на скаляр, в том числе, …
DeveloperDeveloper123 Sep 27, 2025
d667946
Добавлены тесты на операторы +, - и * в случае с двумя векторами разн…
DeveloperDeveloper123 Sep 27, 2025
47e33b9
Добавлены тесты на операторы +=, -= в случае с двумя векторами (в том…
DeveloperDeveloper123 Sep 27, 2025
095a0a9
Добавлены геттеры для написания тестов
DeveloperDeveloper123 Sep 29, 2025
8e18a1b
Убрано дублирование кода, свяазнное с геттерами...
DeveloperDeveloper123 Sep 29, 2025
89df2fb
Исправлены синтаксические ошибки в конструкторах
DeveloperDeveloper123 Sep 29, 2025
eb1a89e
Добавлены тесты на конструкторы и оператор присваивания
DeveloperDeveloper123 Sep 29, 2025
598097c
Добавлены операторы +, -, * и / для матрицы и скаляра
DeveloperDeveloper123 Sep 29, 2025
a7c4ebd
Добавлены операторы +=, -=, *=, /= для матрицы и скаляра
DeveloperDeveloper123 Sep 29, 2025
ef9a754
Добавлены операторы + и - для двух матриц
DeveloperDeveloper123 Sep 29, 2025
f4af57c
Добавлены тесты на операторы + и - для матриц (в том числе, тесты на …
DeveloperDeveloper123 Sep 29, 2025
373d57f
Добавлены операторы += и -= для двух матриц
DeveloperDeveloper123 Sep 29, 2025
1b3ded6
Добавлены тесты на операторы +=, -= (в том числе тесты на случаи, ког…
DeveloperDeveloper123 Sep 29, 2025
950db46
Добавлен оператор * для матриц И метод для транспонирования
DeveloperDeveloper123 Sep 30, 2025
078ecc4
Добавлены тесты на оператор * (в том числе на случай с исключением - …
DeveloperDeveloper123 Sep 30, 2025
36ee6e5
Добавлен оператор присваивания
DeveloperDeveloper123 Sep 30, 2025
1f8c691
Добавлен оператор присваивания
DeveloperDeveloper123 Sep 30, 2025
e02c7d2
Добавлен тест на оператор присваивания
DeveloperDeveloper123 Sep 30, 2025
187a5e8
Добавлен оператор * для матрицы и вектора, а также оператор присваивания
DeveloperDeveloper123 Sep 30, 2025
7d5d91b
Добавлены тесты на оператор * для матрицы и вектора (+ случай с исклю…
DeveloperDeveloper123 Sep 30, 2025
a5333b3
Убраны невозможные операии: сложение и вычитание вектора и матрицы (о…
DeveloperDeveloper123 Sep 30, 2025
db6f76f
Добавлен оператор присваивания, а также убраны объявления операторов,…
DeveloperDeveloper123 Oct 1, 2025
b800f7d
Добавлено объявление класса Triangle Matrix
DeveloperDeveloper123 Oct 4, 2025
6892ddb
Добавлен _start_index для работы с треугольной матрицей
DeveloperDeveloper123 Oct 4, 2025
be6bdd4
Добавлен геттер для _start_index и несколько новых конструкторов, учи…
DeveloperDeveloper123 Oct 4, 2025
893fc1e
Добавлен сеттер для стартового индекса и операторы []
DeveloperDeveloper123 Oct 4, 2025
ef5d917
Небольшие правки
DeveloperDeveloper123 Oct 4, 2025
8f85ca5
Убран оператор []
DeveloperDeveloper123 Oct 4, 2025
afae751
Добавлены тесты на новые конструкторы и оператор [], с учётом стартов…
DeveloperDeveloper123 Oct 4, 2025
8ff2e54
Добавлены конструкторы
DeveloperDeveloper123 Oct 4, 2025
0a176c5
Полностью готовы конструкторы, деструктор и оператор присваивания (ре…
DeveloperDeveloper123 Oct 5, 2025
3822b6e
Конструктор с массивом и размером пока не реализован (предыдущий конс…
DeveloperDeveloper123 Oct 5, 2025
3b942ac
Добавлены тесты на конструкторы (тест на конструктор с массивом и раз…
DeveloperDeveloper123 Oct 5, 2025
da15c1d
Добавлены операторы +=, -=, *=, /= для матрицы и значения
DeveloperDeveloper123 Oct 5, 2025
2042a5c
Небольшие правки
DeveloperDeveloper123 Oct 6, 2025
0d800ec
Изменения класса MathVector для реализации треугольной матрицы: в опе…
DeveloperDeveloper123 Oct 6, 2025
02f0378
Изменён оператор <<
DeveloperDeveloper123 Oct 6, 2025
5f678fb
Добавлены тесты на оператор [] и at() (в том числе, на случай с исклю…
DeveloperDeveloper123 Oct 6, 2025
eb7bca6
Небольшие правки
DeveloperDeveloper123 Oct 6, 2025
21c4b06
Изменён тест find_count_of_suitable_elements
DeveloperDeveloper123 Oct 6, 2025
15e7707
Добавлены тесты на конструктор копирования и оператор присваивания
DeveloperDeveloper123 Oct 6, 2025
8d943a0
Добавлены тесты на операторы +,-,*,/, +=, -=, *=, /= с треугольной ма…
DeveloperDeveloper123 Oct 6, 2025
f6170cc
Доработаны конструкторы
DeveloperDeveloper123 Oct 6, 2025
6fa8ee3
Добавлены операторы * для матрицы и вектора, +, -, +=, -= для двух ма…
DeveloperDeveloper123 Oct 6, 2025
fd581a3
Исправлены ошибки синтаксиса
DeveloperDeveloper123 Oct 6, 2025
23ff54a
Доработан main с калькулятором - функции заполнения матриц и вектора,…
DeveloperDeveloper123 Oct 6, 2025
f16c315
Переписан оператор для матрицы и вектора
DeveloperDeveloper123 Oct 6, 2025
ac1d6ec
Добавлены тесты на операторы +, -, +=, -=, * включая случаи с исключе…
DeveloperDeveloper123 Oct 6, 2025
224cdde
Тесты на * двух треугольных матриц (+ случай с исключением)
DeveloperDeveloper123 Oct 6, 2025
032e297
Добавлен оператор *
DeveloperDeveloper123 Oct 6, 2025
12a4eae
Задание из ТК: поиск локального минимума в матрице
DeveloperDeveloper123 Oct 7, 2025
dfeff04
Добавлены тесты
DeveloperDeveloper123 Oct 7, 2025
0c04291
Ренализация класса Сфера
DeveloperDeveloper123 Oct 10, 2025
7eeecc1
Добавлен класс Окружность
DeveloperDeveloper123 Oct 10, 2025
1494246
Добавлен класс Точка
DeveloperDeveloper123 Oct 10, 2025
0e600e7
Добавлен класс 3D-Точка
DeveloperDeveloper123 Oct 10, 2025
d431304
Добавлены тесты
DeveloperDeveloper123 Oct 10, 2025
fb90c58
Вынесла метод is_empty() в Public во избежание ошибок в стеке
DeveloperDeveloper123 Oct 12, 2025
e054c78
Неболшие правки
DeveloperDeveloper123 Oct 12, 2025
a2963e3
Добавлено this-> перед вызовом операторов из Tvector для ясности
DeveloperDeveloper123 Oct 13, 2025
54eb1d5
Вынесена из класса реализация оператора <<
DeveloperDeveloper123 Oct 13, 2025
f084077
Вынесен оператор << из класса
DeveloperDeveloper123 Oct 13, 2025
f321f87
Исправлена ошибка в операторе <<
DeveloperDeveloper123 Oct 13, 2025
f021e1e
Исправлен оператор вывода и упрощены реализации некоторых арифметичес…
DeveloperDeveloper123 Oct 13, 2025
a99cee7
Вынесена из класса реализация оператора <<
DeveloperDeveloper123 Oct 13, 2025
05f3d06
Небольшие изменения
DeveloperDeveloper123 Oct 14, 2025
0f5dcca
Убраны не нужные тесты
DeveloperDeveloper123 Oct 20, 2025
5c9c836
Убрано лишнее std::
DeveloperDeveloper123 Oct 20, 2025
21912c2
Убраны нелогичные операции из калькулятора матриц
DeveloperDeveloper123 Oct 20, 2025
5f71806
Теперь оператор * и / на скаляр использует операторы из MathVector
DeveloperDeveloper123 Oct 20, 2025
9e9f820
Убраны тесты на нелогичные операторы
DeveloperDeveloper123 Oct 20, 2025
055355c
Убраны += и -= (их нет в векторе, делать подобное в матрце странно)
DeveloperDeveloper123 Oct 20, 2025
b6a2263
Упрощена реализация некоторых операторов с учетом операторов из MathV…
DeveloperDeveloper123 Oct 20, 2025
e4a79f6
Убрана синтаксическая ошибка в операторе =, добавлено noexcept к гетт…
DeveloperDeveloper123 Oct 20, 2025
63027f7
Убраны нелогичные тесты
DeveloperDeveloper123 Oct 20, 2025
4a82f5b
Убраны нелогичные операторы + и - со скаляром
DeveloperDeveloper123 Oct 20, 2025
0d60e2e
Исправлены тесты на операторы в связи с оптимизацией их реализации
DeveloperDeveloper123 Oct 20, 2025
47fa082
Добавлен конструктор, принимающий треугольную матрицу для оптимизации…
DeveloperDeveloper123 Oct 20, 2025
e4ba0cd
Правки конструктора
DeveloperDeveloper123 Oct 20, 2025
c6d6076
Добавлен cmake лист
DeveloperDeveloper123 Nov 25, 2025
a3f87de
Добавлен cmake лист
DeveloperDeveloper123 Nov 25, 2025
7f77b5f
Добавлен cmake лист
DeveloperDeveloper123 Nov 25, 2025
50d8544
Добавлен .cpp файл и cmake лист
DeveloperDeveloper123 Nov 25, 2025
bf0ae47
Добавлен .cpp файл
DeveloperDeveloper123 Nov 25, 2025
39d2d31
Добавлен .cpp файл и cmake лист
DeveloperDeveloper123 Nov 25, 2025
0821e1d
Добавлен .cpp файл и cmake лист
DeveloperDeveloper123 Nov 25, 2025
7298787
CMakeLists.txt
DeveloperDeveloper123 Nov 30, 2025
84f37dc
lib_algoritm/CMakeLists.txt
DeveloperDeveloper123 Nov 30, 2025
1482f61
Cmake лист и упрощена реализация операторов матрицы
DeveloperDeveloper123 Dec 1, 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
24 changes: 20 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# указывайте последнюю доступную вам версию CMake
# указывайте последнюю доступную вам версию CMake

cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 14)
Expand All @@ -14,6 +14,24 @@ include(cmake/function.cmake) # подхватываем функции,
# и для создания исполняемого проекта в отдельные функции

add_subdirectory(lib_easy_example) # подключаем дополнительный CMakeLists.txt из подкаталога с именем lib_easy_example

add_subdirectory(lib_vector)
add_subdirectory(lib_math_vector)
add_subdirectory(lib_matrix)
add_subdirectory(lib_triangle_matrix)

add_subdirectory(lib_point)
add_subdirectory(lib_point3d)
add_subdirectory(lib_circle)
add_subdirectory(lib_sphere)

add_subdirectory(lib_dsu)

add_subdirectory(lib_algoritm)




add_subdirectory(main) # подключаем дополнительный CMakeLists.txt из подкаталога с именем main

option(BTEST "build test?" ON) # указываем подключаем ли google-тесты (ON или YES) или нет (OFF или NO)
Expand All @@ -23,6 +41,4 @@ if(BTEST) # если тесты подключены
add_subdirectory("third_party/gtest" EXCLUDE_FROM_ALL)
enable_testing()
add_subdirectory(tests)
endif()


endif()
1 change: 1 addition & 0 deletions lib_algoritm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create_project_lib(Algoritm)
55 changes: 55 additions & 0 deletions lib_algoritm/algoritm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once
#include "../lib_matrix/matrix.h"
#include <random>
#include <utility>
template <class T>
std::pair<size_t, size_t> find_min_neighbor_coords(const Matrix<T>& matrix, size_t x, size_t y) {
T min_val = matrix[x][y];
size_t min_x = x;
size_t min_y = y;
if (x > 0 && matrix[x - 1][y] < min_val) {
min_val = matrix[x - 1][y];
min_x = x - 1;
min_y = y;
}
if (x < matrix.getM() - 1 && matrix[x + 1][y] < min_val) {
min_val = matrix[x + 1][y];
min_x = x + 1;
min_y = y;
}
if (y > 0 && matrix[x][y - 1] < min_val) {
min_val = matrix[x][y - 1];
min_x = x;
min_y = y - 1;
}
if (y < matrix.getN() - 1 && matrix[x][y + 1] < min_val) {
min_val = matrix[x][y + 1];
min_x = x;
min_y = y + 1;
}
return { min_x, min_y };
}
size_t getRandomIndex(size_t max) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<size_t> dist(0, max - 1);
return dist(gen);
}
template <class T>
T find_local_minimum(const Matrix<T>& matrix) {
size_t x = getRandomIndex(matrix.getM());
size_t y = getRandomIndex(matrix.getN());

while (true) {
std::pair<size_t, size_t> min_coords = find_min_neighbor_coords(matrix, x, y);
size_t new_x = min_coords.first;
size_t new_y = min_coords.second;

if (new_x == x && new_y == y) {
return matrix[x][y];
}

x = new_x;
y = new_y;
}
}
24 changes: 24 additions & 0 deletions lib_circle/circle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "../lib_point/point.h"
#include <cmath>
class Circle : public Point {
private:
int _radius;
public:
Circle(int x, int y, int radius) : Point(x,y), _radius(radius) {}
Circle(Point coord_center, int radius)
: Point(coord_center.getX(), coord_center.getY()), _radius(radius) {}
Circle(const Circle& other) = default;
int getR() const {
return _radius;
}
void setR(int r) {
_radius = r;
}
bool operator == (const Circle& other) const {
return _x == other._x && _y == other._y && _radius == other._radius;
}
bool operator != (const Circle& other) const{
return !(*this == other);
}
};
1 change: 1 addition & 0 deletions lib_math_vector/math_vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "math_vector.h"
193 changes: 193 additions & 0 deletions lib_math_vector/math_vector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#pragma once
#include <stdexcept>
#include "../lib_vector/vector.h"
template <class T>
class MathVector:public Tvector<T> {
protected:
size_t _start_index = 0;
public:
MathVector();
MathVector(size_t size);
MathVector(size_t size, size_t start_index);
MathVector(T* data, size_t size);
MathVector(T* data, size_t size, size_t start_index);
MathVector(const MathVector<T>& other);
virtual ~MathVector();

size_t get_start_index() const {
return _start_index;
}
void set_start_index(size_t index) {
_start_index = index;
}

T& at(size_t index);
const T& at(size_t index) const;

MathVector<T> operator * (T value) const;
MathVector<T> operator / (T value) const;

MathVector<T>& operator *= (T value);
MathVector<T>& operator /= (T value);

MathVector<T> operator + (const MathVector<T>& vector) const;
MathVector<T> operator - (const MathVector<T>& vector) const;
T operator * (const MathVector<T>& vector) const;

MathVector<T>& operator += (const MathVector<T>& vector);
MathVector<T>& operator -= (const MathVector<T>& vector);
MathVector<T>& operator=(const MathVector<T>& other);
template<typename U>
friend std::ostream& operator<<(std::ostream&, const MathVector<U>& vector);

T& operator[](size_t index);
const T& operator[](size_t index) const;
};
template<class T>
MathVector<T>::MathVector() : Tvector<T>() {}
template <class T>
MathVector<T>::MathVector(size_t size) : Tvector<T>(size) {}
template <class T>
MathVector<T>::MathVector(size_t size, size_t start_index) : Tvector<T>(size), _start_index(start_index) {}
template <class T>
MathVector<T>::MathVector(T* data, size_t size) : Tvector<T>(data, size) {}
template <class T>
MathVector<T>::MathVector(T* data, size_t size, size_t start_index) :
Tvector<T>(data, size), _start_index(start_index) {}
template <class T>
MathVector<T>::MathVector(const MathVector<T>& other) :
Tvector<T>(other), _start_index(other._start_index) {}
template <class T>
MathVector<T>::~MathVector() = default;
template <class T>
MathVector<T> MathVector<T>::operator * (T value) const {
MathVector<T> result(this->get_size());
for (size_t i = 0; i < this->get_size(); ++i) {
result[i] = (*this)[i] * value;
}
return result;
}
template <class T>
MathVector<T> MathVector<T>::operator / (T value) const {
if (value == 0) {
throw std::logic_error("Can't divide by zero!");
}
MathVector<T> result(this->get_size());
for (size_t i = 0; i < this->get_size(); ++i) {
result[i] = (*this)[i] / value;
}
return result;
}
template <class T>
MathVector<T>& MathVector<T>::operator *= (T value) {
for (size_t i = 0; i < this->get_size(); ++i) {
(*this)[i] *= value;
}
return *this;
}
template <class T>
MathVector<T>& MathVector<T>::operator /= (T value) {
if (value == 0) {
throw std::logic_error("Can't divide by zero!");
}
for (size_t i = 0; i < this->get_size(); ++i) {
(*this)[i] /= value;
}
return *this;
}
template<class T>
MathVector<T> MathVector<T>::operator + (const MathVector<T>& vector) const {
if (this->get_size() != vector.get_size()) {
throw std::logic_error("Vectors must have the same dimension");
}
MathVector<T> result(this->get_size());
for (size_t i = 0; i < this->get_size(); ++i) {
result[i] = (*this)[i] + vector[i];
}
return result;
}
template<class T>
MathVector<T> MathVector<T>::operator - (const MathVector<T>& vector) const {
if (this->get_size() != vector.get_size()) {
throw std::logic_error("Vectors must have the same dimension");
}
MathVector<T> result(this->get_size());
for (size_t i = 0; i < this->get_size(); ++i) {
result[i] = (*this)[i] - vector[i];
}
return result;
}
template<class T>
T MathVector<T>::operator * (const MathVector<T>& vector) const {
if (this->get_size() != vector.get_size()) {
throw std::logic_error("Vectors must have the same dimension");
}
T result{};
for (size_t i = 0; i < this->get_size(); ++i) {
result += (*this)[i] * vector[i];
}
return result;
}
template<class T>
MathVector<T>& MathVector<T>::operator += (const MathVector<T>& vector) {
if (this->get_size() != vector.get_size()) {
throw std::logic_error("Vectors must have the same dimension");
}
for (size_t i = 0; i < this->get_size(); ++i) {
(*this)[i] += vector[i];
}
return *this;
}
template<class T>
MathVector<T>& MathVector<T>::operator -= (const MathVector<T>& vector) {
if (this->get_size() != vector.get_size()) {
throw std::logic_error("Vectors must have the same dimension");
}
for (size_t i = 0; i < this->get_size(); ++i) {
(*this)[i] -= vector[i];
}
return *this;
}
template <class T>
MathVector<T>& MathVector<T>::operator=(const MathVector<T>& other) {
if (this != &other) {
Tvector<T>::operator=(other);
_start_index = other._start_index;
}
return *this;
}
template <class T>
T& MathVector<T>::operator[](size_t index) {
return this->Tvector<T>::operator[](index - _start_index);
}
template <class T>
const T& MathVector<T>::operator[](size_t index) const {
return this->Tvector<T>::operator[](index - _start_index);
}
template <class T>
T& MathVector<T>::at(size_t index) {
if (index < _start_index || index >= _start_index + this->get_size()) {
throw std::logic_error("MathVector index out of range");
}
return this->Tvector<T>::operator[](index - _start_index);
}
template <class T>
const T& MathVector<T>::at(size_t index) const {
if (index < _start_index || index >= _start_index + this->get_size()) {
throw std::logic_error("MathVector index out of range");
}
return this->Tvector<T>::operator[](index - _start_index);
}

template <class U>
std::ostream& operator<<(std::ostream& out, const MathVector<U>& vector) {
out << "[";
for (size_t i = 0; i < vector.get_size(); ++i) {
out << vector[i];
if (i < vector.get_size() - 1) {
out << ", ";
}
}
out << "]";
return out;
}
1 change: 1 addition & 0 deletions lib_matrix/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create_project_lib(Matrix)
Loading