// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
// 
//     private double[] power;
//     private double[] frequency;
//     private TimeUnit unit;
// 
//     public PowerSpectrum(double[] power, double[] frequency) {
//         this.power = power;
//         this.frequency = frequency;
//     }
// 
//     public double[] getPower() {
//         return power;
//     }
// 
//     public void setPower(double[] power) {
//         this.power = power;
//     }
// 
//     public double[] getFrequency() {
//         return frequency;
//     }
// 
//     public void setFrequency(double[] frequency) {
//         this.frequency = frequency;
//     }
// 
//     public TimeUnit getUnit() {
//         return unit;
//     }
// 
//     public void setIncomingUnit(TimeUnit unit) {
//         this.unit = unit;
//     }
// 
//     /**
//      * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
//      * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
//      * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
//      * the same values and that they increase with the same rate.
//      *
//      * @param ps {@code PowerSpectrum} to add.
//      */
//     public void add(PowerSpectrum ps) {
//         //Use the shorter length to avoid array out of bounds.
//         int shorterLength = Math.min(ps.getPower().length, this.power.length);
// 
//         for (var i = 0; i < shorterLength; i++) {
//             this.power[i] += ps.getPower()[i];
//         }
//     }
// }
// 
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
// 
// 	/**
// 	 * Calculates the power spectrum density (PSD) of the given
// 	 * rr-interval-data. The sampling rate is used to sample the interpolated
// 	 * rr-interval-data.
// 	 * 
// 	 * @param rr
// 	 *            rr-interval-data in seconds
// 	 * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// 	 */
// 	@Override
// 	public PowerSpectrum calculateEstimate(RRData rr) {
// 		double[] power = calculatePower(rr);
// 		double[] frequencies = calculateFrequencies(rr);
// 		
// 		return new PowerSpectrum(power, frequencies);
// 	}
// 	
// 	private double[] calculatePower(RRData rr) {
// 		double[] rrY = rr.getValueAxis();
// 		var calc = new AvgSampleSizeCalculator();
// 		double avgSampleSize = calc.process(rr).getValue();
// 		
// 		final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// 		final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
// 
// 		// Calculate the power spectral density of the Fourier Transform
// 		var betrag = new double[rrY.length];
// 		for (var i = 0; i < rrY.length; i++) {
// 			//Calculate power spectral density
// 			//Unit: s*s / Hz = s*s*s
// 			double abs = fftResult[i].abs();
// 			betrag[i] =  abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5); 
// 		}
// 		
// 		return betrag;
// 	}
// 	
// 	private double[] calculateFrequencies(RRData rr) {
// 		var calc = new AvgSampleSizeCalculator();
// 		double sampleFrequency = 1 / calc.process(rr).getValue();
// 		double maxSampleFrequency = 0.5 * sampleFrequency;
// 
// 		// Calculate Frequencies to corresponding power values
// 		// Frequency Steps in Hz
// 		double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// 		var frequencies = new double[rr.getTimeAxis().length];
// 
// 		for (var i = 0; i < frequencies.length; i++) {
// 			frequencies[i] = (frequencySteps) * i;
// 		}
// 		
// 		return frequencies;
// 	}
// }


