该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
java.lang.OutOfMemoryError: GC overhead limit exceede请问这是怎么错了,百度了下改了改,还是有问题,有没有大神可以帮我看一下
public class MetrixMuitipy_Notsave0 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
long startTime = System.currentTimeMillis(); // 获取开始时间
HashMap Word_Tfidf = null;
HashMap> tfidf_value = new HashMap>();// 文档号、词、tfidf值;
File f = new File("F:\\ASDN-Introcuction\\day0730\\5000_D_T.txt");
FileReader rf = new FileReader(f);
BufferedReader br = new BufferedReader(rf);
String s = null;
while ((s = br.readLine()) != null) {
String s1[];
s1 = s.split("\\s+");
// System.out.println(s1[0]+" "+s1[1]+" "+s1[2]);
if (!tfidf_value.containsKey(Integer.parseInt(s1[0])))
Word_Tfidf = new HashMap();// 临时
int i = Integer.parseInt(s1[0]);
double tfidf = Double.parseDouble(s1[2]);
Word_Tfidf.put(Integer.parseInt(s1[1]), tfidf);// 单词,tfidf值
tfidf_value.put(Integer.parseInt(s1[0]), Word_Tfidf);
}
//System.out.println(tfidf_value);
matrix_multiplication1(tfidf_value, tfidf_value);
long endTime = System.currentTimeMillis(); // 获取结束时间
System.out.println("程序运行时间: " + (endTime - startTime) + "ms");
}
public static HashMap> matrix_multiplication1(// 矩阵相乘
// public static void matrix_multiplication1(//矩阵相乘
HashMap> TFIDF1, HashMap> TFIDF2) {
// 两个矩阵相乘;
HashMap> result = new HashMap>();
Iterator it = TFIDF1.keySet().iterator();// 先读第一个矩阵的行
while (it.hasNext()) {
int k1 = it.next();
HashMap m1 = new HashMap();
m1 = TFIDF1.get(k1);// (k1,m1)通过k1行找列m1
HashMap m3 = new HashMap();
Iterator it2 = TFIDF2.keySet().iterator();// 再读第二个矩阵的行
while (it2.hasNext()) {
int k2 = it2.next();
HashMap m2 = new HashMap();
m2 = TFIDF2.get(k2);// (k2,m2)找k2行m2列
Iterator it2_1 = m2.keySet().iterator();//
double sum = 0;
double x = 0.8;
double c = x * (1 - x);
while (it2_1.hasNext()) {
int k3 = it2_1.next();
double d1 = 0.0;
try {
d1 = m1.get(k3);// (k1,m1,d1)d1为值
} catch (Exception e) {
d1 = 0.0;
}
if (d1 == 0.0) {
double d3 = 0.0;
} else {
double d2 = m2.get(k3);// (k2,m2,d2)d2为值
double d3 = d1 * d2 * c;// 对应的值相乘,即c(1-c)p*p
sum += d3;
}
// 加算完了第一个值
// sum1=sum+(d1*c);//矩阵相加 对应的行列值相加:c(1-c)p*p + C(1-C)P==R2------------R1=C(1-C)P
}
m3.put(k2, sum);
}
result.put(k1, m3);// 相乘后的方阵,>
}
//System.out.println(result);
return result;
}
}