4 #include <utl/SparseMatrix.h>
6 #include <tst/Verify.h>
7 #include <cppunit/extensions/HelperMacros.h>
13 #define ASSERT_CLOSE(x, y) CPPUNIT_ASSERT(Verify<CloseTo>(x, y))
14 #define ASSERT_CLOSE_EPS(x, y, eps) CPPUNIT_ASSERT(Verify<CloseTo>(x, y, eps))
15 #define ASSERT_EQUAL(x, y) CPPUNIT_ASSERT(Verify<Equal>(x, y))
16 #define ASSERT_NOT_EQUAL(x, y) CPPUNIT_ASSERT(Verify<Not<Equal> >(x, y))
17 #define ASSERT_ITERATOR_EQUAL(it, e, r, c, v) \
18 CPPUNIT_ASSERT(it != e); \
19 ASSERT_EQUAL(it.GetRow(), r); \
20 ASSERT_EQUAL(it.GetColumn(), c); \
36 CPPUNIT_TEST(TestAccess);
37 CPPUNIT_TEST(TestIterators);
38 CPPUNIT_TEST(TestOperators);
39 CPPUNIT_TEST(TestMultiplication);
40 CPPUNIT_TEST(TestNonSquareMultiplication);
41 CPPUNIT_TEST(TestNonSquareMultiplication2);
42 CPPUNIT_TEST(TestTranspose);
43 CPPUNIT_TEST_SUITE_END();
71 for (
int i = 0; i < rows; ++i)
72 for (
int j = 0; j < cols; ++j)
79 for (
int i = 0; i < rows; ++i)
80 for (
int j = 0; j < cols; ++j)
155 ASSERT_EQUAL(it(), 2 * mm[it.GetRow()][it.GetColumn()]);
161 ASSERT_EQUAL(it(), 3 * mm[it.GetRow()][it.GetColumn()]);
167 ASSERT_EQUAL(it(), 2 * mm[it.GetRow()][it.GetColumn()]);
182 a(0, 0) = 1;
a(0, 2) = 2;
183 a(1, 1) = 3;
a(1, 3) = 4;
184 a(2, 0) = 5;
a(2, 2) = 6;
185 a(3, 1) = 7;
a(3, 3) = 8;
189 b(0, 1) = 1;
b(0, 3) = -2;
190 b(1, 0) = 4;
b(1, 2) = -8;
191 b(2, 1) = 16;
b(2, 3) = -32;
192 b(3, 0) = 64;
b(3, 2) = -128;
198 c(0, 1) = 33;
c(0, 3) = -66;
199 c(1, 0) = 268;
c(1, 2) = -536;
200 c(2, 1) = 101;
c(2, 3) = -202;
201 c(3, 0) = 540;
c(3, 2) = -1080;
203 CPPUNIT_ASSERT(r == c);
212 a(0, 0) = 1;
a(0, 9) = 1;
213 a(1, 0) = 1;
a(1, 9) = 1;
217 b(0, 0) = 1;
b(0, 1) = 1;
218 b(9, 0) = 1;
b(9, 1) = 1;
225 t(0, 0) = 2; t(0, 1) = 2;
226 t(1, 0) = 2; t(1, 1) = 2;
232 CPPUNIT_ASSERT(td == c);
244 for (
int i = 0; i < n; ++i)
245 for (
int j = 0; j <
m; ++j) {
247 b(j, i) = -2 * i + j;
252 for (
int i = 0; i < n; ++i)
253 for (
int j = 0; j < n; ++j)
255 double(-2*m*i*j+(i-2*j)*(m-1)*m/2+(m-1)*m*(2*m-1)/6));
264 a(0, 0) = 1;
a(0, 2) = 2;
a(0, 9) = 1;
265 a(1, 1) = 3;
a(1, 3) = 4;
273 t(0, 0) = 1; t(2, 0) = 2; t(9, 0) = 1;
274 t(1, 1) = 3; t(3, 1) = 4;
277 CPPUNIT_ASSERT(t == at);
281 CPPUNIT_ASSERT(a == at);
#define ASSERT_ITERATOR_EQUAL(it, e, r, c, v)
Stream & OutputSparse(Stream &s, const SparseMatrix< T > &m, const typename SparseMatrix< T >::IndexType rows, const typename SparseMatrix< T >::IndexType columns, const char separator, const SparseType &sparse)
void TestNonSquareMultiplication2()
unsigned int GetNonEmptySize() const
void Transpose()
in-situ transpose
void TestNonSquareMultiplication()
Sparse container class for matrix data.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
void TestMultiplication()
#define ASSERT_EQUAL(x, y)
Iterator Find(const IndexType row, const IndexType column)