manpagez: man pages & more
info cln
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Elementary functions

Each of the classes cl_N, cl_R, cl_RA, cl_I, cl_F, cl_SF, cl_FF, cl_DF, cl_LF defines the following operations:

type operator + (const type&, const type&)

Addition.

type operator - (const type&, const type&)

Subtraction.

type operator - (const type&)

Returns the negative of the argument.

type plus1 (const type& x)

Returns x + 1.

type minus1 (const type& x)

Returns x - 1.

type operator * (const type&, const type&)

Multiplication.

type square (const type& x)

Returns x * x.

Each of the classes cl_N, cl_R, cl_RA, cl_F, cl_SF, cl_FF, cl_DF, cl_LF defines the following operations:

type operator / (const type&, const type&)

Division.

type recip (const type&)

Returns the reciprocal of the argument.

The class cl_I doesn’t define a ‘/’ operation because in the C/C++ language this operator, applied to integral types, denotes the ‘floor’ or ‘truncate’ operation (which one of these, is implementation dependent). (See section Rounding functions.) Instead, cl_I defines an “exact quotient” function:

cl_I exquo (const cl_I& x, const cl_I& y)

Checks that y divides x, and returns the quotient x/y.

The following exponentiation functions are defined:

cl_I expt_pos (const cl_I& x, const cl_I& y)
cl_RA expt_pos (const cl_RA& x, const cl_I& y)

y must be > 0. Returns x^y.

cl_RA expt (const cl_RA& x, const cl_I& y)
cl_R expt (const cl_R& x, const cl_I& y)
cl_N expt (const cl_N& x, const cl_I& y)

Returns x^y.

Each of the classes cl_R, cl_RA, cl_I, cl_F, cl_SF, cl_FF, cl_DF, cl_LF defines the following operation:

type abs (const type& x)

Returns the absolute value of x. This is x if x >= 0, and -x if x <= 0.

The class cl_N implements this as follows:

cl_R abs (const cl_N x)

Returns the absolute value of x.

Each of the classes cl_N, cl_R, cl_RA, cl_I, cl_F, cl_SF, cl_FF, cl_DF, cl_LF defines the following operation:

type signum (const type& x)

Returns the sign of x, in the same number format as x. This is defined as x / abs(x) if x is non-zero, and x if x is zero. If x is real, the value is either 0 or 1 or -1.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on August 27, 2013 using texi2html 5.0.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.