File: packed-example.sh

package info (click to toggle)
mcl 1%3A14-137-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 10,704 kB
  • ctags: 5,125
  • sloc: ansic: 53,217; sh: 4,448; perl: 3,967; makefile: 422
file content (69 lines) | stat: -rwxr-xr-x 2,548 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/local/bin/bash
set -e


prefix=$HOME/local

if [[ ! -e $prefix/lib/libimpala.a ]]; then
   echo "Set prefix so that prefix/lib/libimpala.a exists"
   false
fi

if [[ ! -e $prefix/include/mcl/impala/ivp.h ]]; then
   echo "Set prefix so that prefix/include/mcl/ exists"
   echo "and contains impala/ivp.h impala/ivptypes.h util/inttypes.h util/types.h"
   false
fi


cat <<EOC >mcx-test-packed.c

#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <errno.h>
#include <string.h>


#include "impala/ivp.h"

int main(int argc, char **argv)
   {  mclp small[12][4] = {  { { 1, 1.0 }, { 5, 1.0 }, { 6, 1.0 } , { 9, 1.0 } }
                           , { { 0, 1.0 }, { 2, 1.0 }, { 4, 1.0 } ,                 {-1, 1.0 } }
                           , { { 1, 1.0 }, { 3, 1.0 }, { 4, 1.0 } ,                 {-1, 1.0 } }
                           , { { 2, 1.0 }, { 7, 1.0 }, { 8, 1.0 } , {10, 1.0 } }
                           , { { 1, 1.0 }, { 2, 1.0 }, { 6, 1.0 } , { 7, 1.0 } }
                           , { { 0, 1.0 }, { 9, 1.0 },                              {-1, 1.0 } , {-1, 1.0 } }
                           , { { 0, 1.0 }, { 4, 1.0 }, { 9, 1.0 } ,                 {-1, 1.0 } }
                           , { { 3, 1.0 }, { 4, 1.0 }, { 8, 1.0 } , {10, 1.0 } }
                           , { { 3, 1.0 }, { 7, 1.0 }, {10, 1.0 } , {11, 1.0 } }
                           , { { 0, 1.0 }, { 5, 1.0 }, { 6, 1.0 } ,                 {-1, 1.0 } }
                           , { { 3, 1.0 }, { 7, 1.0 }, { 8, 1.0 } , {11, 1.0 } }
                           , { { 8, 1.0 }, {10, 1.0 },                              {-1, 1.0 } , {-1, 1.0 } }
                           }
   ;  long src_and_len[2]
   ;  long sizes[12] = { 4, 3, 3, 4, 4, 2, 3, 4, 4, 3, 4, 2 }
   ;  long i

   ;  mclp ivp = { 1, 1.0 }
   ;  for (i=0; i<12; i++)
      {  src_and_len[0] = i
      ;  src_and_len[1] = sizes[i]
                        /*  Write source node and number of neighbours specified; two longs */
      ;  if (2 != fwrite(src_and_len, sizeof src_and_len[0], 2, stdout))
         exit(13)
                        /*  A list of ivps (index value pairs), each containing a neighbour index and a weight */
      ;  if (sizes[i] != fwrite(small[i], sizeof ivp, sizes[i], stdout))
         exit(13)
   ;  }
      return 0
;  }
EOC

gcc -g -I$HOME/local/include/mcl -c mcx-test-packed.c
gcc -g -L$HOME/local/lib -limpala -o mcx-test-packed mcx-test-packed.o

./mcx-test-packed | mcxload -packed - -pack-cnum 12 -pack-rnum 12 -ri max