import org.simantics.modelica.data.IntMatrix;\r
import org.simantics.modelica.data.Matrix;\r
import org.simantics.modelica.data.StringMatrix;\r
+import org.simantics.utils.datastructures.MapList;\r
\r
public class MatFileReader implements ResultFileReader {\r
private File file;\r
double vs[][] = new double[unSortedRows.size()][];\r
for (int i = 0; i < unSortedRows.size(); i++) {\r
int row = unSortedRows.get(i);\r
- vs[i] = new double[size];\r
+ //vs[i] = new double[size];\r
usc[i] = infoData[row * 4 + 1];\r
uc[i] = usc[i] > 0 ? usc[i]-1 : 1-usc[i];\r
}\r
\r
- Map<Integer, Integer> cToRow = new HashMap<Integer, Integer>();\r
+ //Map<Integer, Integer> cToRow = new HashMap<Integer, Integer>();\r
+ MapList<Integer, Integer> cToRow = new MapList<Integer, Integer>();\r
List<Integer> sortedCs = new ArrayList<Integer>();\r
for (int i = 0; i < unSortedRows.size(); i++) {\r
- cToRow.put(uc[i], unSortedRows.get(i));\r
+ //cToRow.put(uc[i], unSortedRows.get(i));\r
+ cToRow.add(uc[i], unSortedRows.get(i));\r
sortedCs.add(uc[i]);\r
}\r
\r
List<Integer> sortedRows = new ArrayList<Integer>();\r
- int sc[] = new int[unSortedRows.size()];\r
- int c[] = new int[unSortedRows.size()];\r
+// int sc[] = new int[unSortedRows.size()];\r
+// int c[] = new int[unSortedRows.size()];\r
+ int sc[] = new int[sortedCs.size()];\r
+ int c[] = new int[sortedCs.size()];\r
\r
Collections.sort(sortedCs);\r
- for (int i = 0; i < unSortedRows.size(); i++) {\r
- int row = cToRow.get(sortedCs.get(i));\r
+\r
+ //for (int i = 0; i < unSortedRows.size(); i++) {\r
+ for (int i = 0; i < sortedCs.size(); i++) {\r
+ //int row = cToRow.get(sortedCs.get(i));\r
+ int row = cToRow.getValues(sortedCs.get(i)).get(0);\r
sortedRows.add(row);\r
sc[i] = usc[unSortedRows.indexOf(row)];\r
c[i] = uc[unSortedRows.indexOf(row)];\r
+ vs[i] = new double[size];\r
}\r
\r
\r
vs[i][j] = -vs[i][j];\r
\r
}\r
- for (int i = 0; i < sortedRows.size(); i++) {\r
- int row = sortedRows.get(i);\r
+// for (int i = 0; i < sortedRows.size(); i++) {\r
+// int row = sortedRows.get(i);\r
+// int rRow = unSortedRows.get(i);\r
+// if (row != rRow) {\r
+// int ri = sortedRows.indexOf(rRow);\r
+// double v[] = vs[i];\r
+// vs[i] = vs[ri];\r
+// vs[ri] = v;\r
+// sortedRows.set(i, rRow);\r
+// sortedRows.set(ri, row);\r
+// }\r
+// }\r
+ for (int i = 0; i < unSortedRows.size(); i++) {\r
int rRow = unSortedRows.get(i);\r
- if (row != rRow) {\r
- int ri = sortedRows.indexOf(rRow);\r
- double v[] = vs[i];\r
+ \r
+ if (i < sortedRows.size()) {\r
+ int row = sortedRows.get(i);\r
+ if (row != rRow) {\r
+ int ri = sortedRows.indexOf(rRow);\r
+ double v[] = vs[i];\r
+ vs[i] = vs[ri];\r
+ vs[ri] = v;\r
+ sortedRows.set(i, rRow);\r
+ sortedRows.set(ri, row);\r
+ \r
+ }\r
+ } else {\r
+ int uci = uc[i];\r
+ int row = cToRow.getValues(uci).get(0);\r
+ int ri = sortedRows.indexOf(row);\r
vs[i] = vs[ri];\r
- vs[ri] = v;\r
- sortedRows.set(i, rRow);\r
- sortedRows.set(ri, row);\r
}\r
}\r
\r
double vs[][] = new double[unSortedRows.size()][];\r
for (int i = 0; i < unSortedRows.size(); i++) {\r
int row = unSortedRows.get(i);\r
- vs[i] = new double[count];\r
+ //vs[i] = new double[count];\r
usc[i] = infoData[row * 4 + 1];\r
uc[i] = usc[i] > 0 ? usc[i]-1 : 1-usc[i];\r
}\r
\r
- Map<Integer, Integer> cToRow = new HashMap<Integer, Integer>();\r
+ //Map<Integer, Integer> cToRow = new HashMap<Integer, Integer>();\r
+ MapList<Integer, Integer> cToRow = new MapList<Integer, Integer>();\r
List<Integer> sortedCs = new ArrayList<Integer>();\r
for (int i = 0; i < unSortedRows.size(); i++) {\r
- cToRow.put(uc[i], unSortedRows.get(i));\r
- sortedCs.add(uc[i]);\r
+ //cToRow.put(uc[i], unSortedRows.get(i));\r
+ cToRow.add(uc[i], unSortedRows.get(i));\r
+ if (!sortedCs.contains(uc[i]))\r
+ sortedCs.add(uc[i]);\r
}\r
\r
List<Integer> sortedRows = new ArrayList<Integer>();\r
- int sc[] = new int[unSortedRows.size()];\r
- int c[] = new int[unSortedRows.size()];\r
+// int sc[] = new int[unSortedRows.size()];\r
+// int c[] = new int[unSortedRows.size()];\r
+ int sc[] = new int[sortedCs.size()];\r
+ int c[] = new int[sortedCs.size()];\r
\r
Collections.sort(sortedCs);\r
- for (int i = 0; i < unSortedRows.size(); i++) {\r
- int row = cToRow.get(sortedCs.get(i));\r
+ //for (int i = 0; i < unSortedRows.size(); i++) {\r
+ for (int i = 0; i < sortedCs.size(); i++) {\r
+ //int row = cToRow.get(sortedCs.get(i));\r
+ int row = cToRow.getValues(sortedCs.get(i)).get(0);\r
sortedRows.add(row);\r
sc[i] = usc[unSortedRows.indexOf(row)];\r
c[i] = uc[unSortedRows.indexOf(row)];\r
+ vs[i] = new double[count];\r
}\r
\r
\r
\r
-// skip((c+start*rows) * 8, in);\r
-// for (int j = 0; j < v.length; ++j) {\r
-// \r
-// double d = getDouble(in);\r
-// v[j] = d;\r
-// skip((rows*skip + rows-1)*8,in);\r
-// }\r
-//\r
-// \r
-// if(sc < 0)\r
-// for(int j=0;j<v.length;++j)\r
-// v[j] = -v[j];\r
-// return v;\r
\r
skip((start*rows) * 8, in);\r
skip(c[0] * 8, in);\r
vs[i][j] = -vs[i][j];\r
\r
}\r
- for (int i = 0; i < sortedRows.size(); i++) {\r
- int row = sortedRows.get(i);\r
+ for (int i = 0; i < unSortedRows.size(); i++) {\r
int rRow = unSortedRows.get(i);\r
- if (row != rRow) {\r
- int ri = sortedRows.indexOf(rRow);\r
- double v[] = vs[i];\r
+ \r
+ if (i < sortedRows.size()) {\r
+ int row = sortedRows.get(i);\r
+ if (row != rRow) {\r
+ int ri = sortedRows.indexOf(rRow);\r
+ double v[] = vs[i];\r
+ vs[i] = vs[ri];\r
+ vs[ri] = v;\r
+ sortedRows.set(i, rRow);\r
+ sortedRows.set(ri, row);\r
+ \r
+ }\r
+ } else {\r
+ int uci = uc[i];\r
+ int row = cToRow.getValues(uci).get(0);\r
+ int ri = sortedRows.indexOf(row);\r
vs[i] = vs[ri];\r
- vs[ri] = v;\r
- sortedRows.set(i, rRow);\r
- sortedRows.set(ri, row);\r
}\r
}\r
\r