function [calcforward calcbackward calcconcs calcabs]=efa(obsdata,ncomp,noprocs)
% 13 July 2011
%

	norows=size(obsdata,1); % extracts number of rows in x
	nocolumns=size(obsdata,2);
	forward=zeros(norows,ncomp); % create zero-filled matrix with correct dims
	backward=forward; %ibid.

% parallelisable - not iterative
%tic
	for i=ncomp:norows %forward
%		if mod(i,10)==0
%			disp(i)
%		end
		tempsvd=svd(scale(obsdata(1:i,:)))' ;
		forward(i,:)=tempsvd(:,1:ncomp);
	end
%toc 6/3 s
%tic

	for m=0:(norows-ncomp)%		reverse
		i=((norows-ncomp+1)-m);
%		if mod(i,10)==0
%			disp(i)
%		end

		tempsvd=svd(scale(obsdata(i:norows,:)))'; 
		backward(i,:)=tempsvd(:,1:ncomp);
	end
%toc 6/3 s


% make forward linear - column after column, l->r
% inverse order of columns in backward
% then make separate matrices again?!
% $d returns the singular values from svd. default in octave
	calcconcs=zeros(norows,ncomp);
	calcforward=forward;
	calcbackward=backward;

	for row=1:norows
%		if mod(row,10)==0
%			disp(row)
%		end
		for col=1:ncomp;
				if mod(col,10)==0
					disp(col)
				end
				calcconcs(row,col)=min(calcforward(row,col), calcbackward(row,ncomp+1-col));
		end
	end
	calcabs=pinv(calcconcs)*obsdata;
end
