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

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

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

Matrix.ginv介绍

暂无

代码示例

代码示例来源: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.ginv();
  result.put(TARGET, target);
  return result;
}

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

public Object call() {
  Matrix result = getMatrixObject().getMatrix().ginv();
  return result;
}

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

Matrix m4 = m1.ginv();
assertEquals(mclass.toString(), 0.0, ref2.minus(m2).getRMS(), TOLERANCE);
assertEquals(mclass.toString(), 0.0, ref2.minus(m3).getRMS(), TOLERANCE);

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

@Test
public void testRandomInverses() {
  Random rand = new Random(System.currentTimeMillis());
  for (int count = 0; count < 10000; ++count) {
    Matrix a = Matrix.Factory.zeros(1 + Math.abs(rand.nextInt()) % 6,
        1 + Math.abs(rand.nextInt()) % 6);
    for (int row = 0; row < a.getRowCount(); ++row) {
      for (int col = 0; col < a.getColumnCount(); ++col) {
        a.setAsDouble(rand.nextDouble(), row, col);
      }
    }
    Matrix a12 = a.ginv();
    Matrix a12a = a12.mtimes(a);
    Matrix a12aa12 = a12a.mtimes(a12);
    Matrix aa12a = a.mtimes(a12a);
    // confirm left and right side inverses:
    for (int row = 0; row < a12aa12.getRowCount(); ++row) {
      for (int col = 0; col < a12aa12.getColumnCount(); ++col) {
        assertEquals(a12.getAsDouble(row, col), a12aa12.getAsDouble(row, col), 0.001);
      }
    }
    for (int row = 0; row < aa12a.getRowCount(); ++row) {
      for (int col = 0; col < aa12a.getColumnCount(); ++col) {
        assertEquals(a.getAsDouble(row, col), aa12a.getAsDouble(row, col), 0.001);
      }
    }
  }
}

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

@Test
public void testSquareArbitrariness() {
  Matrix a = Matrix.Factory.zeros(3, 3); // example from ucla.edu
  a.setAsDouble(4, 0, 0);
  a.setAsDouble(2, 0, 1);
  a.setAsDouble(2, 0, 2);
  a.setAsDouble(4, 1, 0);
  a.setAsDouble(6, 1, 1);
  a.setAsDouble(8, 1, 2);
  a.setAsDouble(-2, 2, 0);
  a.setAsDouble(2, 2, 1);
  a.setAsDouble(4, 2, 2);
  Matrix a12 = a.ginv();
  Matrix ima12a = Ginv.arbitrariness(a, a12);
  for (int row = 0; row < ima12a.getRowCount(); ++row) {
    for (int col = 0; col < ima12a.getColumnCount(); ++col) {
      assertEquals(0.0, ima12a.getAsDouble(row, col), 0.001);
    }
  }
}

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

@Test
public void testSquareInverse() {
  Matrix a = Matrix.Factory.zeros(3, 3); // example from ucla.edu
  a.setAsDouble(4, 0, 0);
  a.setAsDouble(2, 0, 1);
  a.setAsDouble(2, 0, 2);
  a.setAsDouble(4, 1, 0);
  a.setAsDouble(6, 1, 1);
  a.setAsDouble(8, 1, 2);
  a.setAsDouble(-2, 2, 0);
  a.setAsDouble(2, 2, 1);
  a.setAsDouble(4, 2, 2);
  Matrix a12 = a.ginv();
  Matrix a12a = a12.mtimes(a);
  for (int row = 0; row < a12a.getRowCount(); ++row) {
    for (int col = 0; col < a12a.getColumnCount(); ++col) {
      if (row == col) {
        assertEquals(1.0, a12a.getAsDouble(row, col), 0.001);
      } else {
        assertEquals(0.0, a12a.getAsDouble(row, col), 0.001);
      }
    }
  }
}

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

