本文整理匯總了Java中com.google.common.primitives.Doubles.concat方法的典型用法代碼示例。如果您正苦於以下問題:Java Doubles.concat方法的具體用法?Java Doubles.concat怎麽用?Java Doubles.concat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.primitives.Doubles
的用法示例。
在下文中一共展示了Doubles.concat方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: multiDimTest
import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Test
public void multiDimTest() throws JsonProcessingException, IOException
{
String json = "{\"request\":{\"values\":[[1.0]]}}";
System.out.println(json);
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = mapper.getFactory();
JsonParser parser = factory.createParser(json);
JsonNode j = mapper.readTree(parser);
JsonNode values = j.get("request").get("values");
double[][] v = mapper.readValue(values.toString(),double[][].class);
double[] vs = Doubles.concat(v);
int[] shape = {v.length,v[0].length };
((ObjectNode) j.get("request")).replace("values",mapper.valueToTree(vs));
((ObjectNode) j.get("request")).set("shape",mapper.valueToTree(shape));
System.out.println(j.toString());
}
示例2: getContigToMedianCRMap
import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@VisibleForTesting
static Map<String, Double> getContigToMedianCRMap(final ReadCountCollection readCountCollection) {
final List<String> allContigsPresent = retrieveAllContigsPresent(readCountCollection);
final Map<String, Double> contigToMedian = new LinkedHashMap<>();
for (String contig: allContigsPresent) {
final ReadCountCollection oneContigReadCountCollection = readCountCollection.subsetTargets(readCountCollection.targets().stream().filter(t -> t.getContig().equals(contig)).collect(Collectors.toSet()));
final double[] flatCounts = Doubles.concat(oneContigReadCountCollection.counts().getData());
// Put into CRSpace
final double[] flatCountsInCRSpace = DoubleStream.of(flatCounts).map(d -> Math.pow(2, d)).toArray();
contigToMedian.put(contig, new Median().evaluate(flatCountsInCRSpace));
}
return contigToMedian;
}
示例3: truncateExtremeCounts
import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
* Truncates the extreme count values in the input read-count collection.
* Values are forced to be bound by the percentile indicated with the input {@code percentile} which must be
* in the range [0 .. 50.0]. Values under that percentile and the complementary (1 - percentile) are set to the
* corresponding threshold value.
*
* <p>The imputation is done in-place, thus the input matrix is modified as a result of this call.</p>
*
* @param readCounts the input and output read-count matrix.
*/
public static void truncateExtremeCounts(final ReadCountCollection readCounts, final double percentile, final Logger logger) {
final RealMatrix counts = readCounts.counts();
final int targetCount = counts.getRowDimension();
final int columnCount = counts.getColumnDimension();
// Create a row major array of the counts.
final double[] values = Doubles.concat(counts.getData());
final Percentile bottomPercentileEvaluator = new Percentile(percentile);
final Percentile topPercentileEvaluator = new Percentile(100.0 - percentile);
final double bottomPercentileThreshold = bottomPercentileEvaluator.evaluate(values);
final double topPercentileThreshold = topPercentileEvaluator.evaluate(values);
long totalCounts = 0;
long bottomTruncatedCounts = 0;
long topTruncatedCounts = 0;
for (int i = 0; i < targetCount; i++) {
final double[] rowCounts = counts.getRow(i);
for (int j = 0; j < columnCount; j++) {
final double count = rowCounts[j];
totalCounts++;
if (count < bottomPercentileThreshold) {
counts.setEntry(i, j, bottomPercentileThreshold);
bottomTruncatedCounts++;
} else if (count > topPercentileThreshold) {
counts.setEntry(i, j, topPercentileThreshold);
topTruncatedCounts++;
}
}
}
if (topTruncatedCounts == 0 && bottomTruncatedCounts == 0) {
logger.info(String.format("None of the %d counts were truncated as they all fall in the non-extreme range " +
"[%.2f, %.2f]", totalCounts, bottomPercentileThreshold, topPercentileThreshold));
} else {
final double truncatedPercentage = ((double)(topTruncatedCounts + bottomTruncatedCounts) / totalCounts) * 100;
logger.info(String.format("Some counts (%d out of %d, %.2f%%) were truncated as they fall out of the " +
"non-extreme range [%.2f, %.2f]", topTruncatedCounts + bottomTruncatedCounts, totalCounts,
truncatedPercentage, bottomPercentileThreshold, topPercentileThreshold));
}
}
示例4: getArrayCopy
import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public double[] getArrayCopy() {
return Doubles.concat(this.doubleArray);
}