Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80702407
MatrixDiagonal.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 2, 04:20
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Sep 4, 04:20 (2 d)
Engine
blob
Format
Raw Data
Handle
20422583
Attached To
rGOOSEFEM GooseFEM
MatrixDiagonal.cpp
View Options
#include <catch2/catch.hpp>
#include <xtensor/xrandom.hpp>
#include <xtensor/xmath.hpp>
#include <GooseFEM/GooseFEM.h>
#define ISCLOSE(a,b) REQUIRE_THAT((a), Catch::WithinAbs((b), 1.e-12));
TEST_CASE
(
"GooseFEM::MatrixDiagonal"
,
"MatrixDiagonal.h"
)
{
SECTION
(
"dot"
)
{
GooseFEM
::
Mesh
::
Quad4
::
Regular
mesh
(
2
,
2
);
xt
::
xtensor
<
double
,
1
>
a
=
xt
::
random
::
rand
<
double
>
({
mesh
.
nnode
()
*
mesh
.
ndim
()});
xt
::
xtensor
<
double
,
1
>
b
=
xt
::
random
::
rand
<
double
>
({
mesh
.
nnode
()
*
mesh
.
ndim
()});
xt
::
xtensor
<
double
,
1
>
c
=
a
*
b
;
GooseFEM
::
MatrixDiagonal
A
(
mesh
.
conn
(),
mesh
.
dofs
());
A
.
set
(
a
);
xt
::
xtensor
<
double
,
1
>
C
=
A
.
Dot
(
b
);
REQUIRE
(
C
.
size
()
==
c
.
size
());
REQUIRE
(
xt
::
allclose
(
C
,
c
));
}
SECTION
(
"solve"
)
{
GooseFEM
::
Mesh
::
Quad4
::
Regular
mesh
(
2
,
2
);
xt
::
xtensor
<
double
,
1
>
a
=
xt
::
random
::
rand
<
double
>
({
mesh
.
nnode
()
*
mesh
.
ndim
()});
xt
::
xtensor
<
double
,
1
>
b
=
xt
::
random
::
rand
<
double
>
({
mesh
.
nnode
()
*
mesh
.
ndim
()});
xt
::
xtensor
<
double
,
1
>
c
=
a
*
b
;
GooseFEM
::
MatrixDiagonal
A
(
mesh
.
conn
(),
mesh
.
dofs
());
A
.
set
(
a
);
xt
::
xtensor
<
double
,
1
>
C
=
A
.
Dot
(
b
);
xt
::
xtensor
<
double
,
1
>
B
=
A
.
Solve
(
C
);
REQUIRE
(
B
.
size
()
==
b
.
size
());
REQUIRE
(
xt
::
allclose
(
B
,
b
));
}
}
Event Timeline
Log In to Comment