-
Notifications
You must be signed in to change notification settings - Fork 0
/
causet_edit_link.m
59 lines (57 loc) · 2.05 KB
/
causet_edit_link.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
function [ L, C ] = causet_edit_link( coordinates, spacetime )
%CAUSET_EDIT_LINK sets the links for a causet with event COORDINATES in a
% SPACETIME with spacetime dimensions and ranges specified by
% COORDINATERANGES.
%
% Arguments:
% COORDINATES positions of the elements.
%
% Optional aguments:
% SPACETIME specifies the type of spacetime.
% 'Minkowski' flat spacetime with Euclidean coordinates for the
% spacelike dimensions.
%
% Returns:
% L logical upper triangular (direct) links matrix.
% C logical upper triangular causal matrix.
%
% Copyright 2021, C. Minz. BSD 3-Clause License.
N = size( coordinates, 1 );
d = size( coordinates, 2 );
if nargin < 2
spacetime = 'Minkowski';
end
if strcmp( spacetime, 'Minkowski' )
% set Minkowski metric:
metric = -eye( d );
metric( 1, 1 ) = 1;
% compute links:
C = false( N );
L = false( N );
for j = 2 : N
Jcoord = coordinates( j, : );
for i = 1 : ( j - 1 )
dcoordinates = Jcoord - coordinates( i, : );
causaldistanceIJ = dcoordinates * metric * transpose( dcoordinates );
if causaldistanceIJ >= 0
C( i, j ) = true;
haslink = true;
for k = ( i + 1 ) : ( j - 1 )
dcoordinates = Jcoord - coordinates( k, : );
causaldistanceKJ = dcoordinates * metric * transpose( dcoordinates );
if causaldistanceKJ >= 0
C( k, j ) = true;
end
if C( i, k ) && C( k, j )
haslink = false;
break;
end
end
if haslink
L( i, j ) = true;
end
end
end
end
end
end