%% BPS invariants for compact CY - Log degeneracies - template for all CY - Vietoris-Rips complex
%% Section 7 of the paper barcodes&walls

clc; 
clear; 
%close all;
%% BPS compact - Log degeneracies - CY template - Vietoris-Rips complex

%% set the parameters

max_dimension=2
max_filtration_value=7
num_divisions=100
over_integers=2

% create the set of points
load ('DTQuinticLog.mat')
point_cloud = DTQuinticLog;
size(point_cloud)

% create a Vietoris-Rips stream
stream=api.Plex4.createVietorisRipsStream(point_cloud,max_dimension,max_filtration_value,num_divisions);
num_simplices = stream.getSize()

%% get persistence algorithm over Z/2Z
persistence = api.Plex4.getModularSimplicialAlgorithm(max_dimension, over_integers);

% compute the intervals
intervals= persistence.computeIntervals(stream);

% create the barcode plots
options.filename = 'DTX5LogBarcodes';
options.max_filtration_value = max_filtration_value;
options.max_dimension = max_dimension - 1;
options.side_by_side = true;
options.caption='X5';
plot_barcodes(intervals, options);

% get the infinite barcodes
infinite_barcodes = intervals.getInfiniteIntervals();

% print out betti numbers array
betti_numbers_array = infinite_barcodes.getBettiSequence()