Hello,
So I'm doing some mathematical modeling and it turns out I need
distinct imaginary and complex types to carry out complex contour
integration.
I want to have it in all three precisions (float, double, and decimal),
and the code is highly redundant, but I can't seem to come up with a
clean way to use Generics in the code. For example, the following
doesn't work
public struct Imag<Twhere T:System.ValueType
{
T imag;
public static Imag<Toperator +(Imag<Ta, Imag<Tb) { //implmentation}
public static Imag<Toperator -(Imag<Ta, Imag<Tb) { //implmentation}
public static T operator *(Imag<Ta, Imag<Tb) { //implmentation}
// and so on
}
Basically I need a way to make a Generic struct (can't be a class for
speed) that can only accept floats, doubles and decimals. Is this
possible in the current spec? I tried setting up an interface, but
those do not allow operators.
I really appreciate any help. Thanks.
Ravi