/* This is a replacement for log() that doesn't return .NaNs This is useful in intermediate iterations in nonlinear estimation. Reference: A.R. Gallant, 1987, Nonlinear Statistical Models, pg. 319. Michael.Creel@uab.es 13/3/2000 */ slog(const z) { decl a, b, c, t1, t2, t3, y, n; a = - 299.999999999999886; b = 5667638086.9808321; c = - 28288190434904165; t1 = z .<= 0; t1 = t1 .* (a + b * z); t2 = (0. < z) .&& (z .<= 1e-7); t2 = t2 .* (a + b * z + c * z .^ 2); t3 = z .> 1e-7; n = sizer(z); y = t3 .* z + (1 - t3) .* ones(n, 1); t3 = t3 .* log(y); y = t1 + t2 + t3; return y; }