当前位置: 首页>>代码示例>>Java>>正文


Java Floats类代码示例

本文整理汇总了Java中com.google.common.primitives.Floats的典型用法代码示例。如果您正苦于以下问题:Java Floats类的具体用法?Java Floats怎么用?Java Floats使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Floats类属于com.google.common.primitives包,在下文中一共展示了Floats类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: topKProbabilities

import com.google.common.primitives.Floats; //导入依赖的package包/类
private List<Integer> topKProbabilities(final float[] labelProbabilities, int k) {

		List<Integer> list = new ArrayList<>(labelProbabilities.length);
		for (int i = 0; i < labelProbabilities.length; i++) {
			list.add(i);
		}

		List<Integer> topK = new Ordering<Integer>() {
			@Override
			public int compare(Integer left, Integer right) {
				return Floats.compare(labelProbabilities[left], labelProbabilities[right]);
			}
		}.greatestOf(list, k);

		return topK;
	}
 
开发者ID:tzolov,项目名称:tensorflow-spring-cloud-stream-app-starters,代码行数:17,代码来源:LabelImageTensorflowOutputConverter.java

示例2: toArray

import com.google.common.primitives.Floats; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"}) // NOTE: We assume the component type matches the list
private Object toArray(Class<?> componentType, List<Object> values) {
    if (componentType == boolean.class) {
        return Booleans.toArray((Collection) values);
    } else if (componentType == byte.class) {
        return Bytes.toArray((Collection) values);
    } else if (componentType == short.class) {
        return Shorts.toArray((Collection) values);
    } else if (componentType == int.class) {
        return Ints.toArray((Collection) values);
    } else if (componentType == long.class) {
        return Longs.toArray((Collection) values);
    } else if (componentType == float.class) {
        return Floats.toArray((Collection) values);
    } else if (componentType == double.class) {
        return Doubles.toArray((Collection) values);
    } else if (componentType == char.class) {
        return Chars.toArray((Collection) values);
    }
    return values.toArray((Object[]) Array.newInstance(componentType, values.size()));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:22,代码来源:JavaClassProcessor.java

示例3: deserializeSingleElement

import com.google.common.primitives.Floats; //导入依赖的package包/类
private Length deserializeSingleElement(JsonElement json)
{
    if (json.isJsonPrimitive())
    {
        JsonPrimitive primitive = json.getAsJsonPrimitive();
        if (primitive.isString())
        {
            String value = primitive.getAsString();
            if (value.endsWith("%"))
            {
                value = value.substring(0, value.length() - 1);
                Float percentValue = Floats.tryParse(value);
                if (percentValue != null)
                    return relative(percentValue / 100f);
            }
        } else
        {
            return absolute(json.getAsInt());
        }
    }

    return Length.ZERO;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:24,代码来源:LengthDeserializer.java

示例4: getValues

import com.google.common.primitives.Floats; //导入依赖的package包/类
static
public List<?> getValues(Tensor tensor){
	DataType dataType = tensor.dataType();

	switch(dataType){
		case FLOAT:
			return Floats.asList(TensorUtil.toFloatArray(tensor));
		case DOUBLE:
			return Doubles.asList(TensorUtil.toDoubleArray(tensor));
		case INT32:
			return Ints.asList(TensorUtil.toIntArray(tensor));
		case INT64:
			return Longs.asList(TensorUtil.toLongArray(tensor));
		case STRING:
			return Arrays.asList(TensorUtil.toStringArray(tensor));
		case BOOL:
			return Booleans.asList(TensorUtil.toBooleanArray(tensor));
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:22,代码来源:TensorUtil.java

示例5: determineType

import com.google.common.primitives.Floats; //导入依赖的package包/类
private static URI determineType(final String data) {
    if (Ints.tryParse(data) != null) {
        return XMLSchema.INTEGER;
    } else if (Doubles.tryParse(data) != null) {
        return XMLSchema.DOUBLE;
    } else if (Floats.tryParse(data) != null) {
        return XMLSchema.FLOAT;
    } else if (isShort(data)) {
        return XMLSchema.SHORT;
    } else if (Longs.tryParse(data) != null) {
        return XMLSchema.LONG;
    } if (Boolean.parseBoolean(data)) {
        return XMLSchema.BOOLEAN;
    } else if (isByte(data)) {
        return XMLSchema.BYTE;
    } else if (isDate(data)) {
        return XMLSchema.DATETIME;
    } else if (isUri(data)) {
        return XMLSchema.ANYURI;
    }

    return XMLSchema.STRING;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:SmartUriAdapter.java

示例6: testMapOfMultipleThings

import com.google.common.primitives.Floats; //导入依赖的package包/类
@Test
public void testMapOfMultipleThings() throws Exception {
    String[] arr = {"foo", "bar", "baz", "buz", "biz"};
    int[] vals = {1, 2, 3, 4, 5};
    float[] floats = {1f, 2f, 3f, 4f, 5f};
    Set<String> set = new LinkedHashSet<>(Arrays.asList(arr));
    BufferCharSequenceSet bcsSet = new BufferCharSequenceSet(set);

    int[] indices = Arrays.stream(arr).mapToInt(bcsSet::getIndex).toArray();
    int[] newVals = Ints.toArray(Reorder.reorderCopy(Ints.asList(vals), indices));
    float[] newFloats = Floats.toArray(Reorder.reorderCopy(Floats.asList(floats), indices));

    for (int i = 0; i < arr.length; i++) {
        String word = arr[i];
        int index = bcsSet.getIndex(word);
        assertThat(newVals[index], is(vals[i]));
        assertThat(newFloats[index], is(floats[i]));
    }
}
 
开发者ID:scr,项目名称:memory-mapped-hashmap,代码行数:20,代码来源:ReorderTest.java

示例7: compareTo

import com.google.common.primitives.Floats; //导入依赖的package包/类
@Override
public int compareTo(ScoredFeature o) {
    int c = -Float.compare(Floats.max(scores), Floats.max(o.scores));
    if (c != 0) {
        return c;
    }
    c = Integer.compare(featureScore.termIds.length, o.featureScore.termIds.length);
    if (c != 0) {
        return c;
    }
    for (int j = 0; j < featureScore.termIds.length; j++) {
        c = featureScore.termIds[j].compareTo(o.featureScore.termIds[j]);
        if (c != 0) {
            return c;
        }
    }
    return 0;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:19,代码来源:CatwalkPluginRegion.java

示例8: displayQRFinderPoints

import com.google.common.primitives.Floats; //导入依赖的package包/类
/**
 * Update IProgress with QR finder points that were
 * found during the QR decoding. It orders the (x,y)
 * coordinates as follows: [x1,y2,x2,y2...xi,yi...].
 */
private void displayQRFinderPoints(Iterable<Result> decodedQRCodes) {
  List<Float> list = Lists.newArrayList();
  for (Result qr : decodedQRCodes) {
    ResultPoint[] points = qr.getResultPoints();
    if(points != null) {
      for (ResultPoint point : points) {
        if (point != null) {
          list.add(point.getX());
          list.add(point.getY());
        }
      }
    }
  }
  progress.drawFinderPoints(Floats.toArray(list));
}
 
开发者ID:creswick,项目名称:StreamingQR,代码行数:21,代码来源:Receive.java

示例9: create

import com.google.common.primitives.Floats; //导入依赖的package包/类
public static <V> BinGenerator<V> create(
        Random random, Iterable<? extends Pair<Float, ? extends V>> weightedValues) {
    final ImmutableRangeMap.Builder<Float, V> bins = ImmutableRangeMap.builder();
    Float lower = Float.valueOf(0.0f);
    for (Pair<Float, ? extends V> weightedValue: weightedValues) {
        if (weightedValue.first().floatValue() <= 0.0f) {
            continue;
        }
        Float upper = Float.valueOf(Floats.min(1.0f, lower.floatValue() + weightedValue.first().floatValue()));
        checkArgument(upper.floatValue() > lower.floatValue());
        Range<Float> range = Range.closedOpen(lower, upper);
        bins.put(range, weightedValue.second());
        lower = upper;
    }
    checkArgument(Float.compare(lower.floatValue(), 1.0f) == 0);
    return new BinGenerator<V>(random, bins.build());
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:18,代码来源:BinGenerator.java

示例10: getCacheKey

import com.google.common.primitives.Floats; //导入依赖的package包/类
@Override
public byte[] getCacheKey()
{
  ByteBuffer abscissaBuffer = ByteBuffer.allocate(abscissa.length * Floats.BYTES);
  abscissaBuffer.asFloatBuffer().put(abscissa);
  final byte[] abscissaCacheKey = abscissaBuffer.array();

  ByteBuffer ordinateBuffer = ByteBuffer.allocate(ordinate.length * Floats.BYTES);
  ordinateBuffer.asFloatBuffer().put(ordinate);
  final byte[] ordinateCacheKey = ordinateBuffer.array();

  final ByteBuffer cacheKey = ByteBuffer
      .allocate(1 + abscissaCacheKey.length + ordinateCacheKey.length + Ints.BYTES)
      .put(abscissaCacheKey)
      .put(ordinateCacheKey)
      .putInt(getLimit())
      .put(CACHE_TYPE_ID);

  return cacheKey.array();
}
 
开发者ID:metamx,项目名称:bytebuffer-collections,代码行数:21,代码来源:PolygonBound.java

示例11: getCacheKey

import com.google.common.primitives.Floats; //导入依赖的package包/类
@Override
public byte[] getCacheKey()
{
  ByteBuffer minCoordsBuffer = ByteBuffer.allocate(minCoords.length * Floats.BYTES);
  minCoordsBuffer.asFloatBuffer().put(minCoords);
  final byte[] minCoordsCacheKey = minCoordsBuffer.array();

  ByteBuffer maxCoordsBuffer = ByteBuffer.allocate(maxCoords.length * Floats.BYTES);
  maxCoordsBuffer.asFloatBuffer().put(maxCoords);
  final byte[] maxCoordsCacheKey = maxCoordsBuffer.array();

  final ByteBuffer cacheKey = ByteBuffer
      .allocate(1 + minCoordsCacheKey.length + maxCoordsCacheKey.length + Ints.BYTES)
      .put(minCoordsCacheKey)
      .put(maxCoordsCacheKey)
      .putInt(limit)
      .put(CACHE_TYPE_ID);
  return cacheKey.array();
}
 
开发者ID:metamx,项目名称:bytebuffer-collections,代码行数:20,代码来源:RectangularBound.java

示例12: ImmutableNode

import com.google.common.primitives.Floats; //导入依赖的package包/类
public ImmutableNode(
    int numDims,
    int initialOffset,
    int offsetFromInitial,
    ByteBuffer data,
    BitmapFactory bitmapFactory
)
{
  this.bitmapFactory = bitmapFactory;
  this.numDims = numDims;
  this.initialOffset = initialOffset;
  this.offsetFromInitial = offsetFromInitial;
  short header = data.getShort(initialOffset + offsetFromInitial);
  this.isLeaf = (header & 0x8000) != 0;
  this.numChildren = (short) (header & 0x7FFF);
  final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Floats.BYTES;
  int bitmapSize = data.getInt(sizePosition);
  this.childrenOffset = initialOffset
                        + offsetFromInitial
                        + HEADER_NUM_BYTES
                        + 2 * numDims * Floats.BYTES
                        + Ints.BYTES
                        + bitmapSize;

  this.data = data;
}
 
开发者ID:metamx,项目名称:bytebuffer-collections,代码行数:27,代码来源:ImmutableNode.java

示例13: func_175327_a

import com.google.common.primitives.Floats; //导入依赖的package包/类
private void func_175327_a(float p_175327_1_)
{
    Gui gui = this.field_175349_r.func_178056_g();

    if (gui instanceof GuiTextField)
    {
        float f = p_175327_1_;

        if (GuiScreen.isShiftKeyDown())
        {
            f = p_175327_1_ * 0.1F;

            if (GuiScreen.isCtrlKeyDown())
            {
                f *= 0.1F;
            }
        }
        else if (GuiScreen.isCtrlKeyDown())
        {
            f = p_175327_1_ * 10.0F;

            if (GuiScreen.isAltKeyDown())
            {
                f *= 10.0F;
            }
        }

        GuiTextField guitextfield = (GuiTextField)gui;
        Float f1 = Floats.tryParse(guitextfield.getText());

        if (f1 != null)
        {
            f1 = Float.valueOf(f1.floatValue() + f);
            int i = guitextfield.getId();
            String s = this.func_175330_b(guitextfield.getId(), f1.floatValue());
            guitextfield.setText(s);
            this.func_175319_a(i, s);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:GuiCustomizeWorldScreen.java

示例14: modifyFocusValue

import com.google.common.primitives.Floats; //导入依赖的package包/类
private void modifyFocusValue(float p_175327_1_)
{
    Gui gui = this.list.getFocusedControl();

    if (gui instanceof GuiTextField)
    {
        float f = p_175327_1_;

        if (GuiScreen.isShiftKeyDown())
        {
            f = p_175327_1_ * 0.1F;

            if (GuiScreen.isCtrlKeyDown())
            {
                f *= 0.1F;
            }
        }
        else if (GuiScreen.isCtrlKeyDown())
        {
            f = p_175327_1_ * 10.0F;

            if (GuiScreen.isAltKeyDown())
            {
                f *= 10.0F;
            }
        }

        GuiTextField guitextfield = (GuiTextField)gui;
        Float f1 = Floats.tryParse(guitextfield.getText());

        if (f1 != null)
        {
            f1 = Float.valueOf(f1.floatValue() + f);
            int i = guitextfield.getId();
            String s = this.getFormattedValue(guitextfield.getId(), f1.floatValue());
            guitextfield.setText(s);
            this.setEntryValue(i, s);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:GuiCustomizeWorldScreen.java

示例15: func_175327_a

import com.google.common.primitives.Floats; //导入依赖的package包/类
private void func_175327_a(float p_175327_1_)
{
    Gui gui = this.field_175349_r.getFocusedControl();

    if (gui instanceof GuiTextField)
    {
        float f1 = p_175327_1_;

        if (GuiScreen.isShiftKeyDown())
        {
            f1 = p_175327_1_ * 0.1F;

            if (GuiScreen.isCtrlKeyDown())
            {
                f1 *= 0.1F;
            }
        }
        else if (GuiScreen.isCtrlKeyDown())
        {
            f1 = p_175327_1_ * 10.0F;

            if (GuiScreen.isAltKeyDown())
            {
                f1 *= 10.0F;
            }
        }

        GuiTextField guitextfield = (GuiTextField)gui;
        Float f2 = Floats.tryParse(guitextfield.getText());

        if (f2 != null)
        {
            f2 = Float.valueOf(f2.floatValue() + f1);
            int i = guitextfield.getId();
            String s = this.func_175330_b(guitextfield.getId(), f2.floatValue());
            guitextfield.setText(s);
            this.setEntryValue(i, s);
        }
    }
}
 
开发者ID:lumien231,项目名称:Simple-Dimensions,代码行数:41,代码来源:GuiCustomizeDimension.java


注:本文中的com.google.common.primitives.Floats类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。