-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrel.m
35 lines (32 loc) · 984 Bytes
/
rel.m
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
classdef rel
properties (SetAccess = public)
addTo;
coefficient;
order;
comps;
end
methods
function newAdd = rel(addTo, coefficient , order, comps )
newAdd.addTo = addTo ;
newAdd.coefficient = coefficient ;
newAdd.order = order ;
newAdd.comps = comps ;
end
function r = normalize(r)
if size(r.comps, 1) > 1
return;
end
oldComps = sort(r.comps);
newComps = [oldComps(1) ; 0];
for e = oldComps
if newComps(1, size(newComps, 2)) == e
newComps(2, size(newComps, 2)) = newComps(2, size(newComps, 2)) + 1;
else
newComps(1, size(newComps, 2) + 1) = e;
newComps(2, size(newComps, 2)) = 1;
end
end
r.comps = newComps;
end
end
end