Skip to content

Method Jakobi for symmetrical matrixs#3

Open
tnoktkm wants to merge 1 commit into
mainfrom
dev
Open

Method Jakobi for symmetrical matrixs#3
tnoktkm wants to merge 1 commit into
mainfrom
dev

Conversation

@tnoktkm
Copy link
Copy Markdown
Owner

@tnoktkm tnoktkm commented Apr 10, 2021

For Pull Request

@tnoktkm tnoktkm requested a review from JungleTryne April 10, 2021 14:07
@tnoktkm tnoktkm added the enhancement New feature or request label Apr 10, 2021
Comment thread Task 3, Jakobi/main.cpp
#include <cmath>
#include <iomanip>

std::vector<int> absMaxElement(std::vector<std::vector<double>> matrix) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты передаешь вектор по значению, происходит лишнее копирование -> теряешь впроизводительности.
Ты никак не меняешь matrix, поэтому передавай ее по константной ссылке:

std::vector<int> absMacElement(const std::vector<std::vector<double>>& matrix)

Comment thread Task 3, Jakobi/main.cpp
int x, y;
for (size_t i = 0; i < matrix.size(); ++i) {
for (size_t j = i; j < matrix.size(); ++j) {
if (i != j && fabs(matrix[i][j]) > maximum) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Используй std::abs, это более адаптированная версия для C++

Comment thread Task 3, Jakobi/main.cpp
}
}
}
std::vector<int> ans;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты используешь вектор, чтобы хранить два числа? Создай отдельную структуру для этого, с ней будет легче работать:

struct MaxElementPos {
  size_t x;
  size_t y;
}

Comment thread Task 3, Jakobi/main.cpp
return ans;
}

double findFi (int i, int j, std::vector<std::vector<double>> matrix) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что такое фи? Добавь комменты, которые объясняют этот кусок кода

Comment thread Task 3, Jakobi/main.cpp
std::cout << std::endl;
}

std::vector<std::vector<double>> multiplie(std::vector<std::vector<double>> a, std::vector<std::vector<double>> b) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделать отдельный тип:

using matrix_t = std::vector<std::vector<double>>

Тогда объявление станет проще:

matrix_t multiply(const matrix_t& first, const matrix_t& second)

И multiply пишется по другому)

Comment thread Task 3, Jakobi/main.cpp
return ans;
}

std::vector<std::vector<double>> returnv(double fi, int i, int j, int n) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returnv -- мне название не понятно, добавь комменты

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants