Package org.renjin.sexp

Examples of org.renjin.sexp.DoubleVector


  }
 
  @Test
  public void invokeFunction() throws ScriptException, NoSuchMethodException {
    engine.eval("f <- function(x) sqrt(x)");
    DoubleVector result = (DoubleVector)invocableEngine.invokeFunction("f", 4);
   
    assertThat(result.length(), equalTo(1));
    assertThat(result.get(0), equalTo(2d));
  }
View Full Code Here


  }
 
  @Test
  public void invokeMethod() throws ScriptException, NoSuchMethodException {
    Object obj = engine.eval("list(execute=sqrt)");
    DoubleVector result = (DoubleVector)invocableEngine.invokeMethod(obj, "execute", 16);
   
    assertThat(result.length(), equalTo(1));
    assertThat(result.get(0), equalTo(4d));
  }
View Full Code Here

      new DoubleSequence(1, 1, 100),
      new DoubleSequence(98, 2, 100),
      new DoubleArrayVector(5, 4, 3, 2)
    };

    DoubleVector combined = CombinedDoubleVector.combine(vectors, AttributeMap.EMPTY);

    assertThat(combined.length(), equalTo(204));
    assertThat(combined.getElementAsDouble(100), equalTo(vectors[1].getElementAsDouble(0)));
    assertThat(combined.getElementAsDouble(200), equalTo(5d));
    assertThat(combined.getElementAsDouble(203), equalTo(2d));

    // just verify that we can get all the elements without error
    for(int i=0;i!=combined.length();++i) {
      assertThat(combined.getElementAsDouble(i), not(equalTo(0d)));
    }

  }
View Full Code Here

public class TransposingMatrixTest {

@Test
  public void transposed() {
    DoubleVector x = new DoubleSequence(1,1,12);
    x = (DoubleVector)x.setAttribute(Symbols.DIM, new IntArrayVector(4,3));

    DoubleVector y = new TransposingMatrix(x, AttributeMap.dim(3, 4));
    assertThat(y.getElementAsDouble(9), equalTo(4d));
    assertThat(y.getElementAsDouble(4), equalTo(6d));
  }
View Full Code Here

TOP

Related Classes of org.renjin.sexp.DoubleVector

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.