import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
	 * 
	 * @return List of HRV-Parameters
	 */
	public List<HRVParameter> calculateParameters() {

		RRData filteredData = filters.manipulate(data);
		
		List<HRVParameter> allParams = new ArrayList<>();
		List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();

		for (HRVDataProcessor p : allCalculators) {
			allParams.add(p.process(filteredData));
		}

		if (containsOne(frequencyParams, parameters)) {
			allParams.addAll(calculateFrequencyParams(filteredData));
		}

		return allParams;
	}

	/**
	 * Calculates the power spectrum of the given data.
	 * 
	 * @param data
	 *            Data to calculate the power spectrum from
	 * @return power spectrum
	 */
	public PowerSpectrum getPowerSpectrum(RRData data) {
		RRData manipulatedData = frequencyDataManipulator.manipulate(data);
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/PowerSpectrum.java
// public class PowerSpectrum {
// 
//     private double[] power;
//     private double[] frequency;
//     private TimeUnit unit;
// 
//     public PowerSpectrum(double[] power, double[] frequency) {
//         this.power = power;
//         this.frequency = frequency;
//     }
// 
//     public double[] getPower() {
//         return power;
//     }
// 
//     public void setPower(double[] power) {
//         this.power = power;
//     }
// 
//     public double[] getFrequency() {
//         return frequency;
//     }
// 
//     public void setFrequency(double[] frequency) {
//         this.frequency = frequency;
//     }
// 
//     public TimeUnit getUnit() {
//         return unit;
//     }
// 
//     public void setIncomingUnit(TimeUnit unit) {
//         this.unit = unit;
//     }
// 
//     /**
//      * Adds the power of the given {@code PowerSpectrum} to this {@code PowerSpectrum}.
//      * If one of the {@code PowerSpectrum's} has more entries summation stops when the shorter
//      * {@code PowerSpectrum} reached its end. It is assumed, that the frequencies start at
//      * the same values and that they increase with the same rate.
//      *
//      * @param ps {@code PowerSpectrum} to add.
//      */
//     public void add(PowerSpectrum ps) {
//         //Use the shorter length to avoid array out of bounds.
//         int shorterLength = Math.min(ps.getPower().length, this.power.length);
// 
//         for (var i = 0; i < shorterLength; i++) {
//             this.power[i] += ps.getPower()[i];
//         }
//     }
// }
// 
// Path: lib/src/main/java/hrv/lib/hrv/calc/psd/StandardPowerSpectralDensityEstimator.java
// public class StandardPowerSpectralDensityEstimator implements PowerSpectralDensityEstimator {
// 
// 	/**
// 	 * Calculates the power spectrum density (PSD) of the given
// 	 * rr-interval-data. The sampling rate is used to sample the interpolated
// 	 * rr-interval-data.
// 	 * 
// 	 * @param rr
// 	 *            rr-interval-data in seconds
// 	 * @return power spectrum density (PSD) of RR-interval-data (unit is s squared)
// 	 */
// 	@Override
// 	public PowerSpectrum calculateEstimate(RRData rr) {
// 		double[] power = calculatePower(rr);
// 		double[] frequencies = calculateFrequencies(rr);
// 		
// 		return new PowerSpectrum(power, frequencies);
// 	}
// 	
// 	private double[] calculatePower(RRData rr) {
// 		double[] rrY = rr.getValueAxis();
// 		var calc = new AvgSampleSizeCalculator();
// 		double avgSampleSize = calc.process(rr).getValue();
// 		
// 		final var fft = new FastFourierTransformer(DftNormalization.STANDARD);
// 		final Complex[] fftResult = fft.transform(rrY, TransformType.FORWARD);
// 
// 		// Calculate the power spectral density of the Fourier Transform
// 		var betrag = new double[rrY.length];
// 		for (var i = 0; i < rrY.length; i++) {
// 			//Calculate power spectral density
// 			//Unit: s*s / Hz = s*s*s
// 			double abs = fftResult[i].abs();
// 			betrag[i] =  abs * abs / (rrY.length * (1 / avgSampleSize) * 0.5); 
// 		}
// 		
// 		return betrag;
// 	}
// 	
// 	private double[] calculateFrequencies(RRData rr) {
// 		var calc = new AvgSampleSizeCalculator();
// 		double sampleFrequency = 1 / calc.process(rr).getValue();
// 		double maxSampleFrequency = 0.5 * sampleFrequency;
// 
// 		// Calculate Frequencies to corresponding power values
// 		// Frequency Steps in Hz
// 		double frequencySteps = (2 * maxSampleFrequency) / (rr.getTimeAxis().length);
// 		var frequencies = new double[rr.getTimeAxis().length];
// 
// 		for (var i = 0; i < frequencies.length; i++) {
// 			frequencies[i] = (frequencySteps) * i;
// 		}
// 		
// 		return frequencies;
// 	}
// }


// Path: lib/src/main/java/hrv/lib/hrv/HRVLibFacade.java
import hrv.lib.hrv.calc.manipulator.*;
import hrv.lib.hrv.calc.parameter.*;
import hrv.lib.hrv.calc.psd.PowerSpectrum;
import hrv.lib.hrv.calc.psd.StandardPowerSpectralDensityEstimator;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;

	 * 
	 * @return List of HRV-Parameters
	 */
	public List<HRVParameter> calculateParameters() {

		RRData filteredData = filters.manipulate(data);
		
		List<HRVParameter> allParams = new ArrayList<>();
		List<HRVDataProcessor> allCalculators = getAllHRVDataProcessors();

		for (HRVDataProcessor p : allCalculators) {
			allParams.add(p.process(filteredData));
		}

		if (containsOne(frequencyParams, parameters)) {
			allParams.addAll(calculateFrequencyParams(filteredData));
		}

		return allParams;
	}

	/**
	 * Calculates the power spectrum of the given data.
	 * 
	 * @param data
	 *            Data to calculate the power spectrum from
	 * @return power spectrum
	 */
	public PowerSpectrum getPowerSpectrum(RRData data) {
		RRData manipulatedData = frequencyDataManipulator.manipulate(data);
		var estimator = new StandardPowerSpectralDensityEstimator();