Mantis Bug Tracker

View Revisions: Issue #240 All Revisions ] Back to Issue ]
Summary 0000240: abs() method used on Real values in core::scoring
Revision 2013-04-02 17:38 by Labonte
Description This may not be an error, but I'd like someone who knows more to double check it, just in case, because it looks very wrong to me and is throwing a ton of warnings.

In core/scoring/dna/base_geometry.cc, a lot of asserts are using the int abs(int) method but passing Reals. Rather than just cast everything to an int, I wanted to make sure that this is the intended behavior, because there is also a float abs(float) (in a different namespace, cmath) that could be used.

For an example, see l. 1246:

assert( abs( params[1] - asin( dot( MBT.col_z(), cross( M2.col_y(), M1.col_y() ) ) ) ) + abs( params[1] - asin( dot( MBT.col_z(), cross( M2.col_x(), M1.col_x() ) ) ) ) < 1e-2 );

where params is a vector1<Real>.

Not all of the issues are in asserts either -- l. 1303:

Real dot = std::abs( n12.dot( ( atoms[4]-atoms[3] ).normalized() ) );

where n12 is an xyzVector. This looks very bad to me; or am I missing something?

No one listed him- or herself as author on this file, but whoever you are, could you fix all the abs() calls in this file, whether by casting or by using cmath::abs()? Thanks!
Revision 2013-04-02 16:21 by Labonte
Description This may not be an error, but I'd like someone who knows more to double check it, just in case, because it looks very wrong to me and is throwing a ton of warnings.

In core/scoring/base_geometry.cc, a lot of asserts are using the int abs(int) method but passing Reals. Rather than just cast everything to an int, I wanted to make sure that this is the intended behavior, because there is also a float abs(float) (in a different namespace, cmath) that could be used.

For an example, see l. 1246:

assert( abs( params[1] - asin( dot( MBT.col_z(), cross( M2.col_y(), M1.col_y() ) ) ) ) + abs( params[1] - asin( dot( MBT.col_z(), cross( M2.col_x(), M1.col_x() ) ) ) ) < 1e-2 );

where params is a vector1<Real>.

Not all of the issues are in asserts either -- l. 1303:

Real dot = std::abs( n12.dot( ( atoms[4]-atoms[3] ).normalized() ) );

where n12 is an xyzVector. This looks very bad to me; or am I missing something?

No one listed him- or herself as author on this file, but whoever you are, could you fix all the abs() calls in this file, whether by casting or by using cmath::abs()? Thanks!


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker