Commit 96ba0df2 authored by Peter Wittek's avatar Peter Wittek

Avoid deep matrix copy in updating row seriation

parent b238e83b
......@@ -96,7 +96,7 @@ public class DynamicBiseriation extends Biseriation {
DynamicBiseriation dynamicBiseriation = new DynamicBiseriation(
collection, distance, heuristic);
dynamicBiseriation.calculateBiseriationOfStaticPart();
while (args.length>argc){
String collectionUpdate = args[argc++];
dynamicBiseriation.addCollectionUpdate(collectionUpdate);
......@@ -132,10 +132,7 @@ public class DynamicBiseriation extends Biseriation {
public void addCollectionUpdate(String collectionUpdate)
throws IOException {
updates = SparseVector.readSparseMatrix(collectionUpdate);
}
private void addRow(VectorNode[] vector) {
rowSeriation.foldInNewInstance(vector);
rowSeriation.mergeUpdates(updates);
}
/**
......@@ -146,7 +143,7 @@ public class DynamicBiseriation extends Biseriation {
*/
public void iterativelyUpdate() throws IOException {
for (int i = 0; i < updates.length; i++) {
addRow(updates[i]);
rowSeriation.foldInNewInstance(updates[i]);
updateFeatureSpaceSeriation();
}
global_update_iteration += updates.length;
......
......@@ -54,14 +54,19 @@ public abstract class DistributionalOrder extends LinearOrder {
return nInstances / 2;
}
public void foldInNewInstance(VectorNode[] newInstance) {
nInstances++;
VectorNode[][] newMx = new VectorNode[nInstances][];
for (int i = 0; i < mx.length; i++) {
public void mergeUpdates(VectorNode[][] updates) {
VectorNode[][] newMx = new VectorNode[nInstances+updates.length][];
for (int i = 0; i < mx.length; ++i) {
newMx[i] = mx[i];
}
newMx[nInstances - 1] = newInstance;
for (int i = 0; i < updates.length; ++i) {
newMx[mx.length + i] = updates[i];
}
mx = newMx;
}
public void foldInNewInstance(VectorNode[] newInstance) {
nInstances++;
order.add(findBestSlot(nInstances - 1), nInstances - 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment