%==================================================================
%
%	change_n_sqrt_n.m
%
%	Markus Junghoefer	[1995]
%   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.                                                                      
%
%
%	This will change the n-dim vector to one sqrt(n) x sqrt(n) matrix
%	
%	Function definition

	function[A]=change_n_sqrt_n(x)

%=================================================================

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;
