简体   繁体   English

使用自己的通用类型(带有Math.NET数值)的C#矩阵计算和SVD

[英]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. 你们中有些人可能熟悉Range类型,这非常相似。

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 . 由于我正在处理线性方程组 ,需要SVD之类的东西并且不想重新发明轮子,因此我打算使用现有的Math库,例如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. 简而言之:他们说只允许使用double,single和complex。 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? 所以:我不能在我的类型中使用Math.Net数值吗? 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. 现在假设您实际上可以使用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? 我仍然不遗余力,因为据我所知,计算间隔矩阵的SVD与任何特定矩阵的SVD没有直接关系,是吗? Likewise for interval eigenvalue/eigenvector calculations. 对于间隔特征值/特征向量计算同样如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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