Skip to content

Commit

Permalink
fix cerr
Browse files Browse the repository at this point in the history
  • Loading branch information
Semyon1104 committed Nov 26, 2024
1 parent b7ca0a7 commit 4b44fcb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 15 deletions.
5 changes: 0 additions & 5 deletions tasks/mpi/titov_s_simple_iteration/src/ops_mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ using namespace std::chrono_literals;
void titov_s_simple_iteration_mpi::MPISimpleIterationSequential::transformMatrix() {
for (unsigned int i = 0; i < rows_; ++i) {
float diagonal = input_[i * cols_ + i];
if (diagonal == 0.0f) {
throw std::runtime_error("Diagonal element is zero, cannot transform matrix.");
}
for (unsigned int j = 0; j < cols_ - 1; ++j) {
if (i != j) {
input_[i * cols_ + j] = -input_[i * cols_ + j] / diagonal;
Expand Down Expand Up @@ -65,7 +62,6 @@ bool titov_s_simple_iteration_mpi::MPISimpleIterationSequential::pre_processing(
auto* epsilon_ptr = reinterpret_cast<float*>(taskData->inputs[rows_]);
epsilon_ = *epsilon_ptr;
if (!isDiagonallyDominant()) {
std::cerr << "Matrix is not diagonally dominant. The method may not converge.\n";
return false;
}

Expand All @@ -78,7 +74,6 @@ bool titov_s_simple_iteration_mpi::MPISimpleIterationSequential::validation() {
internal_order_test();

if (taskData->inputs_count.empty() || taskData->inputs.empty()) {
std::cerr << "Validation failed: inputs_count or inputs is empty.\n";
return false;
}

Expand Down
10 changes: 0 additions & 10 deletions tasks/seq/titov_s_simple_iteration/src/ops_seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ using namespace std::chrono_literals;
void titov_s_simple_iteration_seq::SimpleIterationSequential::transformMatrix() {
for (unsigned int i = 0; i < rows_; ++i) {
float diagonal = input_[i * cols_ + i];
if (diagonal == 0.0f) {
throw std::runtime_error("Diagonal element is zero, cannot transform matrix.");
}

for (unsigned int j = 0; j < cols_ - 1; ++j) {
if (i != j) {
Expand Down Expand Up @@ -47,44 +44,37 @@ bool titov_s_simple_iteration_seq::SimpleIterationSequential::validation() {
internal_order_test();

if (taskData->inputs_count.empty() || taskData->inputs.empty()) {
std::cerr << "Validation failed: inputs_count or inputs is empty.\n";
return false;
}

unsigned int rows = taskData->inputs_count[0];
unsigned int cols = taskData->inputs_count[1];

if (taskData->inputs.size() < rows + 1) {
std::cerr << "Validation failed: inputs size is less than expected (rows + 1).\n";
return false;
}

if (rows == 0 || cols == 0) {
std::cerr << "Validation failed: rows or cols is 0.\n";
return false;
}

for (unsigned int i = 0; i < rows; ++i) {
auto* tmp_ptr = reinterpret_cast<int*>(taskData->inputs[i]);
if (tmp_ptr == nullptr) {
std::cerr << "Validation failed: inputs[" << i << "] is nullptr.\n";
return false;
}
}

auto* epsilon_ptr = reinterpret_cast<float*>(taskData->inputs[rows]);
if (epsilon_ptr == nullptr) {
std::cerr << "Validation failed: epsilon_ptr is nullptr.\n";
return false;
}
float epsilon = *epsilon_ptr;
if (epsilon <= 0.0f || epsilon > 1.0f) {
std::cerr << "Validation failed: epsilon (" << epsilon << ") is out of range.\n";
return false;
}

if (taskData->outputs_count.empty() || taskData->outputs_count[0] < 1) {
std::cerr << "Validation failed: outputs_count is invalid.\n";
return false;
}

Expand Down

0 comments on commit 4b44fcb

Please sign in to comment.