-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amanda Bienz
authored and
Amanda Bienz
committed
May 24, 2024
1 parent
1c3457f
commit 6e1cfba
Showing
6 changed files
with
164 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright (c) 2015-2017, RAPtor Developer Team | ||
// License: Simplified BSD, http://opensource.org/licenses/BSD-2-Clause | ||
|
||
|
||
#include "gtest/gtest.h" | ||
#include "raptor/raptor.hpp" | ||
|
||
using namespace raptor; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
|
||
} // end of main() // | ||
|
||
TEST(AnisoJacobiTest, TestsInUtil) | ||
{ | ||
double x_val; | ||
int grid[3] = {10, 10, 10}; | ||
double* stencil = laplace_stencil_27pt(); | ||
CSRMatrix* A_sten = stencil_grid(stencil, grid, 3); | ||
int n_items_read; | ||
FILE* f; | ||
|
||
Vector x(A_sten->n_rows); | ||
Vector b(A_sten->n_rows); | ||
Vector tmp(A_sten->n_rows); | ||
|
||
BSRMatrix* A = new BSRMatrix(A_sten, 5, 5); | ||
double* D_inv; | ||
|
||
const char* x_ones_1 = "../../../../test_data/laplace_block_jacobi_ones_1.txt"; | ||
const char* x_ones_2 = "../../../../test_data/laplace_block_jacobi_ones_2.txt"; | ||
const char* x_inc_1 = "../../../../test_data/laplace_block_jacobi_inc_1.txt"; | ||
const char* x_inc_2 = "../../../../test_data/laplace_block_jacobi_inc_2.txt"; | ||
|
||
// SETUP D_inv! | ||
block_relax_init(A, &D_inv); | ||
|
||
/********************************************* | ||
* Test jacobi when b is constant value 1.0 | ||
*********************************************/ | ||
// Iteration 1 | ||
b.set_const_value(1.0); | ||
x.set_const_value(0.0); | ||
jacobi(A, D_inv, b, x, tmp, 1, 3.0/4); | ||
f = fopen(x_ones_1, "r"); | ||
for (int i = 0; i < A_sten->n_rows; i++) | ||
{ | ||
n_items_read = fscanf(f, "%lg\n", &x_val); | ||
ASSERT_EQ(n_items_read, 1); | ||
ASSERT_NEAR(x[i],x_val,1e-06); | ||
} | ||
fclose(f); | ||
|
||
// Iteration 2 | ||
jacobi(A, D_inv, b, x, tmp, 1, 3.0/4); | ||
f = fopen(x_ones_2, "r"); | ||
for (int i = 0; i < A_sten->n_rows; i++) | ||
{ | ||
n_items_read = fscanf(f, "%lg\n", &x_val); | ||
ASSERT_EQ(n_items_read, 1); | ||
ASSERT_NEAR(x[i],x_val,1e-06); | ||
} | ||
fclose(f); | ||
|
||
/********************************************* | ||
* Test jacobi when b[i] = i | ||
*********************************************/ | ||
// Iteration 1 | ||
for (int i = 0; i < A_sten->n_rows; i++) | ||
{ | ||
b[i] = i; | ||
} | ||
x.set_const_value(0.0); | ||
jacobi(A, D_inv, b, x, tmp, 1, 3.0/4); | ||
f = fopen(x_inc_1, "r"); | ||
for (int i = 0; i < A_sten->n_rows; i++) | ||
{ | ||
n_items_read = fscanf(f, "%lg\n", &x_val); | ||
ASSERT_EQ(n_items_read, 1); | ||
ASSERT_NEAR(x[i],x_val,1e-06); | ||
} | ||
fclose(f); | ||
|
||
// Iteration 2 | ||
jacobi(A, D_inv, b, x, tmp, 1, 3.0/4); | ||
f = fopen(x_inc_2, "r"); | ||
for (int i = 0; i < A_sten->n_rows; i++) | ||
{ | ||
n_items_read = fscanf(f, "%lg\n", &x_val); | ||
ASSERT_EQ(n_items_read, 1); | ||
ASSERT_NEAR(x[i],x_val,1e-06); | ||
} | ||
fclose(f); | ||
|
||
|
||
// Free D_inv | ||
block_relax_free(D_inv); | ||
|
||
delete A; | ||
delete A_sten; | ||
|
||
|
||
|
||
} // end of TEST(AnisoSpMVTest, TestsInUtil) // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters