Package org.apache.mahout.math

Examples of org.apache.mahout.math.Matrix.viewDiagonal()


public class UpperTriangularTest extends MahoutTestCase {
  @Test
  public void testBasics() {
    Matrix a = new UpperTriangular(new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, false);
    assertEquals(0, a.viewDiagonal().minus(new DenseVector(new double[]{1, 5, 8, 10})).norm(1), 1.0e-10);
    assertEquals(0, a.viewPart(0, 3, 1, 3).viewDiagonal().minus(
        new DenseVector(new double[]{2, 6, 9})).norm(1), 1.0e-10);
    assertEquals(4, a.get(0, 3), 1.0e-10);
    print(a);
    Matrix m = new DenseMatrix(4, 4).assign(a);
View Full Code Here


   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
      } else if (v < 0) {
View Full Code Here

   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
      } else if (v < 0) {
View Full Code Here

   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      final double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
      } else if (v < 0) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.