function result = logsum(logv) len = length(logv); if (len<2); error('Subroutine logsum cannot sum less than 2 terms.'); end; % First two terms if (logv(2)