我正在尝试使用this video(4:50)制作AHP计划。我坚持找到标准权重的特征向量。我使用了来自this webpage的类库,但结果差异很大。
这是我到目前为止所写的测试代码。
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);
}
答案 0 :(得分:1)
使用第三方库时,您应该仔细阅读提供的文档。
在smatrixevd
的情况下,它明确指出:
A:对称矩阵由上三角部分或下三角部分给出......
重点突出部分。
你的输入矩阵不是对称的,所以你去。
您要为一般矩阵调用的函数是rmatrixevd
答案 1 :(得分:1)
您必须包含alglib中存在的所有11个.cs库文件以获取特征值和特征向量becoz的结果.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.
要获取更多信息,请查看以下内容:Manual of alglib
对于特征向量和特征值,请查看:How to use eigen vector library
我试过这个,它会起作用......