Hyper Power algorithms

Two ideas.  
1) As an approximate sub roblem solver for a block algorithm.
2) As simple preconditioner.  Including sparse vector idea.

I am implementing the q=2 versions of Stanmirovic [1].

Clear[HyperPower,A,k,q]
HyperPower[A_,k_,q_]:= Module[
{m,n,Id,α,Y,T,M,j},
{m,n}=Dimensions[A];
Id =IdentityMatrix[n];
α=2/Tr[Transpose[A].A];
Y=α Transpose[A];
Do[
T[0]=Id - Y.A;
Do[T[j]=T[0].T[j-1],{j,1,q-1}];
M=Id+Sum[T[j],{j,0,q-1}];
Y=Normal[M.Y],
{k}];
Y
]

Clear[q]
n=32;
NIter=12;
A=RandomReal[{0,1},{n,n}]+ DiagonalMatrix[RandomReal[{2,3},{n}]];
PInvA=PseudoInverse[A];
ListLogPlot[
Table[
B=HyperPower[A,k,q];
Norm[B-PInvA],
{q,2,12},
{k, 1,NIter}
],
Mesh->All,
Joined->True,
PlotRange->All
]

Clear[q]
n=32;
NIter=12;
A=RandomReal[{0,1},{n,n}]+ DiagonalMatrix[RandomReal[{2,3},{n}]];
A=A+Transpose[A];
PInvA=PseudoInverse[A];
evals=Eigenvalues[PInvA]
ListLogPlot[
Table[
B=HyperPower[A,k,q];
Norm[B-PInvA],
{q,2,4},
{k, 1,NIter}
],
Mesh->All,
Joined->True
]
Table[
B=HyperPower[A,k,q];
ListPlot[{Eigenvalues[B]/evals},
PlotRange->{-3,3}],
{q,2,12},
{k, 1,NIter}
]

I have a random selection of mat market stuff here.

SetDirectory["/home/campus03/struther/Desktop/Link to Courses/5580/Stuff/"]
FileNames[]

A= Import["nos5.mtx.gz"]
{m,n}=Dimensions[A];
Timing[PInvA=PseudoInverse[A];]
Norm[A.PInvA-IdentityMatrix[m]]
evals=Eigenvalues[PInvA,50];
NIter=21;
ListLogPlot[
Table[
B=HyperPower[A,k,q];
Norm[B-PInvA],
{q,2,2},
{k, 1,NIter}
],
Mesh->All,
Joined->True,
PlotRange->All
]

Norm[A-Transpose[A]]

ListLogPlot[{
Eigenvalues[PInvA],
Eigenvalues[B]
}]

SparsifyVector[Vec_, nz_]:= Module[
{rules},
Sort[

n=1000;
nz=50;
NZ=10;
coords=RandomSample[Range[1,n],nz];
vals=RandomReal[NormalDistribution[ 0,23],{nz}];
b=SparseArray[ Table[coords[[i]]->vals[[i]],{i, nz}]];
Barney=ArrayRules[b];
ListLogPlot[
Table[
((Norm[SparseArray[Barney[[Ordering[ArrayRules[b],NZ,Abs[#1[[2]]]>Abs[#2[[2]]]&]]]]])/(Norm[b])),
{NZ,1,nz}],
PlotRange->All
]

Barney[[24]]

Order

FullForm[{246}->0.5232769192040148`]

FullForm[{698}->0.9454930310081582`]

A
B=A.Transpose[A];
B

195654/(1806.^2)
195654/63454.