src/types/matrix.cpp

Tue, 15 Nov 2016 17:37:31 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Tue, 15 Nov 2016 17:37:31 +0200
changeset 1046
f4a7b56c7eb2
parent 1037
4a9185e94d78
child 1062
4119185b56ca
permissions
-rw-r--r--

Cleanup PartDownloader

1037
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
1 /*
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
3 * Copyright (C) 2013 - 2016 Teemu Piippo
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
4 *
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
8 * (at your option) any later version.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
9 *
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
13 * GNU General Public License for more details.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
14 *
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
17 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
18
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
19 #include "../basics.h"
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
20 #include "../format.h"
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
21 #include "matrix.h"
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
22
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
23 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
24 * @brief Matrix::Matrix
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
25 * Default-constructor for a matrix -- does not actually initialize the member values.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
26 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
27 Matrix::Matrix() {}
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
28
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
29 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
30 * @brief Matrix::Matrix
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
31 * @param values
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
32 * Initializes the matrix from a C array
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
33 * Note: the array must have (at least) 9 values!
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
34 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
35 Matrix::Matrix (double values[])
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
36 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
37 for (int i = 0; i < 9; ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
38 m_values[i] = values[i];
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
39 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
40
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
41 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
42 * @brief Matrix::Matrix
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
43 * @param fillvalue
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
44 * Constructs a matrix from a single fill value.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
45 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
46 Matrix::Matrix (double fillvalue)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
47 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
48 for (int i = 0; i < 9; ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
49 m_values[i] = fillvalue;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
50 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
51
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
52 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
53 * @brief Matrix::Matrix
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
54 * @param values
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
55 * Constructs a matrix from an initializer list.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
56 * Note: the initializer list must have exactly 9 values.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
57 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
58 Matrix::Matrix (const std::initializer_list<double>& values)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
59 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
60 if (values.size() == 9)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
61 memcpy (&m_values[0], values.begin(), sizeof m_values);
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
62 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
63
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
64 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
65 * @brief Matrix::dump
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
66 * Prints the matrix out.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
67 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
68 void Matrix::dump() const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
69 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
70 for (int i = 0; i < 3; ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
71 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
72 for (int j = 0; j < 3; ++j)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
73 print ("%1\t", m_values[i * 3 + j]);
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
74
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
75 print ("\n");
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
76 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
77 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
78
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
79 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
80 * @brief Matrix::toString
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
81 * @return a string representation of the matrix
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
82 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
83 QString Matrix::toString() const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
84 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
85 QString val;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
86
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
87 for (int i = 0; i < 9; ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
88 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
89 if (i > 0)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
90 val += ' ';
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
91
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
92 val += QString::number (m_values[i]);
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
93 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
94
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
95 return val;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
96 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
97
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
98 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
99 * @brief Matrix::zero
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
100 * Fills the matrix with zeros
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
101 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
102 void Matrix::zero()
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
103 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
104 memset (&m_values[0], 0, sizeof m_values);
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
105 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
106
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
107 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
108 * @brief Matrix::multiply
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
109 * @param other
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
110 * @return this matrix multiplied with @c other.
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
111 * @note @c a.mult(b) is not equivalent to @c b.mult(a)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
112 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
113 Matrix Matrix::multiply (const Matrix& other) const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
114 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
115 Matrix result;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
116 result.zero();
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
117
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
118 for (int i = 0; i < 3; ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
119 for (int j = 0; j < 3; ++j)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
120 for (int k = 0; k < 3; ++k)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
121 result[(i * 3) + j] += m_values[(i * 3) + k] * other[(k * 3) + j];
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
122
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
123 return result;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
124 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
125
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
126 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
127 * @brief Matrix::determinant
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
128 * @return the matrix's determinant
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
129 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
130 double Matrix::determinant() const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
131 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
132 return (value (0) * value (4) * value (8)) +
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
133 (value (1) * value (5) * value (6)) +
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
134 (value (2) * value (3) * value (7)) -
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
135 (value (2) * value (4) * value (6)) -
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
136 (value (1) * value (3) * value (8)) -
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
137 (value (0) * value (5) * value (7));
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
138 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
139
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
140 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
141 * @brief Matrix::operator ==
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
142 * @param other
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
143 * @return whether the two matrices are equal
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
144 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
145 bool Matrix::operator==(const Matrix& other) const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
146 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
147 for (int i = 0; i < countof(m_values); ++i)
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
148 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
149 if (not qFuzzyCompare(m_values[i], other.m_values[i]))
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
150 return false;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
151 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
152 return true;
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
153 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
154
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
155 /**
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
156 * @brief Matrix::operator !=
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
157 * @param other
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
158 * @return whether the two matrices are not equal
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
159 */
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
160 bool Matrix::operator!=(const Matrix& other) const
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
161 {
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
162 return not operator==(other);
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
163 }
4a9185e94d78 Moved matrix into new source/header pair in types/
Teemu Piippo <teemu@compsta2.com>
parents:
diff changeset
164

mercurial