本文整理汇总了Java中org.renjin.sexp.DoubleVector类的典型用法代码示例。如果您正苦于以下问题:Java DoubleVector类的具体用法?Java DoubleVector怎么用?Java DoubleVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleVector类属于org.renjin.sexp包,在下文中一共展示了DoubleVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processMatrixValue
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
private static Value processMatrixValue(Matrix matrix) {
ArrayBuilder ab = new ArrayBuilder();
ArrayBuilder innerBuilder = null;
Vector rawVector = matrix.getVector();
int rowIndex = 0;
for(int i = 0; i < rawVector.length(); i++, rowIndex++) {
if(innerBuilder == null) {
innerBuilder = new ArrayBuilder();
}
if((rowIndex / matrix.getNumRows()) < matrix.getNumRows()) {
if(rawVector instanceof DoubleVector) {
innerBuilder.append(Dbl.get(rawVector.getElementAsDouble(i)));
} else {
innerBuilder.append(Dbl.get(rawVector.getElementAsInt(i)));
}
} else {
ab.append(innerBuilder.freeze());
innerBuilder = null;
rowIndex = 0;
}
}
return ab.freeze();
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:27,代码来源:XqRenjinModule.java
示例2: vectorToBuilder
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static Builder vectorToBuilder(Vector vector, int size) {
Builder out = null;
if(vector instanceof StringVector) {
out = new StringArrayVector.Builder(size);
} else if(vector instanceof LogicalVector) {
out = new LogicalArrayVector.Builder(size);
} else if(vector instanceof IntVector) {
out = new IntArrayVector.Builder(size);
} else if(vector instanceof ComplexVector) {
out = new ComplexVector.Builder(size);
} else if(vector instanceof DoubleVector) {
out = new DoubleArrayVector.Builder(size);
}
return out;
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:17,代码来源:XqRenjinModule.java
示例3: psigamma
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double psigamma(double x, double deriv) {
/* n-th derivative of psi(x); e.g., psigamma(x,0) == digamma(x) */
int k, n;
if (DoubleVector.isNaN(x)) {
return x;
}
deriv = Math.floor(deriv + 0.5);
n = (int) deriv;
//if(n > n_max) {
//MATHLIB_WARNING2(_("deriv = %d > %d (= n_max)\n"), n, n_max);
//return ML_NAN;
//}
double[] ans = new double[1];
double[] xd = new double[]{x};
int[] nz = new int[1];
int[] ierr = new int[1];
dpsifn.dpsifn(x, n, 1, 1, ans, nz, ierr);
//ML_TREAT_psigam(ierr);
/* Now, ans == A := (-1)^(n+1) / gamma(n+1) * psi(n, x) */
ans[0] = -ans[0]; /* = (-1)^(0+1) * gamma(0+1) * A */
for (k = 1; k <= n; k++) {
ans[0] *= (-k);/* = (-1)^(k+1) * gamma(k+1) * A */
}
return ans[0];/* = psi(n, x) */
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:27,代码来源:PsiGamma.java
示例4: pnbeta
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double pnbeta(double x, double a, double b, double ncp, boolean lower_tail, boolean log_p) {
if (DoubleVector.isNaN(x) || DoubleVector.isNaN(a) || DoubleVector.isNaN(b) || DoubleVector.isNaN(ncp)) {
return x + a + b + ncp;
}
//R_P_bounds_01(x, 0., 1.);
if (x <= 0.0) {
return SignRank.R_DT_0(lower_tail, log_p);
}
if (x >= 1.0) {
return SignRank.R_DT_1(lower_tail, log_p);
}
return pnbeta2(x, 1 - x, a, b, ncp, lower_tail, log_p);
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:18,代码来源:Beta.java
示例5: dlnorm
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double dlnorm(double x, double meanlog, double sdlog, boolean give_log) {
double y;
if (DoubleVector.isNaN(x) || DoubleVector.isNaN(meanlog) || DoubleVector.isNaN(sdlog)) {
return x + meanlog + sdlog;
}
if (sdlog <= 0) {
return DoubleVector.NaN;
}
//if(x <= 0) return R_D__0;
if (x <= 0) {
return SignRank.R_D__0(true, give_log);
}
y = (Math.log(x) - meanlog) / sdlog;
return (give_log ? -(Math.log(Math.sqrt(2 * Math.PI)) + 0.5 * y * y + Math.log(x * sdlog))
: (1 / Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * y * y) / (x * sdlog));
/* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:24,代码来源:LNorm.java
示例6: dpois_raw
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double dpois_raw(double x, double lambda, boolean give_log) {
/* x >= 0 ; integer for dpois(), but not e.g. for pgamma()!
lambda >= 0
*/
if (lambda == 0) {
return ((x == 0) ? SignRank.R_D__1(true, give_log) : SignRank.R_D__0(true, give_log));
}
if (!DoubleVector.isFinite(lambda)) {
return SignRank.R_D__0(true, give_log);
}
if (x < 0) {
return (SignRank.R_D__0(true, give_log));
}
if (x <= lambda * Double.MIN_VALUE) {
return (SignRank.R_D_exp(-lambda, true, give_log));
}
if (lambda < x * Double.MIN_VALUE) {
return (SignRank.R_D_exp(-lambda + x * Math.log(lambda) - Gamma.logGamma(x + 1), true, give_log));
}
return (SignRank.R_D_fexp(2 * Math.PI * x, -Binom.stirlerr(x) - Binom.bd0(x, lambda), true, give_log));
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:22,代码来源:Poisson.java
示例7: bd0
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double bd0(double x, double np) {
double ej, s, s1, v;
int j;
if (!DoubleVector.isFinite(x) || !DoubleVector.isFinite(np) || np == 0.0) {
return DoubleVector.NaN;
}
if (Math.abs(x - np) < 0.1 * (x + np)) {
v = (x - np) / (x + np);
s = (x - np) * v;/* s using v -- change by MM */
ej = 2 * x * v;
v = v * v;
for (j = 1;; j++) { /* Taylor series */
ej *= v;
s1 = s + ej / ((j << 1) + 1);
if (s1 == s) /* last term was effectively 0 */ {
return (s1);
}
s = s1;
}
}
/* else: | x - np | is not too small */
return (x * Math.log(x / np) + np - x);
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:26,代码来源:Binom.java
示例8: getElementAsDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public double getElementAsDouble(int index) {
int i0;
if (index<argLength0) {
i0 = index;
} else {
i0 = (index%argLength0);
}
double arg0_i = arg0 .getElementAsDouble(i0);
if (DoubleVector.isNA(arg0_i)) {
return DoubleVector.NA;
}
int i1;
if (index<argLength1) {
i1 = index;
} else {
i1 = (index%argLength1);
}
double arg1_i = arg1 .getElementAsDouble(i1);
if (DoubleVector.isNA(arg1_i)) {
return DoubleVector.NA;
}
return Ops.plus(arg0_i, arg1_i);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:24,代码来源:R$primitive$$plus$deferred_dd.java
示例9: getElementAsDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public double getElementAsDouble(int index) {
int i0;
if (index<argLength0) {
i0 = index;
} else {
i0 = (index%argLength0);
}
double arg0_i = arg0 .getElementAsDouble(i0);
if (DoubleVector.isNA(arg0_i)) {
return DoubleVector.NA;
}
int i1;
if (index<argLength1) {
i1 = index;
} else {
i1 = (index%argLength1);
}
double arg1_i = arg1 .getElementAsDouble(i1);
if (DoubleVector.isNA(arg1_i)) {
return DoubleVector.NA;
}
return MathExt.beta(arg0_i, arg1_i);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:24,代码来源:R$primitive$beta$deferred_dd.java
示例10: doApply
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1)
throws Exception
{
if ((arg0 instanceof Vector)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector))) {
return Subsetting.getSingleElement(((Vector) arg0), WrapperRuntime.convertToInt(arg1));
} else {
if ((arg0 instanceof Vector)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((Vector) arg0), WrapperRuntime.convertToString(arg1));
} else {
if ((arg0 instanceof PairList.Node)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector))) {
return Subsetting.getSingleElement(((PairList.Node) arg0), WrapperRuntime.convertToInt(arg1));
} else {
if ((arg0 instanceof PairList.Node)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((PairList.Node) arg0), WrapperRuntime.convertToString(arg1));
} else {
if ((arg0 instanceof Environment)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((Environment) arg0), WrapperRuntime.convertToString(arg1));
} else {
throw new EvalException(String.format("Invalid argument:\n\t[[(%s, %s)\n\tExpected:\n\t[[(Vector, integer(1))\n\t[[(pairlist, integer(1))\n\t[[(pairlist, character(1))\n\t[[(Environment, character(1))\n\t[[(Vector, character(1))\n\t[[(pairlist, character(1), logical(1))\n\t[[(Vector, character(1), logical(1))", arg0 .getTypeName(), arg1 .getTypeName()));
}
}
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:26,代码来源:R$primitive$$bracket$bracket.java
示例11: getElementAsDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public double getElementAsDouble(int index) {
int i0;
if (index<argLength0) {
i0 = index;
} else {
i0 = (index%argLength0);
}
double arg0_i = arg0 .getElementAsDouble(i0);
if (DoubleVector.isNA(arg0_i)) {
return DoubleVector.NA;
}
int i1;
if (index<argLength1) {
i1 = index;
} else {
i1 = (index%argLength1);
}
double arg1_i = arg1 .getElementAsDouble(i1);
if (DoubleVector.isNA(arg1_i)) {
return DoubleVector.NA;
}
return Ops.divide(arg0_i, arg1_i);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:24,代码来源:R$primitive$$div$deferred_dd.java
示例12: doApply
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0)
throws Exception
{
if (((arg0 instanceof IntVector)||(arg0 instanceof DoubleVector))||(arg0 instanceof LogicalVector)) {
return Types.asEnvironment(context, WrapperRuntime.convertToInt(arg0));
} else {
if (arg0 instanceof ListVector) {
return Types.asEnvironment(((ListVector) arg0));
} else {
if (arg0 instanceof Environment) {
return Types.asEnvironment(((Environment) arg0));
} else {
if (arg0 instanceof S4Object) {
return Types.asEnvironment(((S4Object) arg0));
} else {
if ((arg0 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg0))) {
return Types.asEnvironment(context, WrapperRuntime.convertToString(arg0));
} else {
throw new EvalException(String.format("Invalid argument:\n\tas.environment(%s)\n\tExpected:\n\tas.environment(Environment)\n\tas.environment(integer(1))\n\tas.environment(character(1))\n\tas.environment(list)\n\tas.environment(S4Object)", arg0 .getTypeName()));
}
}
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:26,代码来源:R$primitive$as$environment.java
示例13: getElementAsDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public double getElementAsDouble(int index) {
int i0;
if (index<argLength0) {
i0 = index;
} else {
i0 = (index%argLength0);
}
double arg0_i = arg0 .getElementAsDouble(i0);
if (DoubleVector.isNA(arg0_i)) {
return DoubleVector.NA;
}
int i1;
if (index<argLength1) {
i1 = index;
} else {
i1 = (index%argLength1);
}
double arg1_i = arg1 .getElementAsDouble(i1);
if (DoubleVector.isNA(arg1_i)) {
return DoubleVector.NA;
}
return MathExt.atan2(arg0_i, arg1_i);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:24,代码来源:R$primitive$atan2$deferred_dd.java
示例14: doApply
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1)
throws Exception
{
if ((arg0 instanceof IntVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((IntVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
if ((arg0 instanceof DoubleVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((DoubleVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
if ((arg0 instanceof StringVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((StringVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
throw new EvalException(String.format("Invalid argument:\n\tsort(%s, %s)\n\tExpected:\n\tsort(IntVector, logical(1))\n\tsort(character, logical(1))\n\tsort(DoubleVector, logical(1))", arg0 .getTypeName(), arg1 .getTypeName()));
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:18,代码来源:R$primitive$sort.java
示例15: doApply
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4)
throws Exception
{
if (((((arg0 instanceof SEXP)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector)))&&(arg2 instanceof Vector))&&(arg3 instanceof Vector))&&((arg4 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg4)))) {
return Connections.readLines(context, ((SEXP) arg0), WrapperRuntime.convertToInt(arg1), WrapperRuntime.convertToBooleanPrimitive(arg2), WrapperRuntime.convertToBooleanPrimitive(arg3), WrapperRuntime.convertToString(arg4));
} else {
throw new EvalException(String.format("Invalid argument:\n\treadLines(%s, %s, %s, %s, %s)\n\tExpected:\n\treadLines(any, integer(1), logical(1), logical(1), character(1))", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName(), arg4 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$readLines.java
示例16: getElementAsDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public double getElementAsDouble(int index) {
int i0;
if (index<argLength0) {
i0 = index;
} else {
i0 = (index%argLength0);
}
double arg0_i = arg0 .getElementAsDouble(i0);
if (DoubleVector.isNA(arg0_i)) {
return DoubleVector.NA;
}
int i1;
if (index<argLength1) {
i1 = index;
} else {
i1 = (index%argLength1);
}
double arg1_i = arg1 .getElementAsDouble(i1);
if (DoubleVector.isNA(arg1_i)) {
return DoubleVector.NA;
}
return Ops.power(arg0_i, arg1_i);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:24,代码来源:R$primitive$$up$deferred_dd.java
示例17: asDouble
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
@Generic
@Primitive("as.double")
public static DoubleVector asDouble(Environment env) {
Frame frame = env.getFrame();
if (frame instanceof ObjectFrame) {
ObjectFrame oframe = (ObjectFrame) frame;
Object instance = oframe.getInstance();
Class clazz = instance.getClass();
if (DoubleConverter.accept(clazz)) {
return (DoubleVector) DoubleConverter.INSTANCE
.convertToR((Double) instance);
} else if (DoubleArrayConverter.accept(clazz)) {
return (DoubleVector)new DoubleArrayConverter(clazz)
.convertToR((Double[]) instance);
}
}
throw new EvalException(
"unsurpported converter,only environment with double[] ObjectFrame is implemented");
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:20,代码来源:Types.java
示例18: doApply
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3)
throws Exception
{
if ((((arg0 instanceof SEXP)&&(arg1 instanceof Vector))&&(((arg2 instanceof IntVector)||(arg2 instanceof DoubleVector))||(arg2 instanceof LogicalVector)))&&(arg3 instanceof Vector)) {
return AllNamesVisitor.allNames(((SEXP) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1), WrapperRuntime.convertToInt(arg2), WrapperRuntime.convertToBooleanPrimitive(arg3));
} else {
throw new EvalException(String.format("Invalid argument:\n\tall.names(%s, %s, %s, %s)\n\tExpected:\n\tall.names(any, logical(1), integer(1), logical(1))", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$all$names.java
示例19: XqRenjinMatrix
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public XqRenjinMatrix(XqRenjin renjinIn, Vector vectorIn) {
super(renjinIn, vectorIn);
matrix = new Matrix(vectorIn);
rows = matrix.getRowNames();
cols = matrix.getColNames();
isDouble = vectorIn instanceof DoubleVector;
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:10,代码来源:XqRenjinMatrix.java
示例20: pnf
import org.renjin.sexp.DoubleVector; //导入依赖的package包/类
public static double pnf(double x, double df1, double df2, double ncp, boolean lower_tail, boolean log_p) {
double y;
if (DoubleVector.isNaN(x) || DoubleVector.isNaN(df1) || DoubleVector.isNaN(df2) || DoubleVector.isNaN(ncp)) {
return x + df2 + df1 + ncp;
}
if (df1 <= 0. || df2 <= 0. || ncp < 0) {
return DoubleVector.NaN;
}
if (!DoubleVector.isFinite(ncp)) {
return DoubleVector.NaN;
}
if (!DoubleVector.isFinite(df1) && !DoubleVector.isFinite(df2)) { /* both +Inf */
return DoubleVector.NaN;
}
//R_P_bounds_01(x, 0., ML_POSINF);
if (x <= 0.0) {
return SignRank.R_DT_0(lower_tail, log_p);
}
if (x >= Double.POSITIVE_INFINITY) {
return SignRank.R_DT_1(lower_tail, log_p);
}
if (df2 > 1e8) /* avoid problems with +Inf and loss of accuracy */ {
return Distributions.pnchisq(x * df1, df1, ncp, lower_tail, log_p);
}
y = (df1 / df2) * x;
return Beta.pnbeta2(y / (1. + y), 1. / (1. + y), df1 / 2., df2 / 2.,
ncp, lower_tail, log_p);
}
开发者ID:CompEvol,项目名称:beastshell,代码行数:32,代码来源:F.java
注:本文中的org.renjin.sexp.DoubleVector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论