org.ujmp.core.Matrix.mtimes()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.ujmp.core.Matrix.mtimes()方法的一些代码示例,展示了Matrix.mtimes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.mtimes()方法的具体详情如下:
包路径:org.ujmp.core.Matrix
类名称:Matrix
方法名:mtimes

Matrix.mtimes介绍

暂无

代码示例

代码示例来源:origin: ujmp/universal-java-matrix-package

public M call() throws Exception {
    return (M) a.mtimes(b);
  };
};

代码示例来源: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.mtimes(source2));

    return result;

  }
}

代码示例来源:origin: jdmp/java-data-mining-package

public double getDensityUnscaled(Matrix input) {
  Matrix xmean = input.minus(meanMatrix);
  Matrix matrix = xmean.mtimes(inverse).mtimes(xmean.transpose());
  return Math.exp(-0.5 * matrix.doubleValue());
}

代码示例来源:origin: jdmp/java-data-mining-package

public double getDensity(Matrix input) {
  Matrix xmean = input.minus(meanMatrix);
  Matrix matrix = xmean.mtimes(inverse).mtimes(xmean.transpose());
  return factor * Math.exp(-0.5 * matrix.doubleValue());
}

代码示例来源:origin: jdmp/java-data-mining-package

public static double getDensityUnscaled(Matrix x, Matrix mean, Matrix covariance) {
  Matrix xmean = x.minus(mean);
  Matrix inverse = covariance.inv();
  Matrix matrix = xmean.mtimes(inverse).mtimes(xmean.transpose());
  return Math.exp(-0.5 * matrix.doubleValue());
}

代码示例来源:origin: jdmp/java-data-mining-package

public static double getDensity(Matrix x, Matrix mean, Matrix covariance) {
  Matrix xmean = x.minus(mean);
  Matrix inverse = covariance.inv();
  double f = 1.0 / Math.sqrt(covariance.det() * Math.pow(2.0 * Math.PI, x.getColumnCount()));
  Matrix matrix = xmean.mtimes(inverse).mtimes(xmean.transpose());
  return f * Math.exp(-0.5 * matrix.doubleValue());
}

代码示例来源:origin: jdmp/java-data-mining-package

public Matrix hash(Matrix input) {
  Matrix result = input.toColumnVector(Ret.NEW).mtimes(randomVectors).ge(Ret.NEW, 0);
  return result;
}

代码示例来源:origin: nativelibs4java/JavaCL

public Matrix perform() {
    Matrix sq = m.mtimes(Ret.NEW, true, m);
    sq.getAsDouble(0, 0);
    return sq;
  }
});

代码示例来源:origin: ujmp/universal-java-matrix-package

public double getDouble(long... coordinates) {
  if (pca == null) {
    Matrix[] usv;
    usv = getSource().svd();
    Matrix u = usv[0];
    Matrix s = usv[1];
    pca = u.mtimes(s);
  }
  return pca.getAsDouble(coordinates);
}

代码示例来源:origin: nativelibs4java/JavaCL

