1% B = TransformToOnes (clovec)
3% Returns
the similarity transformation matrix that
4% converts
the given
column vector to a vector of ones.
5% It works even
if clovec has zero entries.
9% clovec : matrix, shape(M,1)
10% The original closing vector
14% B : matrix, shape(M,M)
15% The matrix by which B*clovec = ones holds
17function B = TransformToOnes (clovec)
19 % construct permutation matrix to move at least one non-zero element to
the first position
20 % to acchieve it,
the code below sorts it in a reverse order
23 [~,ix] = sort(-clovec);
30 % construct transformation matrix B
for which B*rp=1 holds
33 B(i,1:i) = 1.0 / sum(cp(1:i,1));
35 % construct matrix B
for which B*r=1 holds