source: CIVL/examples/omp/m4ri/tests/test_kernel.c@ a389857

main test-branch
Last change on this file since a389857 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*
3* M4RI: Linear Algebra over GF(2)
4*
5* Copyright (C) 2009 Martin Albrecht <M.R.Albrecht@rhul.ac.uk>
6*
7* Distributed under the terms of the GNU General Public License (GPL)
8* version 2 or higher.
9*
10* This code is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13* General Public License for more details.
14*
15* The full text of the GPL is available at:
16*
17* http://www.gnu.org/licenses/
18*
19********************************************************************/
20
21#include <m4ri/config.h>
22#include <stdlib.h>
23#include <m4ri/m4ri.h>
24
25int test_kernel_left_pluq(rci_t m, rci_t n) {
26 mzd_t* A = mzd_init(m, n);
27 mzd_randomize(A);
28
29 mzd_t *Acopy = mzd_copy(NULL, A);
30
31 rci_t r = mzd_echelonize_m4ri(A, 0, 0);
32 printf("kernel_left m: %4d, n: %4d, r: %4d ", m, n, r);
33 mzd_free(Acopy);
34 Acopy = mzd_copy(NULL, A);
35
36 mzd_t *X = mzd_kernel_left_pluq(A, 0);
37 if (X == NULL) {
38 printf("passed\n");
39 mzd_free(A);
40 mzd_free(Acopy);
41 return 0;
42 }
43
44 mzd_t *Z = mzd_mul(NULL, Acopy, X, 0);
45
46 int status = 1 - mzd_is_zero(Z);
47
48 if (!status)
49 printf("passed\n");
50 else
51 printf("FAILED\n");
52
53 mzd_free(A);
54 mzd_free(Acopy);
55 mzd_free(X);
56 mzd_free(Z);
57 return status;
58}
59
60int main() {
61 int status = 0;
62
63 srandom(17);
64
65 status += test_kernel_left_pluq( 2, 4);
66 status += test_kernel_left_pluq( 4, 1);
67 status += test_kernel_left_pluq( 10, 20);
68 status += test_kernel_left_pluq( 20, 1);
69 status += test_kernel_left_pluq( 20, 20);
70 status += test_kernel_left_pluq( 30, 1);
71 status += test_kernel_left_pluq( 30, 30);
72 status += test_kernel_left_pluq( 80, 1);
73 status += test_kernel_left_pluq( 80, 20);
74 status += test_kernel_left_pluq( 80, 80);
75
76 status += test_kernel_left_pluq( 4, 2);
77 status += test_kernel_left_pluq( 1, 4);
78 status += test_kernel_left_pluq(20, 10);
79 status += test_kernel_left_pluq( 1, 20);
80 status += test_kernel_left_pluq(20, 20);
81 status += test_kernel_left_pluq( 1, 30);
82 status += test_kernel_left_pluq(30, 30);
83 status += test_kernel_left_pluq( 1, 80);
84 status += test_kernel_left_pluq(20, 80);
85 status += test_kernel_left_pluq(80, 80);
86
87 status += test_kernel_left_pluq(10, 20);
88 status += test_kernel_left_pluq(10, 80);
89 status += test_kernel_left_pluq(10, 20);
90 status += test_kernel_left_pluq(10, 80);
91 status += test_kernel_left_pluq(70, 20);
92 status += test_kernel_left_pluq(70, 80);
93 status += test_kernel_left_pluq(70, 20);
94 status += test_kernel_left_pluq(70, 80);
95 status += test_kernel_left_pluq(770, 1600);
96 status += test_kernel_left_pluq(1764, 1345);
97
98 if (!status) {
99 printf("All tests passed.\n");
100 } else {
101 return 1;
102 }
103
104 return 0;
105}
Note: See TracBrowser for help on using the repository browser.