public Matrix perform() {
    Matrix power = m;
    for (int i = 1; i < pow; i++)
      power.mtimes(Ret.ORIG, true, m);
    //Matrix power = m.power(Ret.NEW, pow);
    power.getAsDouble(0, 0);
    return power;
  }
});

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void test1() {
  Matrix a = Matrix.Factory.linkToArray(new double[][] { { 1, 2, 3 }, { 4, 5, 6 },
      { 7, 8, 9 } });
  Matrix b = Matrix.Factory.linkToArray(new double[][] { { 1, 2, 3 }, { 4, 5, 6 },
      { 7, 8, 9 } });
  Matrix c_correct = a.mtimes(Ret.NEW, true, b);
  Matrix c1 = a.mtimes(b);
  assertEquals(c_correct, c1);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void test2() {
  Matrix a = Matrix.Factory.linkToArray(new double[][] { { 1, 2, 3 }, { 4, 5, 6 } });
  Matrix b = Matrix.Factory.linkToArray(new double[][] { { 1, 2 }, { 4, 5 }, { 7, 8 } });
  Matrix c_correct = a.mtimes(Ret.NEW, true, b);
  Matrix c1 = a.mtimes(b);
  assertEquals(c_correct, c1);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void test3() {
  Matrix a = Matrix.Factory.linkToArray(new double[][] { { 1, 2 }, { 4, 5 }, { 7, 8 } });
  Matrix b = Matrix.Factory.linkToArray(new double[][] { { 4, 5, 6 }, { 7, 8, 9 } });
  Matrix c_correct = a.mtimes(Ret.NEW, true, b);
  Matrix c1 = a.mtimes(b);
  assertEquals(c_correct, c1);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void testNonSquareArbitrariness() {
  Matrix a = Matrix.Factory.zeros(2, 3);
  a.setAsDouble(2, 0, 0);
  a.setAsDouble(1, 0, 1);
  a.setAsDouble(-1, 0, 2);
  a.setAsDouble(1, 1, 0);
  a.setAsDouble(2, 1, 1);
  a.setAsDouble(-1, 1, 2);
  Matrix a12 = a.ginv();
  Matrix a12a = a12.mtimes(a);
  assertTrue(a12.equals(a12a.mtimes(a12)));
  assertTrue(a.equals(a.mtimes(a12a)));
}

代码示例来源:origin: jdmp/java-data-mining-package

public Matrix predictOne(Matrix input) {
  input = input.toColumnVector(Ret.NEW);
  Matrix bias = Matrix.Factory.ones(input.getRowCount(), 1);
  Matrix data = Matrix.Factory.horCat(bias, input);
  Matrix result = getParameterMatrix().transpose().mtimes(data.transpose());
  return result.transpose();
}

代码示例来源:origin: jdmp/java-data-mining-package

public Matrix predictOne(Matrix input) {
  input = input.toColumnVector(Ret.NEW);
  Matrix x = Matrix.Factory.zeros(1, input.getColumnCount() + 1);
  for (int c = 0; c < input.getColumnCount(); c++) {
    x.setAsDouble(input.getAsDouble(0, c), 0, c + 1);
  }
  x = x.minus(mean).divide(std);
  x.setAsDouble(1, 0, 0);
  Matrix result = x.mtimes(getParameterMatrix());
  return result;
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public final void testSVDSquareRandSmall() throws Exception {
  Matrix a = createMatrixWithAnnotation(10, 10);
  if (!isSupported(a, MatrixLibraries.SVD, MatrixLayout.SQUARE, Size.SMALL, EntryType.RANDN)) {
    return;
  }
  a.randn(Ret.ORIG);
  Matrix[] svd = a.svd();
  Matrix prod = svd[0].mtimes(svd[1]).mtimes(svd[2].transpose());
  assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
  if (a instanceof Erasable) {
    ((Erasable) a).erase();
  }
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void testMultiply() {
  Matrix matrix1 = Matrix.Factory.zeros(M1ROWS, M1COLS);
  setIdentity(matrix1);
  Matrix matrix2 = Matrix.Factory.zeros(M2ROWS, M2COLS);
  setIdentity(matrix2);
  Matrix result = matrix1.mtimes(matrix2);
  Matrix desire = Matrix.Factory.zeros(M1ROWS, M2COLS);
  setIdentity(desire);
  assertTrue(result.equals(desire));
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public void testMatrixDot() {
  Matrix matrix1 = Matrix.Factory.zeros(M1COLS, M1COLS);
  for (int i = 0; i < M1COLS; i++) {
    matrix1.setAsDouble(1, i, i);
  }
  Matrix matrix2 = Matrix.Factory.zeros(M1COLS, M1COLS);
  for (int i = 0; i < M1COLS; i++) {
    matrix2.setAsDouble(1, i, i);
  }
  double result = matrix1.mtimes(matrix2).getValueSum();
  assertEquals(M1COLS, result, 0.0001);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

@Test
public final void testQRRandSquareSmall() throws Exception {
  Matrix a = createMatrixWithAnnotation(7, 7);
  a.randn(Ret.ORIG);
  Matrix[] qr = a.qr();
  Matrix prod = qr[0].mtimes(qr[1]);
  assertEquals(0.0, prod.minus(a).getRMS(), TOLERANCE);
  if (a instanceof Erasable) {
    ((Erasable) a).erase();
  }
  if (prod instanceof Erasable) {
    ((Erasable) prod).erase();
  }
}

相关文章

Matrix类方法