Skip to content
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

Implement a combination matrix type with support for read #137

Merged
merged 36 commits into from
Aug 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7d3a97e
Add combination implementation
greole Jun 24, 2024
dc5a117
fix typo
greole Jun 24, 2024
05fa34b
add further doc strings, add todo note for validation
greole Jun 24, 2024
a3a7726
refactor unit test build
greole Jun 24, 2024
b23fb49
Add unit test template combination
greole Jun 24, 2024
88642d6
fixup rebase artifacts
greole Aug 1, 2024
d8e690f
relocate test files
greole Aug 1, 2024
9fee0e8
format
greole Aug 1, 2024
ebf24c0
switch order
greole Aug 1, 2024
8e60940
rename members
greole Aug 1, 2024
4cf003d
add missing include
greole Aug 1, 2024
59caa96
fixup! rename members
greole Aug 1, 2024
5683b6a
fixup! rename combination to combinationMatrix
greole Aug 1, 2024
72cb89e
fixup! not implemented error
greole Aug 1, 2024
f633ffa
fixup! not implemented error
greole Aug 1, 2024
dadee27
fixup! executor
greole Aug 1, 2024
9428988
fixup! executor
greole Aug 1, 2024
6047b65
add getter
greole Aug 1, 2024
498360b
fixup! add getter
greole Aug 2, 2024
8187584
fixup! add getter
greole Aug 2, 2024
bba4718
fixup! template types
greole Aug 2, 2024
680dfa6
make ginkgo system package to reduce warnings
greole Aug 2, 2024
15f9559
revert make ginkgo system package to reduce warnings
greole Aug 2, 2024
3fd1082
fixup! template types
greole Aug 2, 2024
c4753f7
add conversion methods
greole Aug 7, 2024
d83d623
update combination matrix and unit tests
greole Aug 8, 2024
3bab719
Add some description for get_coeffients function
chihtaw Aug 12, 2024
e8dad8a
- Add a unit test for Combination Matrix by using read function
chihtaw Aug 12, 2024
71869fe
- Add a mtx file for storing the vector b
chihtaw Aug 14, 2024
ae2135e
- Use a sparse matrix with floating-point numbers to replace the orig…
chihtaw Aug 14, 2024
69e2565
- Add a unit test for Combination Matrix which stores L, D, and U mat…
chihtaw Aug 14, 2024
9049614
Finish the verification of entry values in the unit test for
chihtaw Aug 14, 2024
7a7c825
Finish the unit test for the function convert_to COO format.
chihtaw Aug 14, 2024
dcce316
- Implement the function convert_to CSR
chihtaw Aug 14, 2024
3f2c730
- Implement the function move_to COO format for CombinationMatrix class
chihtaw Aug 14, 2024
5b6302c
- Implement the function move_to CSR format for CombinationMatrix class
chihtaw Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- Use a sparse matrix with floating-point numbers to replace the orig…
…inal

matrix which consists of integers
- Create a mtx file for storing a vector
- Remove commented lines of code and reorganize the unit test
chihtaw committed Aug 14, 2024
commit ae2135e7fa18c660cc5e99731555d9cba5a8fe5e
2 changes: 1 addition & 1 deletion unitTests/MatrixWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later

# Copy the data files to the execution directory
configure_file(data/A.mtx data/A.mtx COPYONLY)
configure_file(data/A_sparse.mtx data/A_sparse.mtx COPYONLY)
configure_file(data/b.mtx data/b.mtx COPYONLY)

ogl_unit_test(matrixConversion "HostMatrix.C")
40 changes: 20 additions & 20 deletions unitTests/MatrixWrapper/Combination.C
Original file line number Diff line number Diff line change
@@ -57,46 +57,46 @@ TEST(Combination, CanCreateCombinationWithLinOpVector)
ASSERT_EQ(x->at(4, 0), 0.0);
}

TEST(Combination, CombinationMatrixWithSparseMatrix)
TEST(Combination, CanCreateCombinationMatrixWithSparseRealMatrix)
{
auto dim = gko::dim<2>{5, 5};
// gko::matrix_data<double, int> m1
// (dim, {{0, 0, 2}, {1, 1, 0}, {2, 3, 5}});

auto exec = gko::share(gko::ReferenceExecutor::create());
// auto m1linop =
// gko::share(gko::matrix::Csr<scalar, label>::create(exec, dim));
// m1linop->read(m1);
using ValueType = double;
using IndexType = int;
// Arrange
using ValueType = scalar;
using IndexType = label;
using mtx = gko::matrix::Csr<ValueType, IndexType>;
using vec = gko::matrix::Dense<ValueType>;

int dim_size = 5;
auto dim = gko::dim<2>{dim_size, dim_size};

auto exec = gko::share(gko::ReferenceExecutor::create());

auto m1linop = gko::share(
gko::read<mtx>(std::ifstream("data/A.mtx"), exec));
gko::read<mtx>(std::ifstream("data/A_sparse.mtx"), exec));

auto b = gko::read<vec>(std::ifstream("data/b.mtx"), exec);

std::vector<std::shared_ptr<const gko::LinOp>> linops{m1linop, m1linop};

// Act
auto cmb = CombinationMatrix<gko::matrix::Csr<scalar, label>>::create(
exec, dim, linops);

ASSERT_EQ(cmb->get_size(), gko::dim<2>(5, 5));
// Assert
ASSERT_EQ(cmb->get_size(), gko::dim<2>(dim_size, dim_size));
ASSERT_EQ(cmb->get_coefficients().size(), 2);
ASSERT_EQ(cmb->get_operators().size(), 2);

// auto b = gko::matrix::Dense<scalar>::create(exec, gko::dim<2>{5, 1});
// b->fill(1.0);
auto x = gko::matrix::Dense<scalar>::create(exec, gko::dim<2>{5, 1});
// Act
auto x = gko::matrix::Dense<scalar>::create(exec, gko::dim<2>{dim_size, 1});
x->fill(0.0);
cmb->apply(b, x);

ASSERT_EQ(x->at(0, 0), 4.0);
// Assert
ASSERT_EQ(x->at(0, 0), 38.0);
ASSERT_EQ(x->at(1, 0), 0.0);
ASSERT_EQ(x->at(2, 0), 10.0);
ASSERT_EQ(x->at(3, 0), 0.0);
ASSERT_EQ(x->at(4, 0), 0.0);
ASSERT_EQ(x->at(2, 0), 2.0);
ASSERT_EQ(x->at(3, 0), -1414.4);
ASSERT_EQ(x->at(4, 0), 96.0);
}

TEST(Combination, CanConvertToCsr)
5 changes: 0 additions & 5 deletions unitTests/MatrixWrapper/data/A.mtx

This file was deleted.

10 changes: 10 additions & 0 deletions unitTests/MatrixWrapper/data/A_sparse.mtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
%%MatrixMarket matrix coordinate real general
5 5 8
1 1 1
1 4 6
2 2 10.5
3 3 0.5
4 2 250.5
4 4 -280
4 5 33.2
5 5 12
8 changes: 4 additions & 4 deletions unitTests/MatrixWrapper/data/b.mtx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%MatrixMarket matrix array real general
5 1
1
1
1
1
1
0
2
3
4