public void Factorize(CoordinationalMatrix M) { FactorizedMatrix = (CoordinationalMatrix)M.Clone(); for (int i = 0; i < FactorizedMatrix.Size; i++) { FactorizedMatrix.Set(i, i, Math.Sqrt(FactorizedMatrix[i, i])); } }
public void Factorize(CoordinationalMatrix M) { FA = (CoordinationalMatrix)M.Clone(); var rows = FA.GetMatrixRows(); if (Math.Abs(FA[0, 0]) < 1.0E-14) { return; } foreach (var i in rows) { double sumD = 0; var cols_i = FA.GetMatrixColumnsForRow(i); foreach (var j in cols_i) { if (j >= i) { break; } double sumL = 0, sumU = 0; foreach (var k in cols_i) { if (k > j - 1) { break; } sumL += FA[i, k] * FA[k, j]; } FA.Set(i, j, (M[i, j] - sumL) / FA[j, j]); foreach (var k in FA.GetMatrixRowsForColumn(j)) { if (k > j - 1) { break; } sumU += FA[k, i] * FA[j, k]; } FA.Set(j, i, (M[j, i] - sumU)); sumD += FA[i, j] * FA[j, i]; } FA.Set(i, i, M[i, i] - sumD); } }
public void Factorize(CoordinationalMatrix M) { factorizedMatix = (CoordinationalMatrix)M.Clone(); var rows = factorizedMatix.GetMatrixRows(); if (Math.Abs(factorizedMatix[0, 0]) < 1.0E-14) { return; } foreach (var i in rows) { double sumD = 0; var columns = factorizedMatix.GetMatrixColumnsForRow(i); foreach (var j in columns) { if (j >= i) { break; } double sumL = 0; foreach (var k in columns) { if (k > j - 1) { break; } sumL += factorizedMatix[i, k] * factorizedMatix[j, k]; } var value = (M[i, j] - sumL) / factorizedMatix[j, j]; factorizedMatix.Set(i, j, value); factorizedMatix.Set(j, i, value); sumD += factorizedMatix[i, j] * factorizedMatix[i, j]; } factorizedMatix.Set(i, i, Math.Sqrt(M[i, i] - sumD)); } }