|
From: | John W. Eaton |
Subject: | Matlab compatibility of assert (was: Re: assert () taking long time) |
Date: | Tue, 24 Sep 2013 09:47:38 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 |
On 09/23/2013 05:31 PM, Rik wrote:
I just checked in a changeset which avoids pre-calculating the error message which may never get used (~16% speed-up). I also did a little profiling and changed a repmat construction to a const*ones(...) (~23% speed-up). So, overall maybe a 33% improvement. I think if you want to substitute a much simpler, albeit faster, version of assert you should make it a local change. The assert.m in Octave needs to stay general and able to work for simple logical expressions, numeric comparisons, on up to recursive comparison of cell arrays and structures. Perhaps the easiest thing would be to rename your function to qassert.m (Quick Assert) and then find and replace all instances of assert in your code with qassert.
We also have a Matlab compatibility problem here. Octave introduced assert a long time ago as part of the unit test functions. Later, TMW added an assert function with a different interface to Matlab:
http://www.mathworks.com/help/matlab/ref/assert.html?searchHighlight=assertIn the simple one-argument case I think they work in essentially the same way. But with additional arguments, Matlab's assert is much different from Octave's. I don't think there is any way to provide both forms without breaking backward compatibility for Octave.
jwe
[Prev in Thread] | Current Thread | [Next in Thread] |