-
Notifications
You must be signed in to change notification settings - Fork 0
/
causet_edit_periodiclink.m
80 lines (78 loc) · 3.21 KB
/
causet_edit_periodiclink.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
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
function [ L, C ] = causet_edit_periodiclink( coordinates, coordinateranges, spacetime )
%CAUSET_EDIT_PERIODICLINK turns a causet with points given by COORDINATES
% into a spacelike periodic causet.
%
% Arguments:
% COORDINATES positions of the elements.
% COORDINATERANGES row vector for the maxima of the coordinates in each
% dimension.
%
% Optional arguments:
% SPACETIME specifies the type of spacetime.
% "Minkowski" flat spacetime with Euclidean coordinates for the
% spacelike dimensions.
%
% Copyright 2021, C. Minz. BSD 3-Clause License.
errorlevel = -0.001 * min( coordinateranges );
d = length( coordinateranges );
N = size( coordinates, 1 );
if nargin < 3
spacetime = 'Minkowski';
end
if strcmp( spacetime, 'Minkowski' )
% set Minkowski metric:
metrictime = zeros( d );
metrictime( 1, 1 ) = 1;
metric = 2 * metrictime - eye( d );
% set all boundary offsets for periodic repeat:
bndcount = 3^( d - 1 );
bndoffsets = zeros( bndcount, d );
for ibnd = 0 : ( bndcount - 1 )
bndoffset = zeros( 1, d );
bndpos = ibnd;
for id = 2 : d
bndoffset( id ) = ( mod( bndpos, 3 ) - 1 ) * coordinateranges( id );
bndpos = floor( bndpos / 3 );
end
bndoffsets( ibnd + 1, : ) = bndoffset;
end
% compute links for each possible boundary offset (including the set itself):
C = false( N );
L = false( N );
for j = 2 : N
Jcoord = coordinates( j, : );
for i = 1 : ( j - 1 )
Icoord = coordinates( i, : );
for jbnd = 1 : bndcount
Jshifted = Jcoord + bndoffsets( jbnd, : );
dcoordinates = Jshifted - Icoord;
causaldistanceIJ = dcoordinates * metric * transpose( dcoordinates );
if causaldistanceIJ >= errorlevel
C( i, j ) = true;
haslink = true;
for k = ( i + 1 ) : ( j - 1 )
for kbnd = 1 : bndcount
Kshifted = coordinates( k, : ) + bndoffsets( kbnd, : );
dcoordinates = Jshifted - Kshifted;
causaldistanceKJ = dcoordinates * metric * transpose( dcoordinates );
if causaldistanceKJ >= errorlevel
C( k, j ) = true;
end
if C( i, k ) && C( k, j )
haslink = false;
break;
end
end
if ( haslink == false )
break;
end
end
if haslink
L( i, j ) = true;
end
end
end
end
end
end
end