C# 从矩阵求特征向量

C# 从矩阵求特征向量,c#,matrix,C#,Matrix,我正在尝试使用(4:50)编制AHP程序。我一直在寻找标准权重的特征向量。我使用了来自的类库,但结果有很大差异 这是到目前为止我编写的测试代码 private void button_calculate_Click(object sender, EventArgs e) { double[,] matrix = new double[,] { {1, 1/3, 1/2}, {3, 1, 1 },

我正在尝试使用(4:50)编制AHP程序。我一直在寻找标准权重的特征向量。我使用了来自的类库,但结果有很大差异

这是到目前为止我编写的测试代码

private void button_calculate_Click(object sender, EventArgs e)
    {

        double[,] matrix = new double[,]
        {
            {1, 1/3, 1/2},  
            {3, 1, 1 },
            {2, 1, 1}
        };
        double[] eigenValue;
        double[,] eigenVector;


        alglib.smatrixevd(matrix, 3, 1, false, out eigenValue, out eigenVector);
    }

使用第三方库时,您应始终非常仔细地阅读提供的文档

对于
smatrixevd
而言,其明确说明:

A:对称的矩阵,由其上三角部分或下三角部分给出

粗体部分用于强调

你的输入矩阵不是对称的,所以你就这样做了


在使用第三方库时,您希望为通用矩阵调用的函数是

,您应始终仔细阅读提供的文档

对于
smatrixevd
而言,其明确说明:

A:对称的矩阵,由其上三角部分或下三角部分给出

粗体部分用于强调

你的输入矩阵不是对称的,所以你就这样做了


您要为通用矩阵调用的函数是

,您必须包括alglib中存在的所有11.cs库文件,以获得特征值和特征向量的结果,因为一个.cs文件依赖于另一个.cs文件。小心

cs文件如下:

alglibmisc.cs - contains different algorithms which are hard to classify
dataanalysis.cs - contains data mining algorithms
diffequations.cs - contains differential equation solvers
fasttransforms.cs - contains FFT and other related algorithms
integration.cs - contains numerical integration algorithms
interpolation.cs - contains interpolation algorithms
linalg.cs - contains linear algebra algorithms
optimization.cs - contains optimization algorithms
solvers.cs - contains linear and nonlinear solvers
specialfunctions.cs - contains special functions
statistics.cs - statistics
alglibinternal.cs - contains internal functions which are used by other packages, but not exposed to the external world
ap.cs - contains publicly accessible vector/matrix classes, most important and general functions and other "basic" functionality.
要获取更多信息,请查看以下内容:

对于特征向量和特征值,请参见:


我已经试过了,它会起作用的…

您必须包括alglib中存在的所有11.cs库文件,以获得特征值和特征向量的结果,因为一个.cs文件依赖于另一个.cs文件。小心

cs文件如下:

alglibmisc.cs - contains different algorithms which are hard to classify
dataanalysis.cs - contains data mining algorithms
diffequations.cs - contains differential equation solvers
fasttransforms.cs - contains FFT and other related algorithms
integration.cs - contains numerical integration algorithms
interpolation.cs - contains interpolation algorithms
linalg.cs - contains linear algebra algorithms
optimization.cs - contains optimization algorithms
solvers.cs - contains linear and nonlinear solvers
specialfunctions.cs - contains special functions
statistics.cs - statistics
alglibinternal.cs - contains internal functions which are used by other packages, but not exposed to the external world
ap.cs - contains publicly accessible vector/matrix classes, most important and general functions and other "basic" functionality.
要获取更多信息,请查看以下内容:

对于特征向量和特征值,请参见:


我已经试过了,它会起作用的…

我明白了。我必须承认,我认为即使矩阵的行数和列数也是一样的。。。我会查一下,谢谢。@user3699148它与行和列无关;首先只能计算方阵的特征值。对称矩阵意味着给定一个矩阵
A
,它的转置矩阵是相同的<代码>转置(A)=A。我明白了。我必须承认,我认为即使矩阵的行数和列数也是一样的。。。我会查一下,谢谢。@user3699148它与行和列无关;首先只能计算方阵的特征值。对称矩阵意味着给定一个矩阵
A
,它的转置矩阵是相同的<代码>转置(A)=A。