Browse Source

Enable modifying operators by default.

master
Richard Kreckel 17 years ago
parent
commit
98bc175431
  1. 21
      doc/cln.texi
  2. 2
      include/cln/complex.h
  3. 2
      include/cln/dfloat.h
  4. 2
      include/cln/ffloat.h
  5. 2
      include/cln/float.h
  6. 4
      include/cln/integer.h
  7. 2
      include/cln/lfloat.h
  8. 2
      include/cln/rational.h
  9. 2
      include/cln/real.h
  10. 2
      include/cln/sfloat.h

21
doc/cln.texi

@ -157,7 +157,7 @@ Functions on numbers
* Functions on floating-point numbers:: * Functions on floating-point numbers::
* Conversion functions:: * Conversion functions::
* Random number generators:: * Random number generators::
* Obfuscating operators::
* Modifying operators::
Constructing numbers Constructing numbers
@ -931,7 +931,7 @@ objects of type @code{cl_I}, it should @code{#include <cln/integer.h>}.
* Functions on floating-point numbers:: * Functions on floating-point numbers::
* Conversion functions:: * Conversion functions::
* Random number generators:: * Random number generators::
* Obfuscating operators::
* Modifying operators::
@end menu @end menu
@node Constructing numbers @node Constructing numbers
@ -2501,22 +2501,13 @@ if @code{n} is a float.
@end table @end table
@node Obfuscating operators
@section Obfuscating operators
@node Modifying operators
@section Modifying operators
@cindex modifying operators @cindex modifying operators
The modifying C/C++ operators @code{+=}, @code{-=}, @code{*=}, @code{/=}, The modifying C/C++ operators @code{+=}, @code{-=}, @code{*=}, @code{/=},
@code{&=}, @code{|=}, @code{^=}, @code{<<=}, @code{>>=} @code{&=}, @code{|=}, @code{^=}, @code{<<=}, @code{>>=}
are not available by default because their
use tends to make programs unreadable. It is trivial to get away without
them. However, if you feel that you absolutely need these operators
to get happy, then add
@example
#define WANT_OBFUSCATING_OPERATORS
@end example
@cindex @code{WANT_OBFUSCATING_OPERATORS}
to the beginning of your source files, before the inclusion of any CLN
include files. This flag will enable the following operators:
are all available.
For the classes @code{cl_N}, @code{cl_R}, @code{cl_RA}, For the classes @code{cl_N}, @code{cl_R}, @code{cl_RA},
@code{cl_F}, @code{cl_SF}, @code{cl_FF}, @code{cl_DF}, @code{cl_LF}: @code{cl_F}, @code{cl_SF}, @code{cl_FF}, @code{cl_DF}, @code{cl_LF}:
@ -2569,7 +2560,7 @@ The prefix operator @code{--x}.
The postfix operator @code{x--}. The postfix operator @code{x--}.
@end table @end table
Note that by using these obfuscating operators, you wouldn't gain efficiency:
Note that by using these modifying operators, you don't gain efficiency:
In CLN @samp{x += y;} is exactly the same as @samp{x = x+y;}, not more In CLN @samp{x += y;} is exactly the same as @samp{x = x+y;}, not more
efficient. efficient.

2
include/cln/complex.h

@ -138,7 +138,6 @@ extern const cl_N acos (const cl_N& z);
extern const cl_N acosh (const cl_N& z); extern const cl_N acosh (const cl_N& z);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_N& operator+= (cl_N& x, const cl_N& y) { return x = x + y; } inline cl_N& operator+= (cl_N& x, const cl_N& y) { return x = x + y; }
inline cl_N& operator++ /* prefix */ (cl_N& x) { return x = plus1(x); } inline cl_N& operator++ /* prefix */ (cl_N& x) { return x = plus1(x); }
@ -148,7 +147,6 @@ inline cl_N& operator-- /* prefix */ (cl_N& x) { return x = minus1(x); }
inline void operator-- /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = minus1(x); } inline void operator-- /* postfix */ (cl_N& x, int dummy) { (void)dummy; x = minus1(x); }
inline cl_N& operator*= (cl_N& x, const cl_N& y) { return x = x * y; } inline cl_N& operator*= (cl_N& x, const cl_N& y) { return x = x * y; }
inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; } inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; }
#endif
// Runtime typing support. // Runtime typing support.

