ok restored to compile and executability, but two problems remain:
1) the algorithm is still nonlinear in execution time
2) the answer is not of the right dimension and probably isn't correct.