function [error] =  Error(X,V,V_inv,p,boundaries);

[d,n] = size(X);
[foo,N] = size(boundaries);
error = 0;

for i = 1 : N-1
 X_ = X(:,[boundaries(i):boundaries(i+1)-1]);
 error = error + BasisError(X_,V,V_inv,representative(X_,p),p);
end;
