Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
0b8e6528
There was an error fetching the commit references. Please try again later.
Commit
0b8e6528
authored
6 years ago
by
Lukas Cejka
Committed by
Tomáš Oberhuber
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added test for setRow function.
parent
eb4ba842
No related branches found
No related tags found
1 merge request
!16
Matrices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/UnitTests/Matrices/SparseMatrixTest.h
+73
-0
73 additions, 0 deletions
src/UnitTests/Matrices/SparseMatrixTest.h
with
73 additions
and
0 deletions
src/UnitTests/Matrices/SparseMatrixTest.h
+
73
−
0
View file @
0b8e6528
...
@@ -54,6 +54,11 @@
...
@@ -54,6 +54,11 @@
* vectorProductCuda() ::TEST? How to test __device__?
* vectorProductCuda() ::TEST? How to test __device__?
*/
*/
// GENERAL TODO
/*
* For every function, EXPECT_EQ needs to be done, even for zeros in matrices.
*/
#include
<TNL/Matrices/CSR.h>
#include
<TNL/Matrices/CSR.h>
#include
<TNL/Matrices/Ellpack.h>
#include
<TNL/Matrices/Ellpack.h>
...
@@ -227,6 +232,62 @@ void test_AddElement()
...
@@ -227,6 +232,62 @@ void test_AddElement()
EXPECT_EQ
(
m
.
getElement
(
5
,
0
),
6
);
EXPECT_EQ
(
m
.
getElement
(
5
,
0
),
6
);
}
}
template
<
typename
Matrix
>
void
test_SetRow
()
{
const
int
rows
=
3
;
const
int
cols
=
7
;
Matrix
m
;
m
.
reset
();
m
.
setDimensions
(
rows
,
cols
);
typename
Matrix
::
CompressedRowLengthsVector
rowLengths
;
rowLengths
.
setSize
(
rows
);
rowLengths
.
setValue
(
6
);
rowLengths
.
setElement
(
1
,
3
);
m
.
setCompressedRowLengths
(
rowLengths
);
int
value
=
1
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
m
.
setElement
(
0
,
i
+
3
,
value
);
m
.
setElement
(
1
,
i
,
value
+
1
);
m
.
setElement
(
2
,
i
,
value
+
2
);
}
int
row1
[
3
]
=
{
11
,
11
,
11
};
int
colIndexes1
[
3
]
=
{
0
,
1
,
2
};
int
row2
[
3
]
=
{
22
,
22
,
22
};
int
colIndexes2
[
3
]
=
{
0
,
1
,
2
};
int
row3
[
3
]
=
{
33
,
33
,
33
};
int
colIndexes3
[
3
]
=
{
3
,
4
,
5
};
m
.
setRow
(
0
,
colIndexes1
,
row1
,
3
);
m
.
setRow
(
1
,
colIndexes2
,
row2
,
3
);
m
.
setRow
(
2
,
colIndexes3
,
row3
,
3
);
EXPECT_EQ
(
m
.
getElement
(
0
,
0
),
11
);
EXPECT_EQ
(
m
.
getElement
(
0
,
1
),
11
);
EXPECT_EQ
(
m
.
getElement
(
0
,
2
),
11
);
EXPECT_EQ
(
m
.
getElement
(
0
,
3
),
0
);
EXPECT_EQ
(
m
.
getElement
(
0
,
4
),
0
);
EXPECT_EQ
(
m
.
getElement
(
0
,
5
),
0
);
EXPECT_EQ
(
m
.
getElement
(
0
,
6
),
0
);
EXPECT_EQ
(
m
.
getElement
(
1
,
0
),
22
);
EXPECT_EQ
(
m
.
getElement
(
1
,
1
),
22
);
EXPECT_EQ
(
m
.
getElement
(
1
,
2
),
22
);
EXPECT_EQ
(
m
.
getElement
(
1
,
3
),
0
);
EXPECT_EQ
(
m
.
getElement
(
1
,
4
),
0
);
EXPECT_EQ
(
m
.
getElement
(
1
,
5
),
0
);
EXPECT_EQ
(
m
.
getElement
(
1
,
6
),
0
);
EXPECT_EQ
(
m
.
getElement
(
2
,
0
),
0
);
EXPECT_EQ
(
m
.
getElement
(
2
,
1
),
0
);
EXPECT_EQ
(
m
.
getElement
(
2
,
2
),
0
);
EXPECT_EQ
(
m
.
getElement
(
2
,
3
),
33
);
EXPECT_EQ
(
m
.
getElement
(
2
,
4
),
33
);
EXPECT_EQ
(
m
.
getElement
(
2
,
5
),
33
);
EXPECT_EQ
(
m
.
getElement
(
2
,
6
),
0
);
}
TEST
(
SparseMatrixTest
,
CSR_GetTypeTest_Host
)
TEST
(
SparseMatrixTest
,
CSR_GetTypeTest_Host
)
{
{
host_test_GetType
<
CSR_host_float
,
CSR_host_int
>
();
host_test_GetType
<
CSR_host_float
,
CSR_host_int
>
();
...
@@ -311,6 +372,18 @@ TEST( SparseMatrixTest, CSR_addElementTest_Cuda )
...
@@ -311,6 +372,18 @@ TEST( SparseMatrixTest, CSR_addElementTest_Cuda )
}
}
#endif
#endif
TEST
(
SparseMatrixTest
,
CSR_setRowTest_Host
)
{
test_SetRow
<
CSR_host_int
>
();
}
#ifdef HAVE_CUDA
TEST
(
SparseMatrixTest
,
CSR_setRowTest_Cuda
)
{
test_SetRow
<
CSR_cuda_int
>
();
}
#endif
#endif
#endif
#include
"../GtestMissingError.h"
#include
"../GtestMissingError.h"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment