2012-04-10 58 views

回答

1

好的;我決定寫這篇簡報的作者(Dr. Melanie J Martin),她指出她基於Deerwester等人的論文第406頁; 「X帽子」部分。

爲了測試它,我寫出來的例子,看看我是否能得到相同的值,並且它的工作:)

測試代碼:

static void XHatTest() 
{ 
    double[,] testT = new double[12, 2], testD = new double[2, 9], testS = new double[2, 2]; 
    testT[0, 0] = 0.22; 
    testT[0, 1] = -0.11; 
    testT[1, 0] = 0.20; 
    testT[1, 1] = -0.07; 
    testT[2, 0] = 0.24; 
    testT[2, 1] = 0.04; 
    testT[3, 0] = 0.40; 
    testT[3, 1] = 0.06; 
    testT[4, 0] = 0.64; 
    testT[4, 1] = -0.17; 
    testT[5, 0] = 0.27; 
    testT[5, 1] = 0.11; 
    testT[6, 0] = 0.27; 
    testT[6, 1] = 0.11; 
    testT[7, 0] = 0.30; 
    testT[7, 1] = -0.14; 
    testT[8, 0] = 0.21; 
    testT[8, 1] = 0.27; 
    testT[9, 0] = 0.01; 
    testT[9, 1] = 0.49; 
    testT[10, 0] = 0.04; 
    testT[10, 1] = 0.62; 
    testT[11, 0] = 0.03; 
    testT[11, 1] = 0.45; 

    testD[0, 0] = 0.20; 
    testD[0, 1] = 0.61; 
    testD[0, 2] = 0.46; 
    testD[0, 3] = 0.54; 
    testD[0, 4] = 0.28; 
    testD[0, 5] = 0.00; 
    testD[0, 6] = 0.02; 
    testD[0, 7] = 0.02; 
    testD[0, 8] = 0.08; 
    testD[1, 0] = -0.06; 
    testD[1, 1] = 0.17; 
    testD[1, 2] = -0.13; 
    testD[1, 3] = -0.23; 
    testD[1, 4] = 0.11; 
    testD[1, 5] = 0.19; 
    testD[1, 6] = 0.44; 
    testD[1, 7] = 0.62; 
    testD[1, 8] = 0.53; 

    testS[0, 0] = 3.34; 
    testS[0, 1] = 0; 
    testS[1, 0] = 0; 
    testS[1, 1] = 2.54; 

    Matrix A = new Matrix(testT), B = new Matrix(testD), C = new Matrix(testS); 
    Matrix Result = A * C * B; 
    for (int row = 0; row < Result.NoRows; row++) 
    { 
     for (int col = 0; col < Result.NoCols; col++) 
     { 
      Console.Write(Math.Round(Result[row, col], 2) + " "); 
     } 
     Console.WriteLine(); 
    } 
}