function write_vec_to_binary(v,fname)
	n = length(v);
	fp = fopen(fname,'w');
	fwrite(fp,n,'int32');
	for j=1:n
		fwrite(fp,v(j),'double');
	end
	fclose(fp);
end

