LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
TransformToOnes.m
1% B = TransformToOnes (clovec)
2%
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.
6%
8% ----------
9% clovec : matrix, shape(M,1)
10% The original closing vector
11%
12% Returns
13% -------
14% B : matrix, shape(M,M)
15% The matrix by which B*clovec = ones holds
16
17function B = TransformToOnes (clovec)
18
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
21 m = length(clovec);
22
23 [~,ix] = sort(-clovec);
24 P = zeros(m);
25 for i=1:m
26 P(i,ix(i)) = 1.0;
27 end
28 cp = P*clovec;
29
30 % construct transformation matrix B for which B*rp=1 holds
31 B = zeros(m);
32 for i=1:m
33 B(i,1:i) = 1.0 / sum(cp(1:i,1));
34 end
35 % construct matrix B for which B*r=1 holds
36 B = B*P;
37end
Definition Station.m:245