protected boolean expand( int oldRowSize, int oldColumnSize, int newRowSize, int newColumnSize, WeightGenerator generator) { if (newRowSize < oldRowSize) newRowSize = oldRowSize; if (newColumnSize < oldColumnSize) newColumnSize = oldColumnSize; boolean expanded = false; // expand columns if (oldColumnSize < newColumnSize) { int i, j, diff = newColumnSize - oldColumnSize, size = oldRowSize * newColumnSize; for (i = oldColumnSize; i < size; i += newColumnSize) for (j = 0; j < diff; j++) weights.add(i + j, generator == null ? 0 : generator.next()); setColumnSize(newColumnSize); expanded = true; } // expand label dimension if (oldRowSize < newRowSize) { int i, size = newRowSize * newColumnSize; for (i = weights.size(); i < size; i++) weights.add(generator == null ? 0 : generator.next()); setRowSize(newRowSize); expanded = true; } return expanded; }
/** @return a copy of this vector where all the values are initialized to 0. */ public MajorVector createZeroVector() { MajorVector vector = createInstance(); vector.setSizes(label_size, feature_size); vector.weights = new FloatGapList(); for (int i = 0; i < weights.size(); i++) vector.weights.add(0); return vector; }
public float get(int index) { return weights.get(index); }
@Override public String toString() { return weights.toString(); }
public int size() { return weights.size(); }
public void set(int index, float value) { weights.set(index, value); }