コード例 #1
0
ファイル: matrix_add1.cpp プロジェクト: MridulS/csympy
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;
}
コード例 #2
0
ファイル: matrix_add2.cpp プロジェクト: joedborg/csympy
int main(int argc, char* argv[])
{
    Teuchos::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
0
ファイル: test_printing.cpp プロジェクト: MridulS/csympy
void test_matrix()
{
    DenseMatrix A = DenseMatrix(2, 2, {integer(1), integer(0), integer(0),
        integer(1)});
    assert(A.__str__() == "[1, 0]\n[0, 1]\n");
}