简体   繁体   中英

C# Matrix calculations and SVD using own generic type (with Math.NET Numerics)

I have written my own struct for interval arithmetic, to keep it simple let's just say this is a value defined by a lower and an upper bound. Some of you might know be familiar with the type Range, which is quite similar.

I overloaded the whole arithmetic operators like +,-,*,/,<,>, ... . So I suppose I should have something like a generic type (or should be able to implement the rest to make it one).

Now I want to work/calculate with my type. Since I am handling Linear Equation Systems , need stuff like SVD and don't want to newly invent the wheel, I am planning to use existing Math libraries like Math.NET Numerics . But this is what their matrix class says:

/// <summary>
    /// Defines the base class for <c>Matrix</c> classes.
    /// </summary>
    /// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
    [Serializable]
    public abstract partial class Matrix<T> :
        IFormattable, IEquatable<Matrix<T>>
#if !PORTABLE
        , ICloneable
#endif
        where T : struct, IEquatable<T>, IFormattable

In short: They say only double, single and complex are allowed. So my generic type won't work, even if it implements all the listed interfaces, right?

So: Am I right that I can't use Math.Net Numerics with my type? Do you know other math libraries that would support my type/a generic? Do I really have to write my own implementations?

Thanks in advance!

I cannot comment directly (due to small reputation), so I have to post an "answer", my apologies!

I don't think that what you have is a "generic type", it is a specific, custom (not built-in), type.

Suppose now that you could actually use the Matrix abstract class (you should try this yourself, by the way) to represent an interval matrix. You would still be left with all the hard work, since computing the SVD of the interval matrix is not as far as I know directly related to the SVD of any specific matrix, or is it? Likewise for interval eigenvalue/eigenvector calculations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM