|
Glas :Re: [glas] value_type |
From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2005-10-03 15:28:57
Matthias Troyer wrote:
>
> We need to use matrices and vectors of symbolic expressions in some of
> our applications, and it would thus be important that not only numeric
> values but any value could be supported. Why should there be a
> restriction to floating point and complex types only?
>
Currently all types that are a model of the NumericValue concept can be
used as a value_type of a matrix. Do you think this is too restrictive?
And if yes, what exactly is too restrictive for your case ?
(the doc for the NumericValue concept is attached)
toon
| X | A type that is a model of NumericValue |
| abs_value_traits<X>::type | Type of modulus or absolute value of type X |
| x,y | Objects of type X |
| z | Object of type convertible to X |
| Name | Expression | Type requirements | Return type |
|---|---|---|---|
| Constructor | X(z) | X | |
| Zero member | zero<X>() | X | |
| One member | one<X>() | X | |
| Addition | x + y | X | |
| Addition | x += y | X | |
| Negation | - x | X | |
| Subtraction | x - y | X | |
| Subtraction | x -= y | X | |
| Multiplication | x * y | X | |
| Multiplication | x *= y | X | |
| Division | x / y | X | |
| Division | x /= y | X | |
| Modulus | abs(x) | abs_value_traits<X>::type | |
| Square of modulus | abs_square(x) | abs_value_traits<X>::type | |
| Sum of the absolute value of real and imaginary parts | scalar_abs_sum(x) | abs_value_traits<X>::type | |
| Maximum of the absolute value of real and imaginary parts | scalar_abs_max(x) | abs_value_traits<X>::type | |
| Conjugate | conj(x) | X |
| Name | Expression | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
| Constructor | X(z) | |||
| Zero member | zero<X>() | The zero member is such that a + zero<X>() == a. | ||
| One member | one<X>() | The one member is such that a * one<X>() == a. | ||
| Addition | x + y | |||
| Addition | x += y | Is equivalent to x = x + y | ||
| Negation | - x | |||
| Subtraction | x - y | |||
| Subtraction | x -= y | Is equivalent to x = x - y | ||
| Multiplication | x * y | |||
| Multiplication | x *= y | Is equivalent to x = x * y | ||
| Division | x / y | y != zero<X>() | ||
| Division | x /= y | y != zero<X>() | Is equivalent to x = x / y | |
| Modulus | abs(x) | |||
| Square of modulus | abs_square(x) | |||
| Sum of the absolute value of real and imaginary parts | scalar_abs_sum(x) | |||
| Maximum of the absolute value of real and imaginary parts | scalar_abs_max(x) | |||
| Conjugate | conj(x) |