2
include/cln/dfloat.h

@ -293,7 +293,6 @@ extern float float_approx (const cl_DF& x);
extern double double_approx (const cl_DF& x); extern double double_approx (const cl_DF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_DF& operator+= (cl_DF& x, const cl_DF& y) { return x = x + y; } inline cl_DF& operator+= (cl_DF& x, const cl_DF& y) { return x = x + y; }
inline cl_DF& operator+= (cl_DF& x, const double y) { return x = x + y; } inline cl_DF& operator+= (cl_DF& x, const double y) { return x = x + y; }
@ -307,7 +306,6 @@ inline cl_DF& operator*= (cl_DF& x, const cl_DF& y) { return x = x * y; }
inline cl_DF& operator*= (cl_DF& x, const double y) { return x = x * y; } inline cl_DF& operator*= (cl_DF& x, const double y) { return x = x * y; }
inline cl_DF& operator/= (cl_DF& x, const cl_DF& y) { return x = x / y; } inline cl_DF& operator/= (cl_DF& x, const cl_DF& y) { return x = x / y; }
inline cl_DF& operator/= (cl_DF& x, const double y) { return x = x / y; } inline cl_DF& operator/= (cl_DF& x, const double y) { return x = x / y; }
#endif
/* */ /* */

2
include/cln/ffloat.h

@ -293,7 +293,6 @@ extern float float_approx (const cl_FF& x);
extern double double_approx (const cl_FF& x); extern double double_approx (const cl_FF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_FF& operator+= (cl_FF& x, const cl_FF& y) { return x = x + y; } inline cl_FF& operator+= (cl_FF& x, const cl_FF& y) { return x = x + y; }
inline cl_FF& operator+= (cl_FF& x, const float y) { return x = x + y; } inline cl_FF& operator+= (cl_FF& x, const float y) { return x = x + y; }
@ -307,7 +306,6 @@ inline cl_FF& operator*= (cl_FF& x, const cl_FF& y) { return x = x * y; }
inline cl_FF& operator*= (cl_FF& x, const float y) { return x = x * y; } inline cl_FF& operator*= (cl_FF& x, const float y) { return x = x * y; }
inline cl_FF& operator/= (cl_FF& x, const cl_FF& y) { return x = x / y; } inline cl_FF& operator/= (cl_FF& x, const cl_FF& y) { return x = x / y; }
inline cl_FF& operator/= (cl_FF& x, const float y) { return x = x / y; } inline cl_FF& operator/= (cl_FF& x, const float y) { return x = x / y; }
#endif
CL_REQUIRE(cl_ieee) CL_REQUIRE(cl_ieee)

2
include/cln/float.h

@ -716,7 +716,6 @@ inline const cl_F random_F (const cl_F& n)
{ return random_F(default_random_state,n); } { return random_F(default_random_state,n); }
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_F& operator+= (cl_F& x, const cl_F& y) { return x = x + y; } inline cl_F& operator+= (cl_F& x, const cl_F& y) { return x = x + y; }
inline cl_F& operator+= (cl_F& x, const float y) { return x = x + y; } inline cl_F& operator+= (cl_F& x, const float y) { return x = x + y; }
@ -734,7 +733,6 @@ inline cl_F& operator*= (cl_F& x, const double y) { return x = x * y; }
inline cl_F& operator/= (cl_F& x, const cl_F& y) { return x = x / y; } inline cl_F& operator/= (cl_F& x, const cl_F& y) { return x = x / y; }
inline cl_F& operator/= (cl_F& x, const float y) { return x = x / y; } inline cl_F& operator/= (cl_F& x, const float y) { return x = x / y; }
inline cl_F& operator/= (cl_F& x, const double y) { return x = x / y; } inline cl_F& operator/= (cl_F& x, const double y) { return x = x / y; }
#endif
// Thrown when a floating-point exception occurs. // Thrown when a floating-point exception occurs.
class floating_point_exception : public runtime_exception { class floating_point_exception : public runtime_exception {

4
include/cln/integer.h

@ -193,12 +193,10 @@ inline const cl_I operator& (const cl_I& x, const cl_I& y)
{ return logand(x,y); } { return logand(x,y); }
inline const cl_I operator~ (const cl_I& x) inline const cl_I operator~ (const cl_I& x)
{ return lognot(x); } { return lognot(x); }
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_I& operator|= (cl_I& x, const cl_I& y) { return x = x | y; } inline cl_I& operator|= (cl_I& x, const cl_I& y) { return x = x | y; }
inline cl_I& operator^= (cl_I& x, const cl_I& y) { return x = x ^ y; } inline cl_I& operator^= (cl_I& x, const cl_I& y) { return x = x ^ y; }
inline cl_I& operator&= (cl_I& x, const cl_I& y) { return x = x & y; } inline cl_I& operator&= (cl_I& x, const cl_I& y) { return x = x & y; }
#endif
// Addition/Subtraktion von Integers // Addition/Subtraktion von Integers
@ -616,7 +614,6 @@ inline const cl_I testrandom_I ()
{ return testrandom_I(default_random_state); } { return testrandom_I(default_random_state); }
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_I& operator+= (cl_I& x, const cl_I& y) { return x = x + y; } inline cl_I& operator+= (cl_I& x, const cl_I& y) { return x = x + y; }
inline cl_I& operator+= (cl_I& x, const int y) { return x = x + y; } inline cl_I& operator+= (cl_I& x, const int y) { return x = x + y; }
@ -651,7 +648,6 @@ inline const cl_I operator% (const cl_I& x, const cl_I& y) { return rem(x,y); }
inline cl_I& operator/= (cl_I& x, const cl_I& y) { return x = x / y; } inline cl_I& operator/= (cl_I& x, const cl_I& y) { return x = x / y; }
inline cl_I& operator%= (cl_I& x, const cl_I& y) { return x = x % y; } inline cl_I& operator%= (cl_I& x, const cl_I& y) { return x = x % y; }
#endif #endif
#endif
// Runtime typing support. // Runtime typing support.

2
include/cln/lfloat.h

@ -407,7 +407,6 @@ extern float float_approx (const cl_LF& x);
extern double double_approx (const cl_LF& x); extern double double_approx (const cl_LF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_LF& operator+= (cl_LF& x, const cl_LF& y) { return x = x + y; } inline cl_LF& operator+= (cl_LF& x, const cl_LF& y) { return x = x + y; }
inline cl_LF& operator++ /* prefix */ (cl_LF& x) { return x = plus1(x); } inline cl_LF& operator++ /* prefix */ (cl_LF& x) { return x = plus1(x); }
@ -417,7 +416,6 @@ inline cl_LF& operator-- /* prefix */ (cl_LF& x) { return x = minus1(x); }
inline void operator-- /* postfix */ (cl_LF& x, int dummy) { (void)dummy; x = minus1(x); } inline void operator-- /* postfix */ (cl_LF& x, int dummy) { (void)dummy; x = minus1(x); }
inline cl_LF& operator*= (cl_LF& x, const cl_LF& y) { return x = x * y; } inline cl_LF& operator*= (cl_LF& x, const cl_LF& y) { return x = x * y; }
inline cl_LF& operator/= (cl_LF& x, const cl_LF& y) { return x = x / y; } inline cl_LF& operator/= (cl_LF& x, const cl_LF& y) { return x = x / y; }
#endif
// Runtime typing support. // Runtime typing support.

2
include/cln/rational.h

@ -315,7 +315,6 @@ extern float float_approx (const cl_RA& x);
extern double double_approx (const cl_RA& x); extern double double_approx (const cl_RA& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_RA& operator+= (cl_RA& x, const cl_RA& y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const cl_RA& y) { return x = x + y; }
inline cl_RA& operator+= (cl_RA& x, const int y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const int y) { return x = x + y; }
@ -341,7 +340,6 @@ inline cl_RA& operator-- /* prefix */ (cl_RA& x) { return x = minus1(x); }
inline void operator-- /* postfix */ (cl_RA& x, int dummy) { (void)dummy; x = minus1(x); } inline void operator-- /* postfix */ (cl_RA& x, int dummy) { (void)dummy; x = minus1(x); }
inline cl_RA& operator*= (cl_RA& x, const cl_RA& y) { return x = x * y; } inline cl_RA& operator*= (cl_RA& x, const cl_RA& y) { return x = x * y; }
inline cl_RA& operator/= (cl_RA& x, const cl_RA& y) { return x = x / y; } inline cl_RA& operator/= (cl_RA& x, const cl_RA& y) { return x = x / y; }
#endif
// Runtime typing support. // Runtime typing support.

2
include/cln/real.h

@ -525,7 +525,6 @@ inline const cl_R random_R (const cl_R& n)
{ return random_R(default_random_state,n); } { return random_R(default_random_state,n); }
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_R& operator+= (cl_R& x, const cl_R& y) { return x = x + y; } inline cl_R& operator+= (cl_R& x, const cl_R& y) { return x = x + y; }
inline cl_F& operator+= (cl_F& x, const cl_R& y) { return x = x + y; } inline cl_F& operator+= (cl_F& x, const cl_R& y) { return x = x + y; }
@ -608,7 +607,6 @@ inline cl_F& operator/= (cl_F& x, const unsigned long y) { return x = x / y; }
inline cl_F& operator/= (cl_F& x, const long long y) { return x = x / y; } inline cl_F& operator/= (cl_F& x, const long long y) { return x = x / y; }
inline cl_F& operator/= (cl_F& x, const unsigned long long y) { return x = x / y; } inline cl_F& operator/= (cl_F& x, const unsigned long long y) { return x = x / y; }
#endif #endif
#endif
// Complex operations, trivial for reals // Complex operations, trivial for reals

2
include/cln/sfloat.h

@ -273,7 +273,6 @@ extern float float_approx (const cl_SF& x);
extern double double_approx (const cl_SF& x); extern double double_approx (const cl_SF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations. // This could be optimized to use in-place operations.
inline cl_SF& operator+= (cl_SF& x, const cl_SF& y) { return x = x + y; } inline cl_SF& operator+= (cl_SF& x, const cl_SF& y) { return x = x + y; }
inline cl_SF& operator++ /* prefix */ (cl_SF& x) { return x = plus1(x); } inline cl_SF& operator++ /* prefix */ (cl_SF& x) { return x = plus1(x); }
@ -283,7 +282,6 @@ inline cl_SF& operator-- /* prefix */ (cl_SF& x) { return x = minus1(x); }
inline void operator-- /* postfix */ (cl_SF& x, int dummy) { (void)dummy; x = minus1(x); } inline void operator-- /* postfix */ (cl_SF& x, int dummy) { (void)dummy; x = minus1(x); }
inline cl_SF& operator*= (cl_SF& x, const cl_SF& y) { return x = x * y; } inline cl_SF& operator*= (cl_SF& x, const cl_SF& y) { return x = x * y; }
inline cl_SF& operator/= (cl_SF& x, const cl_SF& y) { return x = x / y; } inline cl_SF& operator/= (cl_SF& x, const cl_SF& y) { return x = x / y; }
#endif
// Runtime typing support. // Runtime typing support.

Loading…
Cancel
Save