%
% SVDMSC  Frobenius condition number of
%   scaled Vandermonde matrix (Vandermonde,
%   if R=1). The nodes are assumed in 
%   decreasing order,
%       x_1 > x_2 > ... > x_n
%
function condVsc=sVdMsc(dig,R,n,x)
syms V d D Vsc Vscsc sVsc sVscsc condVsc condVscsc
digits(dig);
for i=1:n
  for j=1:n
    if x(j)==vpa(0) & i==1
      V(i,j)=vpa(1);
    else
      V(i,j)=x(j)^vpa(i-1);
    end
  end
end
for i=1:n
  d(i)=1/R^vpa(i-1);
%  d(i)=1/abs(V(i,1));
%  d(i)=1/sum(abs(V(i,:)));
%  d(i)=1/sqrt(sum(V(i,:).^2));
end
D=diag(d);
Vsc=D*V;
%for j=1:n
%  d(j)=1/sum(abs(Vsc(:,j)));
%  d(j)=1/sqrt(sum(Vsc(:,j).^2));
%end
%D=diag(d);
%Vscsc=Vsc*D;
sVsc=svd(Vsc);
%sVscsc=svd(Vscsc);
if sum(abs(subs(imag(sVsc))))~=0
  subs(sVsc)
  error('Vsc has complex singular values')
  return
end
condVsc=sqrt(sum(sVsc.^2)*sum(sVsc.^(-2)));
%if sum(abs(subs(imag(sVscsc))))~=0
%  subs(sVscsc)
%  error('Vscsc has complex singular values')
%  return
%end
%condVsc=sqrt(sum(sVscsc.^2)*sum(sVscsc.^(-2)));
