Код: Выделить всё
#include
#include
#include
#include
#include "HYPRE_krylov.h"
#include "HYPRE.h"
#include "HYPRE_parcsr_ls.h"
int main(int argc, char* argv[])
{
int i;
int myid, num_procs;
int N, n;
int ilower, iupper;
int local_size;
HYPRE_IJMatrix A;
HYPRE_ParCSRMatrix parcsr_A;
HYPRE_IJVector b;
HYPRE_ParVector par_b;
HYPRE_IJVector x;
HYPRE_ParVector par_x;
HYPRE_Solver solver, precond;
// Initialize
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myid);
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
HYPRE_Initialize();
N = 6;
local_size = N / num_procs;
ilower = local_size * myid;
iupper = local_size * (myid + 1) - 1;
local_size = iupper - ilower + 1;
HYPRE_IJMatrixCreate(MPI_COMM_WORLD, ilower, iupper, ilower, iupper, &A);
HYPRE_IJMatrixSetObjectType(A, HYPRE_PARCSR);
HYPRE_IJMatrixInitialize(A);
// Fill the matrix anti-diagonal
{
int nnz;
double values[1];
int cols[1];
int tmp[2];
for (i = ilower; i
Подробнее здесь: [url]https://stackoverflow.com/questions/79248939/c-hypre-solver-returns-unexpected-result[/url]