A type of user-defined algebraic type implementing some kind of an algebraic structure (field, ring, etc.).
This documentation specifies requirements for user-defined components to be used cohesively with chsvlib components. The corresponding requirement is referenced in documentation to a corresponding chsvlib interface in terms: "A <object_name> should be <adjective_concept_name | noun_concept_name>" or "A <object_name> should meet the <general_concept_name> requirement(s)".
Requirements for user-defined types to be used in cohesion with chsvlib interfaces.
The concept specifies requirements for a user-defined type which implements an algebraic structure. Adherence to the requirements can make the type compatible with some mathematical components of the chsvlib which expect respective algebraic structures. For instance, see Chusov::Math::Matrix.
Given a user-defined algebraic type T
, one of the following must be satisfied.
T::algebraic_category
should be defined as one of the algebraic tags. T
is considered a field and has to meet corresponding requirements. T
is considered a commutative ring and has to meet its requirements. Any of these requirements are not exclusive and are allowed to be met in conjunction. In this case the chsvlib components consider the type T
an algebraic structure as defined in the above list from top to bottom, that is if types T
and U
are defined as:
then the type T
is considered a division ring and the type U is considered an Rng despite the second and the third point of the above list.
If these requirements are met by an implementation T
of an algebraic type, then
is resolved to one of the algebraic tags.
Also, objects of any algebraic type must be EquallyComparable, LessThanComparable, DefaultConstructible, CopyConstructible, and CopyAssignable.
A type implements a behaviour of a group with addition. Let T
be a type which is claimed to implement the behaviour of an additive group, and x
and y
be any objects of this type. All objects of type T
constitute the additive group if the following is true.
The following expressions are valid and correspond to the table below:
Expression | Return/Resolution type | Equivalent expression | Notes |
---|---|---|---|
A containing class implements an algebraic group over addition. Definition: chsvmath.h:829 | See algebraic_type. | ||
Either @ additive_identity A tag to construct additive identity element. See rng_concept. Definition: chsvmath.h:998 T(0)
| Constructs an object of type x + T(Chusov::Math::additive_identity) == x
and T(Chusov::Math::additive_identity) + x == x
must return | ||
-x
| T
| Creates a new object which is a unique additive inversion of | |
x + y
| T
| T new_obj = x;
new_obj += y;
| Returns a new constructed object of type |
x += y
| T&
| x = x + y
| Calculates a unique sum of |
x - y
| T
| x + -y
| Returns a new constructed object of type |
x -= y
| T&
| x += -y
| Calculates a unique difference between x and y and assigns the result to x returning a reference to it. |
x
, y
, and z
of the type T
which implements the [additive group]: A type implements a behaviour of an Rng. Let T
be a type which is claimed to implement the Rng, and x
and y
be any objects of this type. All objects of type T
is declared to constitute the Rng if the following are true.
The following expressions are valid and correspond to the table below:
Expression | Return/Resolution type | Equivalent expression | Notes |
---|---|---|---|
(or any of its successors). | See algebraic_type. | ||
x * y
| T
| T new_obj = x;
new_obj *= y;
| Returns a new constructed object of type |
x *= y
| T&
| x = x * y
| Calculates a unique multiplication of x and y and assigns the result to x returning a reference to it. |
The addition must be commutative, i.e. for any x
, y
, and z
of the type T
which implements the Rng an expression
must return true.
x
, y
, and z
of the type T
which implements the Rng: A type implements a behaviour of an algebraic ring with multiplicative identity. Let T
be a type which is declared to implement the ring, and x
and y be any objects of this type. All objects of type T constitute the ring if the following is true.
T
meets the requirements of the rng_concept. The following expressions are valid and correspond to the table below:
Expression | Return/Resolution type | Equivalent expression | Notes |
---|---|---|---|
A containing class satisfies the ring_concept. Definition: chsvmath.h:831 | See algebraic_type. | ||
@ multiplicative_identity A tag to construct multiplicative identity element. See ring_concept. Definition: chsvmath.h:1005 T(1)
| Constructs an object of type T that is a unique multiplicative identity. Both left and right multiplication of such an object with any object x results to x , i.e. for any x of type T comparisons:x * T(Chusov::Math::multiplicative_identity) == x
T(Chusov::Math::multiplicative_identity) * x == x
true . |
A type implements a behaviour of an algebraic commutative ring. Any class T
that is declared to implement a commutative ring has to adhere the following:
T
class meets the requirements of the ring_concept. x
and y
of type Ttrue
. A type T
implements a behaviour of an algebraic division ring, that is a ring where multiplication is invertible, that is for any \(x\) there exists a unique multiplicative inversion \({x}^{-1}\) such that \(x\cdot {x}^{-1} = 1\), where \(1\) is a multiplicative identity of T
constructed as
. Any class implementing the division ring should adhere the following in order to be used with chsvlib:
The T
class meets the requirements of the ring_concept.
T
implementing a division ring together with any instance x
must adhere the following: Expression | Return/Resolution type | Equivalent expression | Notes |
---|---|---|---|
(or any of its successors). | See algebraic_type. | ||
x.MultiplicativeInverse();
| T
| T y = x;
y.MultiplicativeInverseMe();
<T>::value is true, the following expression will also be considered equivalent:1.0 / x;
| x * x.MultiplicativeInverse() == T(Chusov::Math::multiplicative_identity)
and x.MultiplicativeInverse() * x == T(Chusov::Math::multiplicative_identity)
must be both true regardless of commutativity of multiplication. |
x.MultiplicativeInverseMe();
| T&
| T y = x.MultiplicativeInverse();
x = y;
| See above. |
An algebraic field is both a division ring and a commutative ring, hence the field_concept must adhere the requirements given for both division_ring_concept and commutative_ring_concept, except for the expression
which must be aliased as Chusov::Math::field_algebraic_tag
or any of its successors which can be included in future versions of chsvlib or provided by a user.