public static RDouble stripKeepNames(RDouble v) { Names names = v.names(); if (v.size() == 1 && names == null) { return new ScalarDoubleImpl(v.getDouble(0)); } return new DoubleImpl(v, null, names, null); }
public static RRaw doubleToRaw( RDouble value, ConversionStatus warn) { // eager to keep error semantics eager int size = value.size(); byte[] content = new byte[size]; for (int i = 0; i < size; i++) { double dval = value.getDouble(i); content[i] = Convert.double2raw(dval, warn); } return RRaw.RRawFactory.getFor(content, value.dimensions(), value.names()); }
public static RInt double2int( RDouble value, ConversionStatus warn) { // eager to keep error semantics eager int size = value.size(); int[] content = new int[size]; for (int i = 0; i < size; i++) { double d = value.getDouble(i); content[i] = Convert.double2int(d, warn); } return RInt.RIntFactory.getFor(content, value.dimensions(), value.names()); }
public static RDouble exclude(int excludeIndex, RDouble orig) { Names names = orig.names(); if (names == null) { return new RDoubleExclusion(excludeIndex, orig); } int size = orig.size(); int nsize = size - 1; double[] content = new double[nsize]; for (int i = 0; i < excludeIndex; i++) { content[i] = orig.getDouble(i); } for (int i = excludeIndex; i < nsize; i++) { content[i] = orig.getDouble(i + 1); } return RDoubleFactory.getFor(content, null, names.exclude(excludeIndex)); }
public static RDouble copy(RDouble d) { if (d.size() == 1 && d.dimensions() == null && d.names() == null && d.attributes() == null) { return new ScalarDoubleImpl(d.getDouble(0)); } return new DoubleImpl(d, false); }