-
Notifications
You must be signed in to change notification settings - Fork 0
Домашняя работа 2 Cpp (Матричный калькулятор) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Denactive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Прекрасно сделал, мелкие исправления и апрув
| @@ -0,0 +1,10 @@ | |||
| #include <iostream> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
добавь сюда хоть какой-нибудь расчет
|
|
||
| #include "dvector.h" | ||
|
|
||
| enum class ORIENT { ROW = 0, COL }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут енам класс, ниже просто енам. почему?
matrix_lib/include/dmatrix.h
Outdated
| throw std::runtime_error("Creation is impossible"); | ||
| } | ||
| return DMatrix(rows, cols, fill_value); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
трушные прогеры оставляют пустую строку в конце файлов. погугли почему.
тут и везде добавь \n
matrix_lib/include/dvector.h
Outdated
| @@ -0,0 +1,83 @@ | |||
| #pragma once | |||
|
|
|||
| #include "stdafx.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем тебе stdafx.h в этой программе?
| ~DVector(); | ||
|
|
||
| public: | ||
| const double *CBegin() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не обязательно было реализовывать почти все методы от std::vector, но лайк
| #include "dvector.h" | ||
|
|
||
| enum class ORIENT { ROW = 0, COL }; | ||
| enum SLICE { ROW = 0, COL }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я бы сделал явное указание, чему равен COL
| enum SLICE {ROW = 0, COL}, чтобы | ||
| 1. не писать класс, если в параметрах ROW / COL | ||
| 2. кастилось к enum SLICE, если в параметрах 0 / 1 | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
во! это пояснение - наверх
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| container: leshiy1295/gcc_linters_valgrind_cmake_gtest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=)
уникальная возможность поставить все руками упущена
.github/workflows/main.yml
Outdated
| - name: launch valgrind | ||
| run: | | ||
| cd build | ||
| valgrind --tool=memcheck --leak-check=yes ./main No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверял, падает ли CI если есть утечка? не уверен точно, надо ли --exit-code прописать
валгрин вызови на тестах. Main у тебя ничего не делает)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал кавередж, молодец. Выведи в readme. можешь воспользоваться shields.io
|
|
||
| env: | ||
| LIB_NAME: matrix_lib | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
часто выделяют prepare или beforescript с установкой всего необходимого, check - с линтером, build, test. требовать так делать не буду, особенно больно будет с линтером
| DMatrix operator/(DMatrix left, DMatrix const &right); | ||
| DMatrix operator*(DMatrix left, DMatrix const &right); | ||
|
|
||
| void Print(DMatrix const &matrix, std::string const &msg = std::string{}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
оставь эту функции, но добавь еще перегрузку оператора для << (std::cout<<new DMatrix() ) с его вызовом внутри
README.md
Outdated
|
|
||
| #### Домашняя работа 1 | ||
|
|
||
| ##### Мяделец Михаил WEB-11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
подпиши ментора, преподавателя
|
Исправил замечания.
|
Denactive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Молодец, отличная работа. Аппрув.
\n не достает в конфигах таких как main.yml. Видно в интерфейсе этого ПР, если нажать Files changed
|
Сдал вовремя, первым, за несколько дней до дедлайна. Быстро допилил задание с шаблонами. Исправил замечания. DVector реализует методы std::vector. Предварительно: 10б |
| { | ||
| if (begin >= end) | ||
| { | ||
| throw std::runtime_error("operator(): " + ERROR_RANGE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
возможно, ошибки стоит стандартизировать. Например, вынести в .h дефолтные инстансы std::exception. Хотя мне нравится, что юззеру должно быть потенциально понятнее, если ошибка будет явно говорить, где она случилась
Pull Request с домашней работой #2 по C++, реализация матричного калькулятора. Хотелось бы внести ясность касательно следующих сущностей: DVector и DMatrix.
В моей реализации DVector - класс, максимально похожий на
std::vector, поэтому нет разделения на вектор-столбец и вектор-строку, это просто обертка над динамическим массивом, последовательно размещенные в памяти элементы. Скалярное произведение вектора на вектор - это всегда вещественное число (не матрица), т.е.vector1.Dot(vector2)имеет возвращаемое значение double.Умножение вектора на матрицу и матрицу на вектор выполняется следующим образом:
vector.Dot(matrix)- подразумевается, что умножается вектор-строка 1xN и матрица NxM, результат - вектор-строка, тип DVectormatrix.Dot(vector)- матрица MxN умножается на вектор-столбец Nx1, результат - вектор-столбец, тип DMatrix.Если необходимо умножить вектор на вектор и получить матрицу, стоит использовать
matrix.Dot(matrix). Чтобы преобразовать вектор в матрицу (DVector -> DMatrix), нужно воспользоваться конструктором, в котором можно указать, вектор-строка или вектор-столбец интересует.UPD: Реализован и протестирован класс матрицы DMatrixCompile, являющийся "оберткой" над динамической матрицей DMatrix. Методы этой матрицы проверяют совместимость размеров при выполнении арифметических операций, валидность индекса при обращении к строке, столбцу на этапе компиляции. Если проверка прошла успешно, на этапе выполнения делегируют выполнение метода соответствующему методу динамической матрицы.