function[A]=change_n_sqrt_n(x)

%	change_n_sqrt_n.m                          
%
%	This will change the n-dim vector to one sqrt(n) x sqrt(n) matrix

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.            


size_x=size(x);



if size_x(1) == 1
	n=round(sqrt(size_x(2)));
	i=0;
	for j=1:n;
		for k=1:n;
			i=i+1;
		
				A(j,k) = x(i);
		
		end
	end		
elseif	size_x(2) == 1
	n=round(sqrt(size_x(1)));
	x=x';
	i=0;
	for j=1:n;
		for k=1:n;
			i=i+1;
		
				A(j,k) = x(i);
		
		end
	end	
	x=x';
else
	error('Input data is not a vector')
end

return;
