-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathbench-matobj-creation.g
More file actions
113 lines (96 loc) · 2.9 KB
/
bench-matobj-creation.g
File metadata and controls
113 lines (96 loc) · 2.9 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
ReadGapRoot("benchmark/matobj/bench.g");
# test for old-style matrix constructors, as reference
TestCreatingMatrix := function(ring)
PrintHeadline("NullMat");
MyBench(function()
local m, n, mat;
for m in [1..10] do
for n in [1..10] do
mat := NullMat(m, n, ring);
od;
od;
end);
PrintHeadline("IdentityMat");
MyBench(function()
local n, mat;
for n in [1..100] do
mat := IdentityMat(n, ring);
od;
end);
end;
# test for matriobj constructors
TestCreatingMatrixObj := function(filter, ring)
local example_mat;
example_mat := NewZeroMatrix(filter, ring, 1, 1);
PrintHeadline("NewZeroMatrix");
MyBench(function()
local m, n, mat;
for m in [1..10] do
for n in [1..10] do
mat := NewZeroMatrix(filter, ring, m, n);
od;
od;
end);
PrintHeadline("ZeroMatrix( filt, R, m, n )");
MyBench(function()
local m, n, mat;
for m in [1..10] do
for n in [1..10] do
mat := ZeroMatrix(filter, ring, m, n);
od;
od;
end);
PrintHeadline("ZeroMatrix( m, n, M )");
MyBench(function()
local m, n, mat;
for m in [1..10] do
for n in [1..10] do
mat := ZeroMatrix(m, n, example_mat);
od;
od;
end);
PrintHeadline("NewIdentityMatrix");
MyBench(function()
local n, mat;
for n in [1..100] do
mat := NewIdentityMatrix(filter, ring, n);
od;
end);
PrintHeadline("IdentityMatrix( filt, R, n )");
MyBench(function()
local n, mat;
for n in [1..100] do
mat := IdentityMatrix(filter, ring, n);
od;
end);
PrintHeadline("IdentityMatrix( n, M )");
MyBench(function()
local n, mat;
for n in [1..100] do
mat := IdentityMatrix(n, example_mat);
od;
end);
# TODO: NewMatrix
# TODO: Matrix
end;
RunMatTest := function(desc, ring)
Print("\n");
PrintBoxed(Concatenation("Testing ", desc));
TestCreatingMatrix(ring);
end;
RunMatObjTest := function(desc, filter, ring)
Print("\n");
PrintBoxed(Concatenation("Testing ", desc));
TestCreatingMatrixObj(filter, ring);
end;
RunMatTest("GF(257)", GF(257));
RunMatObjTest("GF(257) IsPlistMatrixRep", IsPlistMatrixRep, GF(257));
RunMatObjTest("GF(257) IsGenericMatrixRep", IsGenericMatrixRep, GF(257));
RunMatTest("Integers", Integers);
RunMatObjTest("integer IsPlistMatrixRep", IsPlistMatrixRep, Integers);
RunMatObjTest("integer IsGenericMatrixRep", IsGenericMatrixRep, Integers);
RunMatTest("Rationals", Rationals);
RunMatObjTest("rational IsPlistMatrixRep", IsPlistMatrixRep, Rationals);
RunMatObjTest("rational IsGenericMatrixRep", IsGenericMatrixRep, Rationals);
# TODO: other reps
# TODO: other compare with creating plist-of-plist