function [A,bu,D] = Diagonal_Matrix_Scaling(A,bu)
%function [A,bu,D] = Diagonal_Matrix_Scaling(A,bu) 
%  Diagonal_Matrix_Scaling performs row scaling on input matrix A and bu
%  by using the l2-norm of each row of A. It then returns the scaled
%  inputs A and bu, as well as the vector D that corresponds with each
%  row norm in case recovery of the original problem is desirable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INPUT and problem description:
% A - Initial m x n matrix
% bu vector in R^m coresponding to A matrix for constraints
% P is m by n vertices of polytope
%
% OUTPUT
% A - Scaled matrix A with row norm 1
% bu - Scaled constraints bu
% D - vector of norm(A(i,:)), i = {1,...,m}

[m,~] = size(A);

for i = 1:m
    D(i) = norm(A(i,:));
    A(i,:) = A(i,:)/D(i);
    bu(i) = bu(i)/D(i);
end

end
