本文整理了Java中org.ujmp.core.Matrix.times()
方法的一些代码示例,展示了Matrix.times()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.times()
方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:times
暂无
代码示例来源:origin: jdmp/java-data-mining-package
public Map<String, Object> calculateObjects(Map<String, Object> input) {
Map<String, Object> result = new HashMap<String, Object>();
Matrix output = MathUtil.getMatrix(input.get(SOURCE1));
Matrix outputdeviation = MathUtil.getMatrix(input.get(SOURCE2));
Matrix product = output.times(output);
Matrix factor1 = product.times(-1).plus(1);
Matrix target = factor1.times(outputdeviation);
result.put(TARGET, target);
return result;
}
代码示例来源:origin: jdmp/java-data-mining-package
public Map<String, Object> calculateObjects(Map<String, Object> input) {
Map<String, Object> result = new HashMap<String, Object>();
Matrix source1 = MathUtil.getMatrix(input.get(SOURCE1));
Matrix source2 = MathUtil.getMatrix(input.get(SOURCE2));
result.put(TARGET, source1.times(source2));
return result;
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public Object call() {
Matrix m = getMatrixObject().getMatrix().times(getRet(), getIgnoreMissing(),
GUIUtil.getDouble("Value to multiply by", -Double.MAX_VALUE, Double.MAX_VALUE));
return m;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public void testTimesScalarSmall() throws Exception {
Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10);
double ref2 = MathUtil.nextDouble();
Matrix ref3 = ref1.times(Ret.LINK, true, ref2);
for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
Matrix m1 = getMatrix(mclass, ref1);
Matrix m3 = m1.times(ref2);
assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE);
}
}
代码示例来源:origin: jdmp/java-data-mining-package
private Object getObject(PLevel2 factor) throws Exception {
if (factor instanceof ALevel1Level2) {
return getObject(((ALevel1Level2) factor).getLevel1());
} else if (factor instanceof AMinusLevel2) {
Matrix m = MathUtil.getMatrix(getObject(((AMinusLevel2) factor).getLevel1()));
return m.times(-1);
} else if (factor instanceof APlusLevel2) {
return getObject(((APlusLevel2) factor).getLevel1());
} else if (factor instanceof AComplementLevel2) {
Matrix m = MathUtil.getMatrix(getObject(((AComplementLevel2) factor).getLevel1()));
return m.not(Ret.NEW);
} else if (factor instanceof ABitComplementLevel2) {
// TODO
}
RuntimeException e = new RuntimeException("Unknown expression type: "
+ factor.getClass().getSimpleName());
result = new Result(e);
throw e;
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public void testTimesScalarLarge() throws Exception {
Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100);
double ref2 = MathUtil.nextDouble();
Matrix ref3 = ref1.times(Ret.LINK, true, ref2);
for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
Matrix m1 = getMatrix(mclass, ref1);
Matrix m3 = m1.times(ref2);
assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public void testTimesMatrixSmall() throws Exception {
Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(11, 10);
Matrix ref2 = DenseDoubleMatrix2D.Factory.randn(11, 10);
Matrix ref3 = ref1.times(Ret.LINK, true, ref2);
for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
Matrix m1 = getMatrix(mclass, ref1);
Matrix m2 = getMatrix(mclass, ref2);
Matrix m3 = m1.times(m2);
assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE);
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public void testTimesMatrixLarge() throws Exception {
Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100);
Matrix ref2 = DenseDoubleMatrix2D.Factory.randn(101, 100);
Matrix ref3 = ref1.times(Ret.LINK, true, ref2);
for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
Matrix m1 = getMatrix(mclass, ref1);
Matrix m2 = getMatrix(mclass, ref2);
Matrix m3 = m1.times(m2);
assertEquals(mclass.toString(), 0.0, ref3.minus(m3).getRMS(), TOLERANCE);
}
}
代码示例来源:origin: jdmp/java-data-mining-package
Matrix weightChange = product.times(eta * sampleWeight * boost);
Matrix newWeight = weight.minus(Ret.NEW, true, weightChange);
代码示例来源:origin: jdmp/java-data-mining-package
Matrix gradient = x.mtimes(diff.transpose()).times(eta / batchSize);
parameters = parameters.times(1.0 - weightDecay);
代码示例来源:origin: org.ujmp/ujmp-examples
Matrix difference = dense.minus(sparse);
Matrix matrixProduct = dense.mtimes(sparse);
Matrix scaled = dense.times(2.0);
代码示例来源:origin: ujmp/universal-java-matrix-package
Matrix difference = dense.minus(sparse);
Matrix matrixProduct = dense.mtimes(sparse);
Matrix scaled = dense.times(2.0);
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void test0Times0Matrix() throws Exception {
Matrix m1 = createMatrixWithAnnotation(5, 7);
Matrix m2 = createMatrixWithAnnotation(5, 7);
Matrix m3 = m1.times(m2);
assertTrue(getLabel(), m3.isEmpty());
if (m1 instanceof Erasable) {
((Erasable) m1).erase();
}
if (m2 instanceof Erasable) {
((Erasable) m2).erase();
}
if (m3 instanceof Erasable) {
((Erasable) m3).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public void testTimesScalar() {
Matrix matrix1 = Matrix.Factory.zeros(M1ROWS, M1ROWS);
for (int i = 0; i < M1ROWS; i++) {
matrix1.setAsDouble(1, i, i);
}
Matrix result = matrix1.times(PRODUCT);
for (int row = 0; row < result.getRowCount(); ++row) {
for (int col = 0; col < result.getColumnCount(); ++col) {
if (row == col) {
assertEquals(PRODUCT, result.getAsDouble(row, col), 0.001);
} else {
assertEquals(0.0, result.getAsDouble(row, col), 0.001);
}
}
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testXTimes0Matrix() throws Exception {
Matrix m1 = createMatrixWithAnnotation(5, 7);
Matrix m2 = createMatrixWithAnnotation(5, 7);
m1.randn(Ret.ORIG);
Matrix m3 = m1.times(m2);
assertTrue(getLabel(), m3.isEmpty());
if (m1 instanceof Erasable) {
((Erasable) m1).erase();
}
if (m2 instanceof Erasable) {
((Erasable) m2).erase();
}
if (m3 instanceof Erasable) {
((Erasable) m3).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void test0TimesXMatrix() throws Exception {
Matrix m1 = createMatrixWithAnnotation(5, 7);
Matrix m2 = createMatrixWithAnnotation(5, 7);
m2.randn(Ret.ORIG);
Matrix m3 = m1.times(m2);
assertTrue(getLabel(), m3.isEmpty());
if (m1 instanceof Erasable) {
((Erasable) m1).erase();
}
if (m2 instanceof Erasable) {
((Erasable) m2).erase();
}
if (m3 instanceof Erasable) {
((Erasable) m3).erase();
}
}
代码示例来源:origin: jdmp/java-data-mining-package
Matrix left = MathUtil.getMatrix(getObject(((ADotMultLevel3) term).getLeft()));
Matrix right = MathUtil.getMatrix(getObject(((ADotMultLevel3) term).getRight()));
return left.times(Ret.NEW, ignoreNaN, right);
} else if (term instanceof ARdivLevel3) {
Matrix left = MathUtil.getMatrix(getObject(((ARdivLevel3) term).getLeft()));
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void test0MinusXMatrix() throws Exception {
Matrix m1 = createMatrixWithAnnotation(5, 7);
Matrix m2 = createMatrixWithAnnotation(5, 7);
m2.randn(Ret.ORIG);
Matrix m3 = m1.minus(m2);
Matrix m4 = m2.times(-1);
assertEquals(getLabel(), m4, m3);
if (m1 instanceof Erasable) {
((Erasable) m1).erase();
}
if (m2 instanceof Erasable) {
((Erasable) m2).erase();
}
if (m3 instanceof Erasable) {
((Erasable) m3).erase();
}
if (m4 instanceof Erasable) {
((Erasable) m4).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testTimesScalarSmall() throws Exception {
Matrix m = createMatrixWithAnnotation(2, 2);
m.setAsDouble(1.0, 0, 0);
m.setAsDouble(2.0, 0, 1);
m.setAsDouble(3.0, 1, 0);
m.setAsDouble(4.0, 1, 1);
Matrix r = m.times(2.0);
assertEquals(getLabel(), 2.0, r.getAsDouble(0, 0), TOLERANCE);
assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
assertEquals(getLabel(), 6.0, r.getAsDouble(1, 0), TOLERANCE);
assertEquals(getLabel(), 8.0, r.getAsDouble(1, 1), TOLERANCE);
assertEquals(getLabel(), 1.0, m.getAsDouble(0, 0), TOLERANCE);
assertEquals(getLabel(), 2.0, m.getAsDouble(0, 1), TOLERANCE);
assertEquals(getLabel(), 3.0, m.getAsDouble(1, 0), TOLERANCE);
assertEquals(getLabel(), 4.0, m.getAsDouble(1, 1), TOLERANCE);
if (m instanceof Erasable) {
((Erasable) m).erase();
}
if (r instanceof Erasable) {
((Erasable) r).erase();
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
@Test
public final void testTimesScalarLarge() throws Exception {
if (!isTestLarge()) {
return;
}
Matrix m = createMatrixWithAnnotation(128, 113);
m.setAsDouble(1.0, 0, 0);
m.setAsDouble(2.0, 0, 1);
m.setAsDouble(3.0, 1, 0);
m.setAsDouble(4.0, 1, 1);
Matrix r = m.times(2.0);
assertEquals(getLabel(), 2.0, r.getAsDouble(0, 0), TOLERANCE);
assertEquals(getLabel(), 4.0, r.getAsDouble(0, 1), TOLERANCE);
assertEquals(getLabel(), 6.0, r.getAsDouble(1, 0), TOLERANCE);
assertEquals(getLabel(), 8.0, r.getAsDouble(1, 1), TOLERANCE);
assertEquals(getLabel(), 1.0, m.getAsDouble(0, 0), TOLERANCE);
assertEquals(getLabel(), 2.0, m.getAsDouble(0, 1), TOLERANCE);
assertEquals(getLabel(), 3.0, m.getAsDouble(1, 0), TOLERANCE);
assertEquals(getLabel(), 4.0, m.getAsDouble(1, 1), TOLERANCE);
if (m instanceof Erasable) {
((Erasable) m).erase();
}
if (r instanceof Erasable) {
((Erasable) r).erase();
}
}
内容来源于网络,如有侵权,请联系作者删除!