File: mindist.g

package info (click to toggle)
gap-scscp 2.3.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,704 kB
  • sloc: xml: 1,247; sh: 389; makefile: 19
file content (83 lines) | stat: -rw-r--r-- 2,509 bytes parent folder | download | duplicates (7)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
############################################################################
#
# Demo of  Parallelised method to compute minimal distance for linear codes
#
LoadPackage("scscp");
LoadPackage("guava");
ReadPackage("scscp", "example/mindist.gi");

# The next function is supposed to compute the runtime in microseconds
# after IO_gettimeofday() was called before and after computation
#
runtime:=function(t1,t2) return 1000000*(t2.tv_sec-t1.tv_sec)+t2.tv_usec-t1.tv_usec; end;


############################################################################                           
#
# Code snippets for SCSCPservers (uncomment as needed)
#

# SCSCPservers:=List( [26133..26140], i-> [ "localhost",  i ] );

# SCSCPservers := Concatenation( 
# List( [26133..26140], i-> [ "localhost",  i ] ),
# List( [26133..26140], i-> [ "ladybank02",  i ] ),
# List( [26133..26140], i-> [ "ladybank01",  i ] ) );

SCSCPservers:=List( [26133..26134], i-> [ "localhost",  i ] );

############################################################################ 

# if IN_SCSCP_BINARY_MODE is false, then XML encoding is used
IN_SCSCP_BINARY_MODE:=true;

# Switch off OpenMath display
SetInfoLevel(InfoSCSCP,0);

# Show how the work is distributed and which values are returned
SetInfoLevel(InfoMasterWorker,5);

# Read sample codes
ReadPackage("scscp", "example/code1.g");
ReadPackage("scscp", "example/code2.g");
ReadPackage("scscp", "example/code3.g");

# WHY USE PICKLING?

curtime1:=IO_gettimeofday();
EvaluateBySCSCP("Identity",[linear_code_example_1],"localhost",26133);;
curtime2:=IO_gettimeofday();
runtime(curtime1,curtime2);

curtime1:=IO_gettimeofday();
IO_UnpickleFromString( EvaluateBySCSCP( "IO_UnpickleStringAndPickleItBack", 
    [ IO_PickleToString(linear_code_example_1) ], "localhost", 26133 ).object );;
curtime2:=IO_gettimeofday();
runtime(curtime1,curtime2);

# EXAMPLE 1
C:=GeneratorMatCode(linear_code_example_1,GF(2));;
curtime1:=IO_gettimeofday();
MinimumDistance(C); # answer = 6
curtime2:=IO_gettimeofday();
runtime(curtime1,curtime2);

# EXAMPLE 2

C:=GeneratorMatCode(linear_code_example_2,GF(2));;
curtime1:=IO_gettimeofday();
MinimumDistance(C); # answer = 6
curtime2:=IO_gettimeofday();
runtime(curtime1,curtime2);

# EXAMPLE 3

C:=GeneratorMatCode(linear_code_example_3,GF(2));;
curtime1:=IO_gettimeofday();
MinimumDistance(C); 
curtime2:=IO_gettimeofday();
runtime(curtime1,curtime2);

############################################################################                           
##
#E