OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt22.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#include "stdtest.h"
7
 
8
template <size_t NX, size_t NY, typename T>
9
void TestMatrix (void)
10
{
11
    matrix<NX,NY,T> m1, m2;
12
    load_identity (m1);
13
    cout << "load_identity(m1)"
14
            "\n    m1 = " << m1;
15
    m2 = m1;
16
    cout << "\nm1 = m2"
17
            "\n    m2 = " << m2;
18
    m1 += m2;
19
    cout << "\nm1 += m2"
20
            "\n    m1 = " << m1;
21
    m1 /= 2;
22
    cout << "\nm1 /= 2"
23
            "\n    m1 = " << m1;
24
    m1 = m1 * m2;
25
    cout << "\nm1 = m1 * m2"
26
            "\n    m1 = " << m1;
27
    m1 += 3;
28
    cout << "\nm1 += 3"
29
            "\n    m1 = " << m1;
30
    load_identity (m2);
31
    m2 *= 2;
32
    m1 = m1 * m2;
33
    cout << "\nm1 *= I(2)";
34
    cout << "\n    m1 = " << m1;
35
    iota (m1.begin(), m1.end(), 1);
36
    cout << "\nm1 = iota(1)"
37
            "\n    m1 = " << m1;
38
    cout << "\n    m1 row [1] = " << m1.row(1);
39
    cout << "\n    m1 column [2] = " << m1.column(2);
40
    m1 = m1 * m2;
41
    cout << "\nm1 *= I(2)"
42
            "\n    m1 = " << m1;
43
    typename matrix<NX,NY,T>::column_type v, vt;
44
    iota (v.begin(), v.end(), 1);
45
    cout << "\nv = iota(1)"
46
            "\n    v = " << v;
47
    load_identity (m2);
48
    m2 *= 2;
49
    for (uoff_t y = 0; y < NY - 1; ++ y)
50
        m2[NY - 1][y] = 1;
51
    cout << "\nm2 = I(2) + T(1)"
52
            "\n    m2 = " << m2;
53
    vt = v * m2;
54
    cout << "\nvt = v * m2"
55
            "\n    vt = " << vt << endl;
56
}
57
 
58
void TestMatrixAlgorithms (void)
59
{
60
    cout << "========================================\n"
61
            "Testing 4x4 int matrix:\n"
62
            "========================================\n";
63
    TestMatrix<4,4,int>();
64
    cout << "========================================\n"
65
            "Testing 4x4 float matrix:\n"
66
            "========================================\n";
67
    cout.set_precision (1);
68
    TestMatrix<4,4,float>();
69
}
70
 
71
StdBvtMain (TestMatrixAlgorithms)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.