Package mikera.vectorz

Examples of mikera.vectorz.Op


    }
    return null;
  }
 
  public static Op create(Op a, Op b) {
    Op t1=tryOptimisedCreate(a,b);
    if (t1!=null) return t1;
   
    return new Division(a,b);
  }
View Full Code Here


    }
    return null;
  }
 
  public static Op create(Op a, Op b) {
    Op t1=tryOptimisedCreate(a,b);
    if (t1!=null) return t1;
   
    Op t2=tryOptimisedCreate(b,a);
    if (t2!=null) return t2;
   
    return new Product(a,b);
  }
View Full Code Here

    return a.derivative(x)*by+b.derivative(x)*ay;
  }
 
  @Override
  public Op getDerivativeOp() {
    Op da=a.getDerivativeOp();
    Op db=b.getDerivativeOp();
    return (da.product(b)).sum(db.product(a));
  }
View Full Code Here

      testDerivativeAt(op,x);
    }
  }
 
  @Test public void testSinh() {
    Op op=Ops.SINH;
    assertEquals(0.0,op.apply(0.0),0.0);
  }
View Full Code Here

   
    assertEquals(Ops.SIN, Ops.compose(Linear.create(0.5,0.0),Ops.compose(Linear.create(2.0,0.0), Ops.SIN)));
  }
 
  @Test public void testDerivativeChains() {
    Op sin=Ops.SIN;
    Op ddddsin=sin.getDerivativeOp().getDerivativeOp().getDerivativeOp().getDerivativeOp();
    //System.out.println(ddddsin);
    assertTrue(ddddsin==sin);

    Op cos=Ops.COS;
    assertTrue(cos.getDerivativeOp().getDerivativeOp().getDerivativeOp().getDerivativeOp()==cos);
   
    assertTrue(Ops.EXP.getDerivativeOp()==Ops.EXP);
   
    Op quad=Quadratic.create(Math.random(), Math.random(), Math.random());
    Op ddquad=quad.getDerivativeOp().getDerivativeOp();
    Op dddquad=ddquad.getDerivativeOp();
    assertEquals(Constant.class,ddquad.getClass());
    assertEquals(0.0,dddquad.apply(Math.random()),0.00001);
   
    Op sum=Constant.create(10).sum(sin);
    assertTrue(cos==sum.getDerivativeOp());
  }
View Full Code Here

  @SuppressWarnings("unused")
  public void timeOpsImmutable(int runs) {
    Vector v=Vector.createLength(8388608);
    Vectorz.fillGaussian(v);

    Op op = Ops.compose(Linear.create(2.0,0.0), Ops.compose(Ops.SQRT, Linear.create(0.0,0.375)));
    for (int i=0; i<runs; i++) {
      Vector a=(Vector) v.applyOpCopy(op);
    }   
  }
View Full Code Here

 
  public void timeOpsMutable(int runs) {
    Vector v=Vector.createLength(8388608);
    Vectorz.fillGaussian(v);

    Op op = Ops.compose(Linear.create(2.0,0.0), Ops.compose(Ops.SQRT, Linear.create(0.0,0.375)));
    for (int i=0; i<runs; i++) {
      v.applyOp(op);
    }   
  }
View Full Code Here

TOP

Related Classes of mikera.vectorz.Op

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.