예제 #1
0
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
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
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");
}