@Test
public void testNonSquareInverse2() {
  Matrix a = Matrix.Factory.zeros(3, 3);
  a.setAsDouble(4, 0, 0);
  a.setAsDouble(2, 0, 1);
  a.setAsDouble(2, 0, 2);
  a.setAsDouble(-2, 1, 0);
  a.setAsDouble(2, 1, 1);
  a.setAsDouble(4, 1, 2);
  Matrix a12 = a.ginv();
  Matrix a12a = a12.mtimes(a);
  Matrix a12aa12 = a12a.mtimes(a12);
  Matrix aa12a = a.mtimes(a12a);
  for (int row = 0; row < a12aa12.getRowCount(); ++row) {
    for (int col = 0; col < a12aa12.getColumnCount(); ++col) {
      assertEquals(a12.getAsDouble(row, col), a12aa12.getAsDouble(row, col), 0.001);
    }
  }
  for (int row = 0; row < aa12a.getRowCount(); ++row) {
    for (int col = 0; col < aa12a.getColumnCount(); ++col) {
      assertEquals(a.getAsDouble(row, col), aa12a.getAsDouble(row, col), 0.001);
    }
  }
}

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

@Test
  public void testSquareInverse2() {
    Matrix a = Matrix.Factory.zeros(3, 3);
    a.setAsDouble(2, 0, 0);
    a.setAsDouble(2, 0, 1);
    a.setAsDouble(4, 0, 2);
    a.setAsDouble(2, 1, 0);
    a.setAsDouble(4, 1, 1);
    a.setAsDouble(6, 1, 2);
    a.setAsDouble(-2, 2, 0);
    a.setAsDouble(-2, 2, 1);
    a.setAsDouble(-4, 2, 2);
    Matrix a12 = a.ginv();
    Matrix a12a = a12.mtimes(a);
    Matrix a12aa12 = a12a.mtimes(a12);
    Matrix aa12a = a.mtimes(a12a);
    for (int row = 0; row < a12aa12.getRowCount(); ++row) {
      for (int col = 0; col < a12aa12.getColumnCount(); ++col) {
        assertEquals(a12.getAsDouble(row, col), a12aa12.getAsDouble(row, col), 0.001);
      }
    }
    for (int row = 0; row < aa12a.getRowCount(); ++row) {
      for (int col = 0; col < aa12a.getColumnCount(); ++col) {
        assertEquals(a.getAsDouble(row, col), aa12a.getAsDouble(row, col), 0.001);
      }
    }
  }
}

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

a.setAsDouble(4, 2, 2);
a.setAsDouble(4, 2, 3);
Matrix a12 = a.ginv();
Matrix ima12a = Ginv.arbitrariness(a, a12);
for (int row = 0; row < ima12a.getRowCount(); ++row) {

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

@Test
public final void testGinvFixedSmall() throws Exception {
  Matrix m1 = createMatrixWithAnnotation(3, 3);
  m1.setAsDouble(1.0, 0, 0);
  m1.setAsDouble(2.0, 1, 0);
  m1.setAsDouble(3.0, 2, 0);
  m1.setAsDouble(4.0, 0, 1);
  m1.setAsDouble(1.0, 1, 1);
  m1.setAsDouble(2.0, 2, 1);
  m1.setAsDouble(3.0, 0, 2);
  m1.setAsDouble(7.0, 1, 2);
  m1.setAsDouble(1.0, 2, 2);
  Matrix m2 = m1.ginv();
  assertEquals(getLabel(), -0.1970, m2.getAsDouble(0, 0), 0.001);
  assertEquals(getLabel(), 0.2879, m2.getAsDouble(1, 0), 0.001);
  assertEquals(getLabel(), 0.0152, m2.getAsDouble(2, 0), 0.001);
  assertEquals(getLabel(), 0.0303, m2.getAsDouble(0, 1), 0.001);
  assertEquals(getLabel(), -0.1212, m2.getAsDouble(1, 1), 0.001);
  assertEquals(getLabel(), 0.1515, m2.getAsDouble(2, 1), 0.001);
  assertEquals(getLabel(), 0.3788, m2.getAsDouble(0, 2), 0.001);
  assertEquals(getLabel(), -0.0152, m2.getAsDouble(1, 2), 0.001);
  assertEquals(getLabel(), -0.1061, m2.getAsDouble(2, 2), 0.001);
  if (m1 instanceof Erasable) {
    ((Erasable) m1).erase();
  }
  if (m2 instanceof Erasable) {
    ((Erasable) m2).erase();
  }
}

相关文章

Matrix类方法