Floor[1806/16]*16

SetDirectory["/home/campus03/struther/Desktop/Link to Courses/5580/CodeFragments/LinearAlgebra/SparseMatVecMul"]
A=Import["bcsstk14.mtx.gz"]
BlockSize=16;
n=Floor[Length[A]/BlockSize] BlockSize;
A=A[[1;;n,1;;n]]
ToCRSFile[A_SparseArray,FileName_String]:= Module[
{fp,n,m,nz,rules,i, nzRow,ColIndices,ColValues},
fp=OpenWrite[FileName,
FormatType->CForm];
{n,m}=Dimensions[A];
nz=Length[ArrayRules[A]]-1;
Map[Write[fp,#]&,{n,m,nz}];
Do[
rules=Drop[ArrayRules[A[[i]]],-1];
nzRow=Length[rules];
ColIndices=rules[[All,1,1]]-1; (* -1 for C addressing *)
ColValues=rules[[All,2]];
Write[fp, nzRow];
Map[Write[fp,#]&,Flatten[Transpose[{ColIndices,ColValues}]]];
{nzRow,ColIndices,ColValues},
{i,1 Length[A]}
];
Close[fp]
]
ToCRSFile[A,"A.txt"];
u=Cos[Range[0.0,π,π/(n-1)]];
ListPlot[u]
x=LinearSolve[A, Cos[Range[0.0,π,π/(n-1)]]];
ListPlot[x,
PlotRange->All]
Norm[A.x-u]
Export["x.txt",x, "TSV"]

RowLengths=Table[
Length[ArrayRules[A[[i]]]],
{i,1, Length[A]}
]

NewA=A[[Ordering[RowLengths]]]
ToCRSFile[NewA,"NewA.txt"];
Newu=Cos[Range[0.0,π,π/(n-1)]];
Newx=LinearSolve[NewA, Newu];
Export["Newx.txt",x, "TSV"]

NIter=100;
hmm=Timing[Table[A.u;,{NIter}];][[1]]/NIter
hmm/0.000370581