本文整理汇总了C++中SymEngine::DenseMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::DenseMatrix方法的具体用法?C++ SymEngine::DenseMatrix怎么用?C++ SymEngine::DenseMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::DenseMatrix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
SymEngine::print_stack_on_segfault();
DenseMatrix A = DenseMatrix(3, 3, {symbol("a"), symbol("b"), symbol("c"),
symbol("d"), symbol("e"), symbol("f"), symbol("g"), symbol("h"), symbol("i")});
DenseMatrix B = DenseMatrix(3, 3, {symbol("x"), symbol("y"), symbol("z"), symbol("p"),
symbol("q"), symbol("r"), symbol("u"), symbol("v"), symbol("w")});
DenseMatrix C(3, 3);
std::cout << "Multiplying Two Matrices; matrix dimensions: 3 x 3" << std::endl;
unsigned N = 10000;
auto t1 = std::chrono::high_resolution_clock::now();
for (unsigned i = 0; i < N; i++)
mul_dense_dense(A, B, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count()/N
<< " microseconds" << std::endl;
return 0;
}
示例2: main
int main(int argc, char* argv[])
{
SymEngine::print_stack_on_segfault();
DenseMatrix A = DenseMatrix(3, 3, {symbol("a"), symbol("b"), symbol("c"), symbol("d"),
symbol("e"), symbol("f"), symbol("g"), symbol("h"), symbol("i")});
DenseMatrix B = DenseMatrix(3, 3, {symbol("x"), symbol("y"), symbol("z"), symbol("p"),
symbol("q"), symbol("r"), symbol("u"), symbol("v"), symbol("w")});
DenseMatrix C(3, 3);
std::cout << "Adding Two Matrices; matrix dimensions: 3 x 3" << std::endl;
// We are taking an average time since time for a single addition varied in
// a range of 40-50 microseconds
unsigned N = 10000;
auto t1 = std::chrono::high_resolution_clock::now();
for (unsigned i = 0; i < N; i++)
add_dense_dense(A, B, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count()/N
<< " microseconds" << std::endl;
return 0;
}
示例3: main
int main(int argc, char* argv[])
{
Teuchos::print_stack_on_segfault();
DenseMatrix A = DenseMatrix(4, 4, {integer(-23), integer(67), integer(3), integer(4),
integer(54), integer(61), integer(7), integer(8), integer(32), integer(15),
integer(12), integer(13), integer(100), integer(17), integer(15),
integer(178)
});
DenseMatrix B = DenseMatrix(4, 4, {integer(12), integer(22), integer(30), integer(40),
integer(45), integer(6), integer(37), integer(80), integer(91), integer(10),
integer(16), integer(52), integer(45), integer(14), integer(2),
integer(6)
});
DenseMatrix C(4, 4);
std::cout << "Multiplying Two Matrices; matrix dimensions: 4 x 4" << std::endl;
unsigned N = 10000;
auto t1 = std::chrono::high_resolution_clock::now();
for (unsigned i = 0; i < N; i++)
mul_dense_dense(A, B, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count()/N
<< " microseconds" << std::endl;
return 0;
}
示例4: main
int main(int argc, char* argv[])
{
Teuchos::print_stack_on_segfault();
DenseMatrix A = DenseMatrix(4, 4, {integer(1), integer(2), integer(3), integer(4),
integer(5), integer(6), integer(7), integer(8), integer(9), integer(10),
integer(11), integer(12), integer(13), integer(14), integer(15),
integer(16)});
DenseMatrix B = DenseMatrix(4, 4, {integer(1), integer(2), integer(3), integer(4),
integer(5), integer(6), integer(7), integer(8), integer(9), integer(10),
integer(11), integer(12), integer(13), integer(14), integer(15),
integer(16)});
DenseMatrix C(4, 4);
std::cout << "Adding Two Matrices; matrix dimensions: 4 x 4" << std::endl;
// We are taking an average time since time for a single addition varied in
// a range of 40-50 microseconds
unsigned N = 10000;
auto t1 = std::chrono::high_resolution_clock::now();
for (unsigned i = 0; i < N; i++)
add_dense_dense(A, B, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout
<< std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count()/N
<< " microseconds" << std::endl;
return 0;
}
示例5: DenseMatrix
}
// If all elements were found, then a == b
return true;
}
TEST_CASE("test_homogeneous_lde()", "[diophantine]")
{
std::vector<DenseMatrix> basis, true_basis;
// First two tests are taken from the following paper:
// Evelyne Contejean, Herve Devie. An Efficient Incremental Algorithm
// for Solving Systems of Linear Diophantine Equations. Information and
// computation, 113(1):143-172, August 1994.
DenseMatrix A = DenseMatrix(2, 4, {integer(-1), integer(1), integer(2),
integer(-3), integer(-1), integer(3),
integer(-2), integer(-1)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{
DenseMatrix(1, 4, {integer(0), integer(1), integer(1), integer(1)}),
DenseMatrix(1, 4, {integer(4), integer(2), integer(1), integer(0)})};
REQUIRE(vec_dense_matrix_eq_perm(basis, true_basis));
basis.clear();
A = DenseMatrix(1, 4, {integer(-1), integer(1), integer(2), integer(-3)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{
DenseMatrix(1, 4, {integer(0), integer(0), integer(3), integer(2)}),
DenseMatrix(1, 4, {integer(0), integer(1), integer(1), integer(1)}),
DenseMatrix(1, 4, {integer(0), integer(3), integer(0), integer(1)}),
示例6: test_homogeneous_lde
void test_homogeneous_lde()
{
std::vector<DenseMatrix> basis, true_basis;
// First two tests are taken from the following paper:
// Evelyne Contejean, Herve Devie. An Efficient Incremental Algorithm
// for Solving Systems of Linear Diophantine Equations. Information and
// computation, 113(1):143-172, August 1994.
DenseMatrix A = DenseMatrix(2, 4, {
integer(-1), integer(1), integer(2), integer(-3),
integer(-1), integer(3), integer(-2), integer(-1)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{
DenseMatrix(1, 4, {integer(0), integer(1), integer(1), integer(1)}),
DenseMatrix(1, 4, {integer(4), integer(2), integer(1), integer(0)})
};
assert(vec_dense_matrix_eq_perm(basis, true_basis));
basis.clear();
A = DenseMatrix(1, 4, {integer(-1), integer(1), integer(2), integer(-3)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{
DenseMatrix(1, 4, {integer(0), integer(0), integer(3), integer(2)}),
DenseMatrix(1, 4, {integer(0), integer(1), integer(1), integer(1)}),
DenseMatrix(1, 4, {integer(0), integer(3), integer(0), integer(1)}),
DenseMatrix(1, 4, {integer(1), integer(0), integer(2), integer(1)}),
DenseMatrix(1, 4, {integer(2), integer(0), integer(1), integer(0)}),
DenseMatrix(1, 4, {integer(1), integer(1), integer(0), integer(0)})
};
assert(vec_dense_matrix_eq_perm(basis, true_basis));
basis.clear();
A = DenseMatrix(1, 2, {integer(2), integer(3)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{};
assert(vec_dense_matrix_eq_perm(basis, true_basis));
basis.clear();
A = DenseMatrix(1, 2, {integer(2), integer(-3)});
homogeneous_lde(basis, A);
true_basis = std::vector<DenseMatrix>{
DenseMatrix(1, 2, {integer(3), integer(2)})
};
assert(vec_dense_matrix_eq_perm(basis, true_basis));
}