Package mikera.vectorz

Examples of mikera.vectorz.Vector


    private boolean isOrthogonal( Matrix Q , double tol ) {
       if( Q.rowCount() < Q.columnCount() ) {
            throw new IllegalArgumentException("The number of rows must be more than or equal to the number of columns");
        }

        Vector u[] = columnsToVector(Q);

        for( int i = 0; i < u.length; i++ ) {
            Vector a = u[i];

            for( int j = i+1; j < u.length; j++ ) {
//                double val = VectorVectorMult.innerProd(a,u[j]);
                double val = a.innerProduct(u[j]).get();
                if( !(Math.abs(val) <= tol))
                    return false;
            }
        }
View Full Code Here


    public Vector[] columnsToVector(Matrix A) {
      Vector[] ret = new Vector[A.columnCount()];
        for( int i = 0; i < ret.length; i++ ) {
          ret[i] = Vector.createLength(A.rowCount());

            Vector u = ret[i];

            for( int j = 0; j < A.rowCount(); j++ ) {
                u.set(j, A.get(j,i));
            }
        }

        return ret;
    }
View Full Code Here

 
  private static final Vector source=new Vector( Vectorz.createUniformRandomVector(1000+VECTOR_SIZE));
 
 
  public void timeVectorAddition(int runs) {
    Vector v=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    Vector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.add(v2);
    }
  }
View Full Code Here

      v.add(v2);
    }
  }
 
  public void timeVectorAddProduct(int runs) {
    Vector v=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    Vector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    Vector v3=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.addProduct(v2,v3);
    }
  }
View Full Code Here

      v.addProduct(v2,v3);
    }
  }
 
  public Object timeAVectorDotProduct(int runs) {
    AVector v=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    AVector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    double r=0.0;
    for (int i=0; i<runs; i++) {
      r+=v.dotProduct(v2);
    }
    return r;
View Full Code Here

    }
    return r;
  }
 
  public void timeVectorOffsetAddition(int runs) {
    Vector v=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.add(source,100);
    }
  }
View Full Code Here

 
  public void timeJoinedVectorSet(int runs) {
    AVector v=Vectorz.newVector(VECTOR_SIZE/2);
    v=v.join(Vectorz.newVector(VECTOR_SIZE-v.length()));

    Vector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.set(v2);
    }
  }
View Full Code Here

import org.junit.Test;

public class TestDenseVectors {
  @Test public void test1() {
    Vector v=Vector.of(0,1,2,3,4,5);
    v.subVector(1, 2).addMultiple(Vector.of(10,20), 2);
    assertEquals(Vector.of(0,21,42,3,4,5),v);
   
    v.subVector(1, 2).addMultiple(Vector.of(0,10,20).subVector(1,2), -2);
    assertEquals(Vector.of(0,1,2,3,4,5),v);

  }
View Full Code Here

 
  public void timeJoinedVectorAddition(int runs) {
    AVector v=Vectorz.newVector(VECTOR_SIZE/2);
    v=v.join(Vectorz.newVector(VECTOR_SIZE-v.length()));

    Vector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.add(v2);
    }
  }
View Full Code Here

 
  public void timeJoinedVectorAddMultiple(int runs) {
    AVector v=Vectorz.newVector(VECTOR_SIZE/2);
    v=v.join(Vectorz.newVector(VECTOR_SIZE-v.length()));

    Vector v2=new Vector(Vectorz.createUniformRandomVector(VECTOR_SIZE));
    for (int i=0; i<runs; i++) {
      v.addMultiple(v2,0.5);
    }
  }
View Full Code Here

TOP

Related Classes of mikera.vectorz.Vector

Copyright © 2018 www.massapicom. 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.