An instance of this class represents an extension of the type NT by
one square root of the type ROOT.
NT is required to be constructible from ROOT.
NT is required to be an IntegralDomainWithoutDivision.
Sqrt_extension<NT,ROOT> is RealEmbeddable if NT is RealEmbeddable.
For example: Let Integer be some type representing ℤ, then Sqrt_extension<Integer,Integer> is able to represent ℤ[√root] for some arbitrary value root. The value of root is set at construction time, or left open if root is not specified.
Note that the given root is stored as it is given to the constructor. In particular, an extension by a square root of a square is considered as an extension.
It is not possible to interoperate two values from two different extensions ℤ[√a] and ℤ[√b], since the result is in ℤ[√a,√b], which is not representable by Sqrt_extension<Integer,Integer>.
From there, Sqrt_extension<NT,ROOT> can be used as if it were a model of an algebraic structure concept, with the following correspondence:
NT | Sqrt_extension<NT,ROOT> |
IntegralDomainWithoutDivision | IntegralDomainWithoutDivision |
IntegralDomain | IntegralDomain |
UniqueFactorizationDomain | IntegralDomain |
EuclideanRing | IntegralDomain |
Field | Field |
The extension of an UniqueFactorizationDomain or EuclideanRing is just an IntegralDomain, since the extension in general destroys the unique factorization property, e.g.,
10 = √10 ⋅ √10 = 2 ⋅ 5 over ℤ[√10] |
Note that the user is responsible for checking that the elements of
Sqrt_extension<NT,ROOT> that are manipulated are actually in a same extension field.
If different extension fields are mixed together,
the code may crash at runtime!
In the same way Sqrt_extension can be used as if it were a model of RealEmbeddable if NT is model of RealEmbeddable. Comparisons of two values from different extension via operators is not allowed. However, the member function compare provides this comparison.
Assignable | |
CopyConstructible | |
DefaultConstructible | |
EqualityComparable | |
ImplicitInteroperable | with int |
ImplicitInteroperable | with NT |
Fraction | if NT is a Fraction |
| |
Introduces an variable initialized with 0.
| |
| |
copy constructor.
| |
| |
Constructor from int.
| |
| |
Constructor from type NT.
| |
| |
Constructor from int: ext= a0 +a1 ⋅ sqrt(r).
| |
| |
General constructor: ext= a0 + a1 ⋅ sqrt(r).
|
An object of type Sqrt_extension represent an expression of the form: a0 + a1 * sqrt(root).
|
|
Returns true in case root of ext is not zero. Note that a1 == 0 does not imply root == 0. | ||
|
| Const access operator for a0 | ||
|
| Const access operator for a1 | ||
|
| Const access operator for root | ||
|
|
Propagates the simplify command to members of ext. see also: AlgebraicStructureTraits::Simplify. | ||
|
| returns true if ext represents the value zero. | ||
|
|
Determines sign of ext by (repeated) squaring.
| ||
|
|
returns the absolute value of ext.
| ||
|
| |||
Compares ext with y. The optional bool in_same_extension indicates whether ext and y are in the same extension of NT. | ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
|
In case NT is an IntegralDomain operator/ implements integral division.
|
| |||
| ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
|
In case Sqrt_extension is RealEmbeddable:
|
| |||
| ||||
|
| |||
| ||||
|
| |||
| ||||
|
| |||
|
The stream operations are available as well. They assume that corresponding stream operators for type NT and ROOT exist.
|
| |
writes ext to ostream os. The format depends on the CGAL::IO::MODE of os. In case the mode is CGAL::IO::ASCII the format is EXT[a0,a1,root]. In case the mode is CGAL::IO::PRETTY the format is human readable. | ||
|
| |
reads ext from istream is in format EXT[a0,a1,root], the output format in mode CGAL::IO::ASCII |