本文整理了Java中org.ujmp.core.Matrix.selectRows()
方法的一些代码示例,展示了Matrix.selectRows()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.selectRows()
方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:selectRows
暂无
代码示例来源:origin: ujmp/universal-java-matrix-package
public double getDouble(long... coordinates) {
Matrix m1 = getSource().selectRows(Ret.LINK, coordinates[ROW]);
Matrix m2 = getSource().selectRows(Ret.LINK, coordinates[COLUMN]);
return m1.minkowskiDistanceTo(m2, p, ignoreNaN);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
private List<Sortable<Double, Matrix>> getSortedNeighbors(long... coordinates) {
List<Sortable<Double, Matrix>> neighbors = new ArrayList<Sortable<Double, Matrix>>();
List<Integer> candidates = getCandidates(coordinates);
for (int candidateRow : candidates) {
double dist = distanceMatrix.getAsDouble(coordinates[ROW], candidateRow);
Matrix candidate = getSource().selectRows(Ret.LINK, candidateRow);
neighbors.add(new Sortable<Double, Matrix>(dist, candidate));
}
Collections.sort(neighbors);
return neighbors;
}
代码示例来源:origin: jdmp/java-data-mining-package
public synchronized Matrix get(Object key) {
Matrix m = map.get(key);
if (m == null) {
Matrix all = dataSet.getMatrix(key);
if (all == null) {
return null;
} else if (all.getRowCount() < dataSet.size()) {
return null;
} else {
m = all.selectRows(Ret.LINK, index);
map.put(String.valueOf(key), m);
}
}
return m;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public Object getObject(long... coordinates) {
if (selection == null) {
List<Integer> rows = new ArrayList<Integer>();
for (int i = 0; i < getSource().getRowCount(); i++) {
rows.add(i);
}
Collections.shuffle(rows);
selection = getSource().selectRows(Ret.LINK, rows);
}
return selection.getAsObject(coordinates);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public Object getObject(long... coordinates) {
if (selection == null) {
List<Integer> rows = new ArrayList<Integer>();
for (int i = 0; i < count; i++) {
int s = MathUtil.nextInteger(0, (int) getSource().getRowCount());
rows.add(s);
}
selection = getSource().selectRows(Ret.LINK, rows);
}
return selection.getAsObject(coordinates);
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public double getDouble(long... coordinates) {
Matrix m1 = getSource().selectRows(Ret.LINK, coordinates[ROW]);
Matrix m2 = getSource().selectRows(Ret.LINK, coordinates[COLUMN]);
double aiSum = 0;
double a2Sum = 0;
double b2Sum = 0;
for (long i = 0; i < m1.getColumnCount(); i++) {
double a = m1.getAsDouble(0, i);
double b = m2.getAsDouble(0, i);
if (ignoreNaN) {
if (!MathUtil.isNaNOrInfinite(a) && !MathUtil.isNaNOrInfinite(b)) {
aiSum += a * b;
a2Sum += a * a;
b2Sum += b * b;
}
} else {
aiSum += a * b;
a2Sum += a * a;
b2Sum += b * b;
}
}
return aiSum / (Math.sqrt(a2Sum) * Math.sqrt(b2Sum));
}
代码示例来源:origin: ujmp/universal-java-matrix-package
private Matrix getDistanceMatrix() {
Matrix distanceMatrix = Matrix.Factory.zeros(getSource().getRowCount(), getSource()
.getRowCount());
for (int r = 0; r < getSource().getRowCount(); r++) {
for (int c = 0; c < getSource().getRowCount(); c++) {
if (r != c) {
Matrix m1 = getSource().selectRows(Ret.LINK, r);
Matrix m2 = getSource().selectRows(Ret.LINK, c);
double dist = m1.euklideanDistanceTo(m2, true);
distanceMatrix.setAsDouble(dist, r, c);
}
}
}
return distanceMatrix;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public void saveSettings() throws Exception {
String resultDir = BenchmarkUtil.getResultDir(getConfig());
File envFile = new File(resultDir + File.separator + "env.csv");
File propFile = new File(resultDir + File.separator + "props.csv");
File confFile = new File(resultDir + File.separator + "conf.csv");
File versionFile = new File(resultDir + File.separator + "versions.csv");
new SystemEnvironmentMatrix().exportTo().file(envFile).asDenseCSV();
Matrix props = new SystemPropertiesMatrix().replaceRegex(Ret.NEW, "\r\n", " ");
props = props.replaceRegex(Ret.NEW, "\n", " ");
props.exportTo().file(propFile).asDenseCSV();
getConfig().exportTo().file(confFile).asDenseCSV();
Matrix libraries = new MatrixLibraries();
System.out.println(libraries);
Matrix versions = libraries.selectRows(Ret.NEW, 0, 1).transpose();
versions.exportTo().file(versionFile).asDenseCSV();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
Matrix columnLabels = m.selectRows(Ret.NEW, 0); // extract label
Matrix row = allmeans.selectRows(Ret.NEW, jamaRow);
Matrix m = Matrix.Factory.vertCat(row, allmeans.getRowCount());
Matrix scaled = allmeans.divide(Ret.NEW, false, m).power(Ret.NEW, -1)
代码示例来源:origin: ujmp/universal-java-matrix-package
public ExtractAnnotation(Matrix m, int dim) {
super(dim, m);
size = Coordinates.copyOf(m.getSize());
size[dim]--;
setMetaData(new DefaultMapMatrix<String, Object>(new TreeMap<String, Object>()));
getMetaData().put(Matrix.LABEL, m.getLabelObject());
if (dim == ROW) {
MapMatrix<String, Object> a = m.getMetaData();
if (a != null) {
Matrix ai = (Matrix) a.get(Matrix.DIMENSIONMETADATA + COLUMN);
if (ai != null) {
ai = ai.deleteRows(Ret.NEW, 0);
getMetaData().put(Matrix.DIMENSIONMETADATA + COLUMN, ai);
}
}
getMetaData().put(Matrix.DIMENSIONMETADATA + ROW, m.selectRows(Ret.NEW, 0));
} else if (dim == COLUMN) {
MapMatrix<String, Object> a = m.getMetaData();
if (a != null) {
Matrix ai = (Matrix) a.get(Matrix.DIMENSIONMETADATA + ROW);
if (ai != null) {
ai = ai.selectColumns(Ret.NEW, 0);
getMetaData().put(Matrix.DIMENSIONMETADATA + ROW, ai);
}
}
getMetaData().put(Matrix.DIMENSIONMETADATA + COLUMN, m.selectColumns(Ret.NEW, 0));
} else {
throw new RuntimeException("only supported for 2D matrices");
}
}
内容来源于网络,如有侵权,请联系作者删除!