source: CIVL/examples/omp/m4ri/tests/test_transpose.c@ bb03188

main test-branch
Last change on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * test_transpose.c
3 *
4 * Application to test functionality of mzd_transpose.
5 *
6 * Copyright (C) 2011 Carlo Wood <carlo@alinoe.com>
7 * RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
8 * Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include <m4ri/m4ri.h>
25
26int test_size[18] = {
27 1, 3, 4, 7, 8, 11, 16, 17, 32, 40, 64, 80, 128, 160, 192, 240, 256, 512
28};
29
30int test_transpose(int i)
31{
32 int failure = 0;
33 rci_t m = test_size[i];
34 printf("transpose m: %4d, n: ", m);
35 for (int j = 0; j < 18 && !failure; ++j) {
36 rci_t n = test_size[j];
37 printf("%d", n);
38 if (j != 17)
39 printf(",");
40 int size = m * n;
41 int loop_size = MAX(64 * 64 / size, 2);
42 for (int i = 0; i < loop_size && !failure; ++i)
43 {
44 mzd_t* A = mzd_init(m, n);
45 mzd_t* B = mzd_init(m, n);
46 mzd_randomize(A);
47 mzd_randomize(B);
48 mzd_t* C = mzd_add(NULL, A, B);
49 mzd_t* AT = mzd_init(n, m);
50 mzd_randomize(AT);
51 mzd_transpose(AT, A);
52 mzd_t* BT = mzd_transpose(NULL, B);
53 mzd_t* CT = mzd_add(NULL, AT, BT);
54 mzd_t* CTT = mzd_transpose(NULL, CT);
55 if (!mzd_equal(C, CTT))
56 ++failure;
57 mzd_free(A);
58 mzd_free(B);
59 mzd_free(C);
60 mzd_free(AT);
61 mzd_free(BT);
62 mzd_free(CT);
63 mzd_free(CTT);
64 }
65 }
66 printf(" ");
67 if (failure) {
68 printf("FAILED\n");
69 }
70 else
71 printf("passed\n");
72 return failure;
73}
74
75int main()
76{
77 int status = 0;
78
79 int m=3;
80 int n=64;
81
82 mzd_t* A = mzd_init(m, n);
83 mzd_t* B = mzd_init(m, n);
84 mzd_randomize(A);
85 mzd_randomize(B);
86 mzd_t* C = mzd_add(NULL, A, B);
87 mzd_t* AT = mzd_init(n, m);
88 mzd_randomize(AT);
89 mzd_transpose(AT, A);
90 mzd_t* BT = mzd_transpose(NULL, B);
91 mzd_t* CT = mzd_add(NULL, AT, BT);
92 mzd_t* CTT = mzd_transpose(NULL, CT);
93 if (!mzd_equal(C, CTT))
94 ++status;
95 mzd_free(A);
96 mzd_free(B);
97 mzd_free(C);
98 mzd_free(AT);
99 mzd_free(BT);
100 mzd_free(CT);
101 mzd_free(CTT);
102
103
104 /* for (int i = 0; i < 18; ++i) { */
105 /* status += test_transpose(i); */
106 /* } */
107
108 if (!status) {
109 printf("All tests passed.\n");
110 } else {
111 printf("TEST FAILED!\n");
112 return 1;
113 }
114
115 return 0;
116}
Note: See TracBrowser for help on using the repository browser.