DB and 400G and minor changes
This commit is contained in:
@@ -54,10 +54,12 @@ classdef MLSE
|
||||
obj.DIR(1:DIR_nonzero(1)-1) = [];
|
||||
end
|
||||
|
||||
if length(obj.DIR) == 1
|
||||
if isscalar(obj.DIR)
|
||||
obj.DIR = [0 obj.DIR];
|
||||
end
|
||||
|
||||
obj.DIR = flip(obj.DIR);
|
||||
|
||||
% RMS normalization of input data
|
||||
data_in = data_in ./ rms(data_in);
|
||||
|
||||
@@ -95,10 +97,65 @@ classdef MLSE
|
||||
% i.e. match the rms values of data_in to noise_free_received
|
||||
if isreal(data_in)
|
||||
if obj.M == round(obj.M)
|
||||
data_in = data_in * rms(noise_free_received,'all','omitnan');
|
||||
data_in = data_in * rms(noise_free_received(noise_free_received ~= inf),'all','omitnan');
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
%
|
||||
% %% Optimized
|
||||
% % Preallocate and initialize variables
|
||||
% data_out = NaN(size(data_in)); % output vector
|
||||
% sum_path_metrics_res = zeros(length(states), length(data_in));
|
||||
% path_idx = zeros(length(states), length(data_in));
|
||||
%
|
||||
% % Precompute repmat size
|
||||
% num_states = length(states);
|
||||
% num_signals = numel(noise_free_received);
|
||||
%
|
||||
% % First trellis path (initialize)
|
||||
% sum_path_metrics = zeros(num_states, num_states);
|
||||
% path_metrics = (abs(data_in(1) - noise_free_received)).^2; % Use broadcasting instead of repmat
|
||||
% sum_path_metrics = sum_path_metrics + path_metrics; % Compute initial path metrics
|
||||
%
|
||||
% [sum_path_metrics_res(:,1), path_idx(:,1)] = min(sum_path_metrics, [], 2); % Best path for first step
|
||||
%
|
||||
% % Preallocate path_metrics and sum_path_metrics to avoid reallocating in each loop
|
||||
% path_metrics = zeros(num_states, num_signals);
|
||||
%
|
||||
% % Loop over remaining trellis paths
|
||||
% for n = 2:length(data_in)
|
||||
% % Avoid reallocation of sum_path_metrics, reuse the same matrix and update
|
||||
% previous_sum_path_metrics = sum_path_metrics_res(:,n-1).'; % Transpose once for broadcasting
|
||||
% sum_path_metrics = repmat(previous_sum_path_metrics, num_states, 1); % Avoid dynamic resizing
|
||||
%
|
||||
% % Calculate path metrics using broadcasting
|
||||
% path_metrics = (abs(data_in(n) - noise_free_received)).^2; % Avoid repmat
|
||||
%
|
||||
% % Update sum path metrics
|
||||
% sum_path_metrics = sum_path_metrics + path_metrics;
|
||||
%
|
||||
% % Find the best path for each state and store results
|
||||
% [sum_path_metrics_res(:,n), path_idx(:,n)] = min(sum_path_metrics, [], 2);
|
||||
% end
|
||||
%
|
||||
% %% Traceback
|
||||
% ideal_path = NaN(1, length(data_in)+1); % Preallocate ideal path
|
||||
% [~, ideal_path(length(data_in)+1)] = min(sum_path_metrics_res(:,length(data_in))); % Start from final state
|
||||
%
|
||||
% % Trace back through trellis
|
||||
% for h = length(data_in):-1:1
|
||||
% ideal_path(h) = path_idx(ideal_path(h+1),h); % Follow the best path back
|
||||
% end
|
||||
%
|
||||
% % Extract the output indices
|
||||
% idx_out = ideal_path(2:end);
|
||||
|
||||
|
||||
|
||||
|
||||
% OLD
|
||||
% initilaize the output vector
|
||||
data_out = NaN(size(data_in));
|
||||
|
||||
@@ -132,12 +189,17 @@ classdef MLSE
|
||||
ideal_path(h) = path_idx(ideal_path(h+1),h);
|
||||
end
|
||||
|
||||
idx_out = ideal_path(1:length(data_in));
|
||||
idx_out = ideal_path(2:length(data_in)+1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if obj.duobinary_output
|
||||
%use duobinary encoder, output is already scaled inside this
|
||||
%one
|
||||
data_out = Duobinary().encode(first_sym(idx_out));
|
||||
|
||||
else
|
||||
%
|
||||
data_out(1:length(data_in)) = first_sym(idx_out);
|
||||
|
||||
Reference in New Issue
Block a user