[lammps-users] Patch: New math operations

Hi Lammps-Group,

For a simulation script I needed some more freedom. So I implemented the
new math operations:

I append the patched source files and a small example.

Best regards:

variable.cpp (44.2 KB)

variable.h (2.26 KB)

round_floor_ceil.lmp (138 Bytes)

Just added these as the 1Apr08 patch (no foolin').

Thanks Gerolf,

To the mail list:

I added these operations of Gerolf's as a patch last week,
but some folks are having trouble compiling, due to the
round() function not being in some C math libraries.

I don't believe its part of the standard, at least not in
my K&R book. Maybe many C++ implementations support it,
but not all?

If this can't be resolved, I'll probably remove the round()
function, since LAMMPS needs to compile easily on all

Any suggestions from anyone on the mail list?



round(3) conforms to the C99 standard (only, according
to the man page on my linux machine).

it may be more portable to implement an equivalent functionality
directly into LAMMPS to circumvent those problems.

What about this one?
   #define ROUND(a) (( a-floor(a) ) >= .5) ? ceil(a) : floor(a)


Any particular reason for not using lower case "round" and not "ROUND" below?


I'll use this one - just posted a patch - thanks for everyone's input.


OOps ... mine was a stupid question!! You would not want a lower case
"round" to conflict with an already existing "round(3) which conforms
to the C99 standard" on linux PCs that have it. Sorry for extending
the closed discussion. by one more thread.