CSIPMLData.java [src/java/crp/utils] Revision: default Date:
package crp.utils;
import java.util.List;
import org.encog.ml.data.MLData;
import org.encog.ml.data.basic.BasicMLDataCentroid;
import org.encog.util.kmeans.Centroid;
public class CSIPMLData implements MLData {
// single permutation, one value for each input node
private double[] data;
public CSIPMLData(MLData data) {
this.data = data.getData();
}
public CSIPMLData(List<Double> data) {
this.data = Calc.toDoubleArray(data);
}
@Override
public void add(int index, double value) {
data[index] += value;
}
@Override
public void clear() {
for (int i = 0; i < data.length; i++) {
data[i] = 0;
}
}
@Override
public MLData clone() {
return new CSIPMLData(this);
}
@Override
public double[] getData() {
return data;
}
@Override
public double getData(int index) {
return data[index];
}
@Override
public void setData(double[] data) {
this.data = data;
}
@Override
public void setData(int index, double d) {
data[index] = d;
}
@Override
public int size() {
return data.length;
}
@Override
public Centroid<MLData> createCentroid() {
return new BasicMLDataCentroid(this);
}
}