Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82081433
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 9, 12:07
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Sep 11, 12:07 (2 d)
Engine
blob
Format
Raw Data
Handle
20651522
Attached To
rGOOSEFEM GooseFEM
MatrixDiagonal.cpp
View Options
#include "support.h"
// =================================================================================================
TEST_CASE("GooseFEM::MatrixDiagonal", "MatrixDiagonal.h")
{
// =================================================================================================
SECTION("dot")
{
// mesh
GooseFEM::Mesh::Quad4::Regular mesh(2,2);
// random matrix and column
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;
// compute product
c = a * b;
// convert to GooseFEM
// - allocate
GooseFEM::MatrixDiagonal A(mesh.conn(), mesh.dofs());
xt::xtensor<double,1> C;
// - set
A.set(a);
// compute product
C = A.Dot(b);
// check
// - size
REQUIRE( C.size() == c.size() );
// - components
REQUIRE( xt::allclose(C, c) );
}
// -------------------------------------------------------------------------------------------------
SECTION("solve")
{
// mesh
GooseFEM::Mesh::Quad4::Regular mesh(2,2);
// random matrix and column
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;
// compute product
c = a * b;
// convert to GooseFEM
// - allocate
GooseFEM::MatrixDiagonal A(mesh.conn(), mesh.dofs());
xt::xtensor<double,1> B, C;
// - set
A.set(a);
// compute product
C = A.Dot(b);
// solve
B = A.Solve(C);
// check
// - size
REQUIRE( B.size() == b.size() );
// - components
REQUIRE( xt::allclose(B, b) );
}
// // =================================================================================================
}
Event Timeline
Log In to Comment