int k = itemNeighborhood.length;
double[][] A = new double[k][k];
double[] b = new double[k];
int i = 0;
DataModel dataModel = getDataModel();
int numUsers = getDataModel().getNumUsers();
for (long iitem : itemNeighborhood) {
PreferenceArray iPrefs = getDataModel().getPreferencesForItem(iitem);
int iSize = iPrefs.length();
int j = 0;
for (long jitem : itemNeighborhood) {
double value = 0.0;
for (int pi = 0; pi < iSize; pi++) {
long v = iPrefs.getUserID(pi);
if (v == userID) {
continue;
}
Float pj = dataModel.getPreferenceValue(userID, jitem);
if (pj != null) {
value += iPrefs.getValue(pi) * pj;
}
}
A[i][j] = value / numUsers;
j++;
}
i++;
}
PreferenceArray iPrefs = getDataModel().getPreferencesForItem(itemID);
int iSize = iPrefs.length();
i = 0;
for (long jitem : itemNeighborhood) {
double value = 0.0;
for (int pi = 0; pi < iSize; pi++) {
long v = iPrefs.getUserID(pi);
if (v == userID) {
continue;
}
Float pj = dataModel.getPreferenceValue(userID, jitem);
if (pj != null) {
value += iPrefs.getValue(pi) * pj;
}
}
b[i] = value / numUsers;