From: luukkainen Date: Thu, 30 Aug 2012 14:19:57 +0000 (+0000) Subject: refs #3659 X-Git-Tag: simantics-1.7~4^2~15 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=547b24ca6ffaf9220c2aad9f0c7db5df7a55829e;p=simantics%2Fsysdyn.git refs #3659 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@25552 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.modelica/META-INF/MANIFEST.MF b/org.simantics.modelica/META-INF/MANIFEST.MF index a3c07a6a..7fd8c199 100644 --- a/org.simantics.modelica/META-INF/MANIFEST.MF +++ b/org.simantics.modelica/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: gnu.trove2;bundle-version="2.0.4", org.eclipse.core.runtime;bundle-version="3.6.0", org.simantics.history;bundle-version="1.0.0", org.simantics.databoard;bundle-version="0.6.3", - org.simantics.utils;bundle-version="1.1.0" + org.simantics.utils;bundle-version="1.1.0", + org.simantics.utils.datastructures;bundle-version="1.1.0" Export-Package: org.simantics.modelica, org.simantics.modelica.data, org.simantics.modelica.fmi, diff --git a/org.simantics.modelica/src/org/simantics/modelica/reader/MatFileReader.java b/org.simantics.modelica/src/org/simantics/modelica/reader/MatFileReader.java index 032dbc44..84b20e64 100644 --- a/org.simantics.modelica/src/org/simantics/modelica/reader/MatFileReader.java +++ b/org.simantics.modelica/src/org/simantics/modelica/reader/MatFileReader.java @@ -16,6 +16,7 @@ import org.simantics.modelica.data.DoubleMatrix; import org.simantics.modelica.data.IntMatrix; import org.simantics.modelica.data.Matrix; import org.simantics.modelica.data.StringMatrix; +import org.simantics.utils.datastructures.MapList; public class MatFileReader implements ResultFileReader { private File file; @@ -380,28 +381,36 @@ public class MatFileReader implements ResultFileReader { double vs[][] = new double[unSortedRows.size()][]; for (int i = 0; i < unSortedRows.size(); i++) { int row = unSortedRows.get(i); - vs[i] = new double[size]; + //vs[i] = new double[size]; usc[i] = infoData[row * 4 + 1]; uc[i] = usc[i] > 0 ? usc[i]-1 : 1-usc[i]; } - Map cToRow = new HashMap(); + //Map cToRow = new HashMap(); + MapList cToRow = new MapList(); List sortedCs = new ArrayList(); for (int i = 0; i < unSortedRows.size(); i++) { - cToRow.put(uc[i], unSortedRows.get(i)); + //cToRow.put(uc[i], unSortedRows.get(i)); + cToRow.add(uc[i], unSortedRows.get(i)); sortedCs.add(uc[i]); } List sortedRows = new ArrayList(); - int sc[] = new int[unSortedRows.size()]; - int c[] = new int[unSortedRows.size()]; +// int sc[] = new int[unSortedRows.size()]; +// int c[] = new int[unSortedRows.size()]; + int sc[] = new int[sortedCs.size()]; + int c[] = new int[sortedCs.size()]; Collections.sort(sortedCs); - for (int i = 0; i < unSortedRows.size(); i++) { - int row = cToRow.get(sortedCs.get(i)); + + //for (int i = 0; i < unSortedRows.size(); i++) { + for (int i = 0; i < sortedCs.size(); i++) { + //int row = cToRow.get(sortedCs.get(i)); + int row = cToRow.getValues(sortedCs.get(i)).get(0); sortedRows.add(row); sc[i] = usc[unSortedRows.indexOf(row)]; c[i] = uc[unSortedRows.indexOf(row)]; + vs[i] = new double[size]; } @@ -430,16 +439,37 @@ public class MatFileReader implements ResultFileReader { vs[i][j] = -vs[i][j]; } - for (int i = 0; i < sortedRows.size(); i++) { - int row = sortedRows.get(i); +// for (int i = 0; i < sortedRows.size(); i++) { +// int row = sortedRows.get(i); +// int rRow = unSortedRows.get(i); +// if (row != rRow) { +// int ri = sortedRows.indexOf(rRow); +// double v[] = vs[i]; +// vs[i] = vs[ri]; +// vs[ri] = v; +// sortedRows.set(i, rRow); +// sortedRows.set(ri, row); +// } +// } + for (int i = 0; i < unSortedRows.size(); i++) { int rRow = unSortedRows.get(i); - if (row != rRow) { - int ri = sortedRows.indexOf(rRow); - double v[] = vs[i]; + + if (i < sortedRows.size()) { + int row = sortedRows.get(i); + if (row != rRow) { + int ri = sortedRows.indexOf(rRow); + double v[] = vs[i]; + vs[i] = vs[ri]; + vs[ri] = v; + sortedRows.set(i, rRow); + sortedRows.set(ri, row); + + } + } else { + int uci = uc[i]; + int row = cToRow.getValues(uci).get(0); + int ri = sortedRows.indexOf(row); vs[i] = vs[ri]; - vs[ri] = v; - sortedRows.set(i, rRow); - sortedRows.set(ri, row); } } @@ -471,45 +501,40 @@ public class MatFileReader implements ResultFileReader { double vs[][] = new double[unSortedRows.size()][]; for (int i = 0; i < unSortedRows.size(); i++) { int row = unSortedRows.get(i); - vs[i] = new double[count]; + //vs[i] = new double[count]; usc[i] = infoData[row * 4 + 1]; uc[i] = usc[i] > 0 ? usc[i]-1 : 1-usc[i]; } - Map cToRow = new HashMap(); + //Map cToRow = new HashMap(); + MapList cToRow = new MapList(); List sortedCs = new ArrayList(); for (int i = 0; i < unSortedRows.size(); i++) { - cToRow.put(uc[i], unSortedRows.get(i)); - sortedCs.add(uc[i]); + //cToRow.put(uc[i], unSortedRows.get(i)); + cToRow.add(uc[i], unSortedRows.get(i)); + if (!sortedCs.contains(uc[i])) + sortedCs.add(uc[i]); } List sortedRows = new ArrayList(); - int sc[] = new int[unSortedRows.size()]; - int c[] = new int[unSortedRows.size()]; +// int sc[] = new int[unSortedRows.size()]; +// int c[] = new int[unSortedRows.size()]; + int sc[] = new int[sortedCs.size()]; + int c[] = new int[sortedCs.size()]; Collections.sort(sortedCs); - for (int i = 0; i < unSortedRows.size(); i++) { - int row = cToRow.get(sortedCs.get(i)); + //for (int i = 0; i < unSortedRows.size(); i++) { + for (int i = 0; i < sortedCs.size(); i++) { + //int row = cToRow.get(sortedCs.get(i)); + int row = cToRow.getValues(sortedCs.get(i)).get(0); sortedRows.add(row); sc[i] = usc[unSortedRows.indexOf(row)]; c[i] = uc[unSortedRows.indexOf(row)]; + vs[i] = new double[count]; } -// skip((c+start*rows) * 8, in); -// for (int j = 0; j < v.length; ++j) { -// -// double d = getDouble(in); -// v[j] = d; -// skip((rows*skip + rows-1)*8,in); -// } -// -// -// if(sc < 0) -// for(int j=0;j