%% BPS N=4 Dyons and mock modular forms - Rips-Vietoris complex - TEMPLATE
%% Section 8 of the paper barcodes&walls

clc; 
clear; 
close all;
%% BPS N=4 Dyons -  TEMPLATE

%% set the parameters

max_dimension=3
max_filtration_value=5.4
num_divisions=100
over_integers=2

% create the set of points - single centered degeneracies from Psi_F
%load ('N4microLog.mat')
%point_cloud = N4microLog;
%size(point_cloud)

% create the set of points - single and 2 center degeneracies from Psi
load ('N4totSLog.mat')
point_cloud = N4totSLog;
size(point_cloud)

% create the set of points - single center degeneracies including modular
% images
%load ('N4microEXLog.mat')
%point_cloud = N4microEXLog;
%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 = 'N4microLogBarcodes';
options.filename = 'N4totSLogBarcodes';
%options.filename = 'N4microEXLogBarcodes';
options.max_filtration_value = max_filtration_value;
options.max_dimension = max_dimension - 1;
options.side_by_side = true;
options.caption='Full degeneracies';
plot_barcodes(intervals, options);

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

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