本文整理了Java中org.ujmp.core.Matrix.isSparse()
方法的一些代码示例,展示了Matrix.isSparse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.isSparse()
方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:isSparse
暂无
代码示例来源:origin: ujmp/universal-java-matrix-package
public final boolean isSparse() {
return matrix.isSparse();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public boolean isSparse() {
loadContent();
return matrix.isSparse();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public boolean isSparse() {
return getSource().isSparse();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public final void calc(final Matrix source1, final Matrix source2, final Matrix target) {
if (source1.isSparse() && source1 instanceof SparseMatrix && source2.isSparse()
&& source2 instanceof SparseMatrix) {
Mtimes.SPARSEMATRIXBOTH.calc((SparseMatrix) source1, (SparseMatrix) source2, target);
} else if (source1.isSparse() && source1 instanceof SparseMatrix) {
Mtimes.SPARSEMATRIX1.calc((SparseMatrix) source1, source2, target);
} else if (source2.isSparse() && source2 instanceof SparseMatrix) {
Mtimes.SPARSEMATRIX2.calc(source1, (SparseMatrix) source2, target);
} else if (source1 instanceof DenseDoubleMatrix2D && source2 instanceof DenseDoubleMatrix2D
&& target instanceof DenseDoubleMatrix2D) {
Mtimes.DENSEDOUBLEMATRIX2D.calc((DenseDoubleMatrix2D) source1,
(DenseDoubleMatrix2D) source2, (DenseDoubleMatrix2D) target);
} else if (source1 instanceof DenseMatrix2D && source2 instanceof DenseMatrix2D
&& target instanceof DenseMatrix2D) {
Mtimes.DENSEMATRIX2D.calc((DenseMatrix2D) source1, (DenseMatrix2D) source2,
(DenseMatrix2D) target);
} else if (source1 instanceof DenseMatrix && source2 instanceof DenseMatrix
&& target instanceof DenseMatrix) {
Mtimes.DENSEMATRIX.calc((DenseMatrix) source1, (DenseMatrix) source2,
(DenseMatrix) target);
} else {
gemm(source1, source2, target);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
return false;
if (isSparse() && m.isSparse()) {
for (long[] c : availableCoordinates()) {
Object o1 = getAsObject(c);
代码示例来源:origin: ujmp/universal-java-matrix-package
public final void calc(final Matrix source, final Matrix target) {
if (source == target) {
throw new RuntimeException("cannot transpose into original matrix");
}
if (source.isSparse() && source instanceof SparseMatrix && target.isSparse()
&& target instanceof SparseMatrix) {
Transpose.SPARSEMATRIX.calc((SparseMatrix) source, (SparseMatrix) target);
} else if (source instanceof DenseDoubleMatrix2D && target instanceof DenseDoubleMatrix2D) {
Transpose.DENSEDOUBLEMATRIX2D.calc((DenseDoubleMatrix2D) source,
(DenseDoubleMatrix2D) target);
} else if (source instanceof DenseMatrix2D && target instanceof DenseMatrix2D) {
Transpose.DENSEMATRIX2D.calc((DenseMatrix2D) source, (DenseMatrix2D) target);
} else if (source instanceof DenseMatrix && target instanceof DenseMatrix) {
Transpose.DENSEMATRIX.calc((DenseMatrix) source, (DenseMatrix) target);
} else {
VerifyUtil.verify2D(source);
VerifyUtil.verify2D(target);
VerifyUtil.verifyEquals(source.getRowCount(), target.getColumnCount(),
"matrices have wrong size");
VerifyUtil.verifyEquals(source.getColumnCount(), target.getRowCount(),
"matrices have wrong size");
for (long[] c : source.allCoordinates()) {
Object o = source.getAsObject(c);
target.setAsObject(o, Coordinates.transpose(c));
}
}
}
};
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testSparseIterator() throws Exception {
Matrix m = createMatrix(2, 2);
if (isTestSparse() && m.isSparse()) {
m = createMatrix(800000, 900000);
m.setAsDouble(1.0, 3, 4);
m.setAsDouble(2.0, 334, 2214);
m.setAsDouble(3.0, 335, 2215);
m.setAsDouble(4.0, 334232, 3434);
List<Coordinates> list = new ArrayList<Coordinates>();
for (long[] c : m.nonZeroCoordinates()) {
list.add(Coordinates.wrap(Coordinates.copyOf(c)));
}
assertEquals(4, list.size());
assertTrue(list.contains(Coordinates.wrap(3, 4)));
assertTrue(list.contains(Coordinates.wrap(334, 2214)));
assertTrue(list.contains(Coordinates.wrap(335, 2215)));
assertTrue(list.contains(Coordinates.wrap(334232, 3434)));
m.setAsDouble(0.0, 335, 2215);
list.clear();
for (long[] c : m.nonZeroCoordinates()) {
list.add(Coordinates.wrap(Coordinates.copyOf(c)));
}
assertEquals(3, list.size());
assertTrue(list.contains(Coordinates.wrap(3, 4)));
assertTrue(list.contains(Coordinates.wrap(334, 2214)));
assertTrue(list.contains(Coordinates.wrap(334232, 3434)));
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testAvailableCoordinateIterator2D() throws Exception {
Matrix m = getTestMatrix();
List<Coordinates> clist = new ArrayList<Coordinates>();
for (long[] c : m.availableCoordinates()) {
clist.add(Coordinates.wrap(c).clone());
}
if (m.isSparse()) {
assertEquals(getLabel(), 5, clist.size());
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(2, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 2)));
} else {
assertEquals(getLabel(), 9, clist.size());
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(0, 2)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(1, 2)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(2, 0)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(2, 1)));
assertTrue(getLabel(), clist.contains(Coordinates.wrap(2, 2)));
}
if (m instanceof Erasable) {
((Erasable) m).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
if (m.isSparse()) {
assertFalse(m.containsCoordinates(0, 1));
} else {
if (m.isSparse()) {
assertFalse(m.containsCoordinates(0, 2));
} else {
assertTrue(m.containsCoordinates(1, 1));
if (m.isSparse()) {
assertFalse(m.containsCoordinates(0, 1));
} else {
if (m.isSparse()) {
assertFalse(m.containsCoordinates(0, 1));
} else {
if (m.isSparse()) {
assertFalse(m.containsCoordinates(0, 1));
} else {
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testSparseTranspose() throws Exception {
Matrix m = createMatrix(2, 2);
if (isTestSparse() && m.isSparse()) {
m = createMatrix(800000, 900000);
m.setAsDouble(1, 3, 4);
m.setAsDouble(1, 334534, 4454);
assertEquals(1.0, m.getAsDouble(3, 4), TOLERANCE);
assertEquals(1.0, m.getAsDouble(334534, 4454), TOLERANCE);
m = m.transpose();
assertEquals(1.0, m.getAsDouble(4, 3), TOLERANCE);
assertEquals(1.0, m.getAsDouble(4454, 334534), TOLERANCE);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testSparseMultiplySmall() throws Exception {
Matrix m1 = createMatrix(2, 2);
Matrix m2 = null;
if (isTestSparse() && m1.isSparse()) {
m1 = createMatrix(8, 9);
m2 = createMatrix(9, 4);
m1.setAsDouble(5.0, 0, 0);
m1.setAsDouble(4.0, 1, 1);
m1.setAsDouble(1.0, 3, 4);
m1.setAsDouble(2.0, 4, 2);
m1.setAsDouble(3.0, 3, 5);
m1.setAsDouble(4.0, 4, 4);
m2.setAsDouble(7.0, 0, 0);
m2.setAsDouble(6.0, 1, 1);
m2.setAsDouble(1.0, 3, 4);
m2.setAsDouble(2.0, 4, 1);
m2.setAsDouble(3.0, 3, 2);
m2.setAsDouble(4.0, 2, 3);
Matrix m3 = m1.mtimes(m2);
Matrix m4 = m1.mtimes(Ret.LINK, true, m2);
assertEquals(m3, m4);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testSparseSetToZero() throws Exception {
Matrix m = createMatrix(2, 2);
if (isTestSparse() && m.isSparse()) {
m = createMatrix(800000, 900000);
m.setAsDouble(1.0, 3, 4);
m.setAsDouble(2.0, 334, 2214);
m.setAsDouble(3.0, 335, 2215);
m.setAsDouble(4.0, 334232, 3434);
assertEquals(1.0, m.getAsDouble(3, 4), TOLERANCE);
assertEquals(2.0, m.getAsDouble(334, 2214), TOLERANCE);
assertEquals(3.0, m.getAsDouble(335, 2215), TOLERANCE);
assertEquals(4.0, m.getAsDouble(334232, 3434), TOLERANCE);
m.setAsDouble(0.0, 335, 2215);
assertEquals(1.0, m.getAsDouble(3, 4), TOLERANCE);
assertEquals(2.0, m.getAsDouble(334, 2214), TOLERANCE);
assertEquals(0.0, m.getAsDouble(335, 2215), TOLERANCE);
assertEquals(4.0, m.getAsDouble(334232, 3434), TOLERANCE);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
Matrix m1 = createMatrix(2, 2);
Matrix m2 = null;
if (isTestSparse() && m1.isSparse()) {
m1 = createMatrix(800000, 900000);
m2 = createMatrix(900000, 400000);
内容来源于网络,如有侵权,请联系作者删除!