@Specialization( guards = {"x.getLength() == 1", "times.getLength() == 1", "each <= 1", "!hasNames(x)"}) protected RAbstractVector repNoEachNoNamesSimple( RAbstractDoubleVector x, RAbstractIntVector times, int lengthOut, @SuppressWarnings("unused") int each) { int t = times.getDataAt(0); if (t < 0) { errorBranch.enter(); throw invalidTimes(); } int length = lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut)) ? lengthOut : t; double[] data = new double[length]; Arrays.fill(data, x.getDataAt(0)); return RDataFactory.createDoubleVector(data, !RRuntime.isNA(x.getDataAt(0))); }
private static void printDimList(RAbstractListVector s, PrintContext printCtx) throws IOException { final PrintParameters pp = printCtx.parameters(); int ns = s.getLength(); String[] t = new String[ns]; for (int i = 0; i < ns; i++) { Object tmp = RRuntime.asAbstractVector(s.getDataAtAsObject(i)); final String pbuf; if (tmp == null || tmp == RNull.instance) { pbuf = RRuntime.NULL; } else if (tmp instanceof RAbstractLogicalVector) { RAbstractLogicalVector lv = (RAbstractLogicalVector) tmp; if (lv.getLength() == 1) { FormatMetrics fm = LogicalVectorPrinter.formatLogicalVector(lv, 0, 1, pp.getNaWidth()); pbuf = snprintf( 115, "%s", LogicalVectorPrinter.encodeLogical(lv.getDataAt(0), fm.maxWidth, pp)); } else { pbuf = snprintf(115, "Logical,%d", lv.getLength()); } } else if (tmp instanceof RAbstractIntVector) { RAbstractIntVector iv = (RAbstractIntVector) tmp; if (printCtx.printerNode().inherits(iv, RRuntime.CLASS_FACTOR)) { /* factors are stored as integers */ pbuf = snprintf(115, "factor,%d", iv.getLength()); } else { if (iv.getLength() == 1) { FormatMetrics fm = IntegerVectorPrinter.formatIntVector(iv, 0, 1, pp.getNaWidth()); pbuf = snprintf( 115, "%s", IntegerVectorPrinter.encodeInteger(iv.getDataAt(0), fm.maxWidth, pp)); } else { pbuf = snprintf(115, "Integer,%d", iv.getLength()); } } } else if (tmp instanceof RAbstractDoubleVector) { RAbstractDoubleVector dv = (RAbstractDoubleVector) tmp; if (dv.getLength() == 1) { DoubleVectorMetrics fm = DoubleVectorPrinter.formatDoubleVector(dv, 0, 1, 0, pp); pbuf = snprintf(115, "%s", DoubleVectorPrinter.encodeReal(dv.getDataAt(0), fm, pp)); } else { pbuf = snprintf(115, "Numeric,%d", dv.getLength()); } } else if (tmp instanceof RAbstractComplexVector) { RAbstractComplexVector cv = (RAbstractComplexVector) tmp; if (cv.getLength() == 1) { RComplex x = cv.getDataAt(0); if (RRuntime.isNA(x.getRealPart()) || RRuntime.isNA(x.getImaginaryPart())) { /* formatReal(NA) --> w=R_print.na_width, d=0, e=0 */ pbuf = snprintf( 115, "%s", DoubleVectorPrinter.encodeReal( RRuntime.DOUBLE_NA, pp.getNaWidth(), 0, 0, '.', pp)); } else { ComplexVectorMetrics cvm = ComplexVectorPrinter.formatComplexVector(x, 0, 1, 0, pp); pbuf = snprintf(115, "%s", ComplexVectorPrinter.encodeComplex(x, cvm, pp)); } } else { pbuf = snprintf(115, "Complex,%d", cv.getLength()); } } else if (tmp instanceof RAbstractStringVector) { RAbstractStringVector sv = (RAbstractStringVector) tmp; if (sv.getLength() == 1) { String ctmp = sv.getDataAt(0); int len = ctmp.length(); if (len < 100) { pbuf = snprintf(115, "\"%s\"", ctmp); } else { pbuf = snprintf(101, "\"%s", ctmp) + "\" [truncated]"; } } else { pbuf = snprintf(115, "Character,%d", sv.getLength()); } } else if (tmp instanceof RAbstractRawVector) { pbuf = snprintf(115, "Raw,%d", ((RAbstractRawVector) (tmp)).getLength()); } else if (tmp instanceof RAbstractListVector) { pbuf = snprintf(115, "List,%d", ((RAbstractListVector) (tmp)).getLength()); } else if (tmp instanceof RLanguage) { pbuf = snprintf(115, "Expression"); } else { pbuf = snprintf(115, "?"); } t[i] = pbuf; } RStringVector tt = RDataFactory.createStringVector(t, true, s.getDimensions()); Object dimNames = s.getAttr(RRuntime.DIMNAMES_ATTR_KEY); tt.setAttr(RRuntime.DIMNAMES_ATTR_KEY, dimNames); PrintContext cc = printCtx.cloneContext(); cc.parameters().setQuote(false); StringVectorPrinter.INSTANCE.print(tt, cc); }