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

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

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

Matrix.transpose介绍

暂无

代码示例

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

public Map<String, Object> calculateObjects(Map<String, Object> input) {
  Map<String, Object> result = new HashMap<String, Object>();
  Matrix source = MathUtil.getMatrix(input.get(SOURCE));
  Matrix target = source.transpose();
  result.put(TARGET, target);
  return result;
}

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

public Matrix perform() {
    Matrix sq = m.transpose(Ret.ORIG).transpose(Ret.ORIG).transpose(Ret.ORIG).transpose(Ret.ORIG);
    sq.getAsDouble(0, 0);
    return sq;
  }
});

代码示例来源: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 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 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: ujmp/universal-java-matrix-package

public Object call() {
  Matrix m = getMatrixObject().getMatrix().transpose(getNewOrLink());
  return m;
}

代码示例来源: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 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: ujmp/universal-java-matrix-package

public Matrix pinv(int k) {
  Matrix[] usv = svd(k);
  Matrix u = usv[0];
  Matrix s = usv[1];
  Matrix v = usv[2];
  for (int i = (int) Math.min(s.getRowCount(), s.getColumnCount()); --i >= 0;) {
    double d = s.getAsDouble(i, i);
    if (Math.abs(d) > UJMPSettings.getInstance().getTolerance()) {
      s.setAsDouble(1.0 / d, i, i);
    } else {
      s.setAsDouble(0.0, i, i);
    }
  }
  return v.mtimes(s.transpose()).mtimes(u.transpose());
}

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

public Matrix predictOne(Matrix input) {
  // transpose and add bias unit
  // Matrix inputWithBias = Matrix.zeros(input.getColumnCount() + 1,
  // input.getRowCount());
  // for (long i = input.getColumnCount() - 1; i != -1; i--) {
  // inputWithBias.setDouble(input.getDouble(0, i), i, 0);
  // }
  // inputWithBias.setDouble(1.0, inputWithBias.getRowCount() - 1, 0);
  addInputMatrix(input);
  for (NetworkLayer networkLayer : getNetworkLayerList()) {
    networkLayer.calculateForward();
  }
  Matrix actualOutput = getOutputMatrix().transpose();
  return actualOutput;
}

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

@Test
public void testTransposeLargeSquare() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 101);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
public void testTransposeSmallWide() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(10, 15);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
public void testTransposeLargeWide() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(100, 101);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
public void testTransposeSmallSquare() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(10, 10);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
public void testTransposeLargeTall() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(101, 100);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
public void testTransposeSmallTall() throws Exception {
  Matrix ref1 = DenseDoubleMatrix2D.Factory.randn(15, 10);
  Matrix ref2 = ref1.transpose(Ret.LINK);
  for (Class<? extends Matrix> mclass : ALLFLOATMATRIXCLASSES) {
    Matrix m1 = getMatrix(mclass, ref1);
    Matrix m2 = m1.transpose();
    assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
  }
}

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

@Test
  public void testStringTranspose() {
    Matrix m1 = new DefaultDenseStringMatrix2D(2, 1);
    m1.setAsString("string1", 0, 0);
    m1.setAsString("string2", 1, 0);
    Matrix m2 = m1.transpose();
    assertEquals("string1", m2.getAsString(0, 0));
    assertEquals("string2", m2.getAsString(0, 1));
  }
}

代码示例来源: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 final void testSVDSquareRandLarge() throws Exception {
  if (!isTestLarge()) {
    return;
  }
  Matrix a = createMatrixWithAnnotation(109, 109);
  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 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);
  }
}

相关文章

Matrix类方法