source: CIVL/examples/omp/m4ri/tests/testing.c

main
Last change on this file 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: 899 bytes
Line 
1#include "testing.h"
2
3mzd_t *mzd_init_test_matrix_random(rci_t M, rci_t N, rci_t m, rci_t n, word pattern, mzd_t **A) {
4 *A = mzd_init(M, N);
5
6 for(rci_t i=0; i<M; i++) {
7 for(rci_t j=0; j<(*A)->width; j++) {
8 (*A)->rows[i][j] = pattern;
9 }
10 }
11
12 mzd_t* a = mzd_init_window(*A, 0, 0, m, n);
13 mzd_randomize(a);
14
15 return a;
16}
17
18void mzd_free_test_matrix_random(mzd_t *A, mzd_t *a) {
19 mzd_free(a);
20 mzd_free(A);
21}
22
23int mzd_check_pattern(mzd_t *A, rci_t m, rci_t n, word pattern) {
24
25 for(rci_t i=0; i<A->nrows; i++) {
26 if (i >= m) {
27 for(rci_t j=0; j<A->width; j++)
28 if(A->rows[i][j] ^ pattern) {
29 return 1;
30 }
31 } else {
32 if ((A->rows[i][n/m4ri_radix] ^ pattern) & ~A->high_bitmask )
33 return 1;
34
35 for(rci_t j=n/m4ri_radix+1; j<A->width; j++)
36 if(A->rows[i][j] ^ pattern) {
37 return 1;
38 }
39 }
40 }
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.