function fsum = fchecksum(var)
%fsum = fchecksum(var)
%generates a floating-point checksum of the specified variable
%

if nargin<1 
    var = [];
end

fsum = size(var,1);
for i=2:ndims(var)
    fsum = (fsum + size(var,i).^2) / ( size(var,i) + 1 );
end

weights = 1.1:0.1:1+numel(var)*0.1;
if numel(var)>1,
    weights(1:2:end) = weights(1:2:end) * -1;
end
nans = isnan(var);
var(nans)=weights(nans);
fsum = fsum + sum(var(:).*weights(:));
