Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_numerics
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argupta
openfpm_numerics
Commits
48eca62b
Commit
48eca62b
authored
Apr 13, 2016
by
Pietro Incardona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding missing files
parent
293dce45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
171 additions
and
0 deletions
+171
-0
src/Matrix/SparseMatrix_unit_tests.hpp
src/Matrix/SparseMatrix_unit_tests.hpp
+171
-0
No files found.
src/Matrix/SparseMatrix_unit_tests.hpp
0 → 100644
View file @
48eca62b
/*
* SparseMatrix_unit_tests.hpp
*
* Created on: Apr 4, 2016
* Author: i-bird
*/
#ifndef OPENFPM_NUMERICS_SRC_MATRIX_SPARSEMATRIX_UNIT_TESTS_HPP_
#define OPENFPM_NUMERICS_SRC_MATRIX_SPARSEMATRIX_UNIT_TESTS_HPP_
#include "Matrix/SparseMatrix.hpp"
#include "Vector/Vector.hpp"
#include "Solvers/umfpack_solver.hpp"
BOOST_AUTO_TEST_SUITE
(
sparse_matrix_test_suite
)
BOOST_AUTO_TEST_CASE
(
sparse_matrix_eigen_parallel
)
{
Vcluster
&
vcl
=
*
global_v_cluster
;
if
(
vcl
.
getProcessingUnits
()
!=
3
)
return
;
// 3 Processors 9x9 Matrix to invert
SparseMatrix
<
double
,
int
>
sm
(
9
,
9
);
Vector
<
double
>
v
(
9
);
typedef
SparseMatrix
<
double
,
int
>::
triplet_type
triplet
;
auto
&
triplets
=
sm
.
getMatrixTriplets
();
if
(
vcl
.
getProcessUnitID
()
==
0
)
{
// row 1
triplets
.
add
(
triplet
(
0
,
0
,
-
2
));
triplets
.
add
(
triplet
(
0
,
1
,
1
));
// row 2
triplets
.
add
(
triplet
(
1
,
0
,
1
));
triplets
.
add
(
triplet
(
1
,
1
,
-
2
));
triplets
.
add
(
triplet
(
1
,
2
,
1
));
// row 3
triplets
.
add
(
triplet
(
2
,
1
,
1
));
triplets
.
add
(
triplet
(
2
,
2
,
-
2
));
triplets
.
add
(
triplet
(
2
,
3
,
1
));
// v row1
v
.
insert
(
0
,
1
);
v
.
insert
(
1
,
1
);
v
.
insert
(
2
,
1
);
}
else
if
(
vcl
.
getProcessUnitID
()
==
1
)
{
// row 4
triplets
.
add
(
triplet
(
3
,
2
,
1
));
triplets
.
add
(
triplet
(
3
,
3
,
-
2
));
triplets
.
add
(
triplet
(
3
,
4
,
1
));
// row 5
triplets
.
add
(
triplet
(
4
,
3
,
1
));
triplets
.
add
(
triplet
(
4
,
4
,
-
2
));
triplets
.
add
(
triplet
(
4
,
5
,
1
));
// row 6
triplets
.
add
(
triplet
(
5
,
4
,
1
));
triplets
.
add
(
triplet
(
5
,
5
,
-
2
));
triplets
.
add
(
triplet
(
5
,
6
,
1
));
v
.
insert
(
3
,
1
);
v
.
insert
(
4
,
1
);
v
.
insert
(
5
,
1
);
}
else
if
(
vcl
.
getProcessUnitID
()
==
2
)
{
// row 7
triplets
.
add
(
triplet
(
6
,
5
,
1
));
triplets
.
add
(
triplet
(
6
,
6
,
-
2
));
triplets
.
add
(
triplet
(
6
,
7
,
1
));
// row 8
triplets
.
add
(
triplet
(
7
,
6
,
1
));
triplets
.
add
(
triplet
(
7
,
7
,
-
2
));
triplets
.
add
(
triplet
(
7
,
8
,
1
));
// row 9
triplets
.
add
(
triplet
(
8
,
7
,
1
));
triplets
.
add
(
triplet
(
8
,
8
,
-
2
));
v
.
insert
(
6
,
1
);
v
.
insert
(
7
,
1
);
v
.
insert
(
8
,
1
);
}
// force to sync
sm
.
getMat
();
// Master has the full Matrix
if
(
vcl
.
getProcessUnitID
()
==
0
)
{
BOOST_REQUIRE_EQUAL
(
sm
(
0
,
0
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
0
,
1
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
1
,
0
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
1
,
1
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
1
,
2
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
2
,
1
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
2
,
2
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
2
,
3
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
3
,
2
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
3
,
3
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
3
,
4
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
4
,
3
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
4
,
4
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
4
,
5
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
5
,
4
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
5
,
5
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
5
,
6
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
6
,
5
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
6
,
6
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
6
,
7
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
7
,
6
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
7
,
7
),
-
2
);
BOOST_REQUIRE_EQUAL
(
sm
(
7
,
8
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
8
,
7
),
1
);
BOOST_REQUIRE_EQUAL
(
sm
(
8
,
8
),
-
2
);
}
// try to invert the Matrix with umfpack
auto
x
=
umfpack_solver
<
double
>::
solve
(
sm
,
v
);
// we control the solution
if
(
vcl
.
getProcessUnitID
()
==
0
)
{
BOOST_REQUIRE_CLOSE
(
x
(
0
),
-
4.5
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
1
),
-
8
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
2
),
-
10.5
,
0.001
);
}
else
if
(
vcl
.
getProcessUnitID
()
==
1
)
{
BOOST_REQUIRE_CLOSE
(
x
(
3
),
-
12.0
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
4
),
-
12.5
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
5
),
-
12.0
,
0.001
);
}
else
if
(
vcl
.
getProcessUnitID
()
==
2
)
{
BOOST_REQUIRE_CLOSE
(
x
(
6
),
-
4.5
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
7
),
-
8
,
0.001
);
BOOST_REQUIRE_CLOSE
(
x
(
8
),
-
10.5
,
0.001
);
}
}
BOOST_AUTO_TEST_SUITE_END
()
#endif
/* OPENFPM_NUMERICS_SRC_MATRIX_SPARSEMATRIX_UNIT_TESTS_HPP_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment