- Jul 23, 2006
- 3,934
- 0
- 0
I'm porting some C++ code into C# and I'm having an issue with a matrix class I have. This program reads in data from a 4096x4096x2Byte matrix of data. In C++ I made this a template class so I could in the future make it take a full 4Byte Integer, however implementing that now would make a single matrix double it's size (to 64 MB). In C++ I wrote some of the code under the assumption that the datatype of the template would only be numeric, so I freely used comparison (<,>,==) and mathematical operations (*,/,+,-). This is fine with C++, however C# seems to be typed strong enough to forbid such an assumption.
I managed to do the comparisons by forcing the datatype to implement IComparable, however I'm still stuck when it comes to the mathematical operators. Is there an easy way to accomplish this (or is there an interface that would facilitate this)?
I managed to do the comparisons by forcing the datatype to implement IComparable, however I'm still stuck when it comes to the mathematical operators. Is there an easy way to accomplish this (or is there an interface that would facilitate this)?