Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60934975
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
Fri, May 3, 11:58
Size
1 KB
Mime Type
text/x-c
Expires
Sun, May 5, 11:58 (2 d)
Engine
blob
Format
Raw Data
Handle
17442604
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