~ubuntu-branches/ubuntu/raring/glmark2/raring

« back to all changes in this revision

Viewing changes to src/libmatrix/test/inverse_test.cc

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2012-08-21 15:38:09 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120821153809-bwux72bat8qp2n5v
Tags: 2012.08-0ubuntu1
* New upstream release 2012.08 (LP: #1039736)
  - Avoid crashing if gl used is not >= 2.0 (LP: #842279)
* Bumping dh compatibility level to v9
* debian/control:
  - Update Standards-Version to 3.9.3.
  - Add libjpeg-dev build dependency.
  - Use libegl1-x11-dev as an build-dep alternative instead of libegl1-dev.
  - Update description of glmark2-data binary package.
* debian/copyright:
  - Refresh copyright based on the current upstrem version
* debian/rules:
  - Clean compiled python code from unpacked waflib/ directory, as
    described in http://wiki.debian.org/UnpackWaf

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (c) 2010 Linaro Limited
 
3
//
 
4
// All rights reserved. This program and the accompanying materials
 
5
// are made available under the terms of the MIT License which accompanies
 
6
// this distribution, and is available at
 
7
// http://www.opensource.org/licenses/mit-license.php
 
8
//
 
9
// Contributors:
 
10
//     Jesse Barker - original implementation.
 
11
//
 
12
#include <iostream>
 
13
#include "libmatrix_test.h"
 
14
#include "inverse_test.h"
 
15
#include "../mat.h"
 
16
 
 
17
using LibMatrix::mat2;
 
18
using LibMatrix::mat3;
 
19
using LibMatrix::mat4;
 
20
using std::cout;
 
21
using std::endl;
 
22
 
 
23
void
 
24
MatrixTest2x2Inverse::run(const Options& options)
 
25
{
 
26
    mat2 m;
 
27
 
 
28
    if (options.beVerbose())
 
29
    {
 
30
        cout << "Starting with mat2 (should be identity): " << endl << endl;
 
31
        m.print();
 
32
    }
 
33
 
 
34
    m[0][1] = -2.5;
 
35
    
 
36
    if (options.beVerbose())
 
37
    {
 
38
        cout << endl << "Matrix should now have (0, 1) == -2.500000" << endl << endl;
 
39
        m.print();
 
40
    }
 
41
    
 
42
    mat2 mi(m);
 
43
 
 
44
    if (options.beVerbose())
 
45
    {
 
46
        cout << endl << "Copy of previous matrix (should have (0, 1) == -2.500000)" << endl << endl;
 
47
        mi.print();
 
48
    }
 
49
 
 
50
    mi.inverse();
 
51
 
 
52
    if (options.beVerbose())
 
53
    {
 
54
        cout << endl << "Inverse of copy: " << endl << endl;
 
55
        mi.print();
 
56
    }
 
57
 
 
58
    mat2 i = m * mi;
 
59
 
 
60
    if (options.beVerbose())
 
61
    {
 
62
        cout << endl << "Product of original and inverse (should be identity): " << endl << endl;
 
63
        i.print();
 
64
    }
 
65
 
 
66
    mat2 ident;
 
67
    if (i == ident)
 
68
    {
 
69
        pass_ = true;
 
70
    }
 
71
}
 
72
 
 
73
void
 
74
MatrixTest3x3Inverse::run(const Options& options)
 
75
{
 
76
    mat3 m;
 
77
 
 
78
    if (options.beVerbose())
 
79
    {
 
80
        cout << "Starting with mat3 (should be identity): " << endl << endl;
 
81
        m.print();
 
82
    }
 
83
 
 
84
    m[1][2] = -2.5;
 
85
    
 
86
    if (options.beVerbose())
 
87
    {
 
88
        cout << endl << "Matrix should now have (1, 2) == -2.500000" << endl << endl;
 
89
        m.print();
 
90
    }
 
91
 
 
92
    mat3 mi(m);
 
93
 
 
94
    if (options.beVerbose())
 
95
    {
 
96
        cout << endl << "Copy of previous matrix (should have (1, 2) == -2.500000)" << endl << endl;
 
97
        mi.print();
 
98
    }
 
99
 
 
100
    mi.inverse();
 
101
 
 
102
    if (options.beVerbose())
 
103
    {
 
104
        cout << endl << "Inverse of copy: " << endl << endl;
 
105
        mi.print();
 
106
    }
 
107
 
 
108
    mat3 i = m * mi;
 
109
 
 
110
    if (options.beVerbose())
 
111
    {
 
112
        cout << endl << "Product of original and inverse (should be identity): " << endl << endl;
 
113
        i.print();
 
114
    }
 
115
 
 
116
    mat3 ident;
 
117
    if (i == ident)
 
118
    {
 
119
        pass_ = true;
 
120
    }
 
121
}
 
122
 
 
123
void
 
124
MatrixTest4x4Inverse::run(const Options& options)
 
125
{
 
126
    mat4 m;
 
127
 
 
128
    if (options.beVerbose())
 
129
    {
 
130
        cout << "Starting with mat4 (should be identity): " << endl << endl;
 
131
        m.print();
 
132
    }
 
133
 
 
134
    m[2][3] = -2.5;
 
135
    
 
136
    if (options.beVerbose())
 
137
    {
 
138
        cout << endl << "Matrix should now have (2, 3) == -2.500000" << endl << endl;
 
139
        m.print();
 
140
    }
 
141
 
 
142
    mat4 mi(m);
 
143
 
 
144
    if (options.beVerbose())
 
145
    {
 
146
        cout << endl << "Copy of previous matrix (should have (2, 3) == -2.500000)" << endl << endl;
 
147
        mi.print();
 
148
    }
 
149
 
 
150
    mi.inverse();
 
151
 
 
152
    if (options.beVerbose())
 
153
    {
 
154
        cout << endl << "Inverse of copy: " << endl << endl;
 
155
        mi.print();
 
156
    }
 
157
 
 
158
    mat4 i = m * mi;
 
159
 
 
160
    if (options.beVerbose())
 
161
    {
 
162
        cout << endl <<  "Product of original and inverse (should be identity): " << endl << endl;
 
163
        i.print();
 
164
    }
 
165
 
 
166
    mat4 ident;
 
167
    if (i == ident)
 
168
    {
 
169
        pass_ = true;
 
170
    }
 
171
}
 
172