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


Java Dimensionless类代码示例

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


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

示例1: getDescriptorFor

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public MetricDescriptor getDescriptorFor(final String metricName) {
    return new MetricDescriptor() {
        @Override
        public Unit<Dimensionless> getUnit() {
            return ONE;
        }

        @Override
        public String getDescription() {
            return metricName;
        }

        @Override
        public ValueSemantics getSemantics() {
            return ValueSemantics.FREE_RUNNING;
        }
    };
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:20,代码来源:DefaultMetricDescriptorLookup.java

示例2: getCreate

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private static List<IOperation> getCreate()
{
  List<IOperation> create = new ArrayList<IOperation>();

  create.add(new AddLayerOperation());

  create
      .add(new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT));

  create.add(new CreateSingletonGenerator("frequency", HERTZ
      .asType(Frequency.class)));

  create.add(new CreateSingletonGenerator("decibels", NonSI.DECIBEL));

  create.add(new CreateSingletonGenerator("speed (m/s)", METRE.divide(SECOND)
      .asType(Velocity.class)));

  create.add(new CreateSingletonGenerator("course (degs)",
      SampleData.DEGREE_ANGLE.asType(Angle.class)));
  create.add(new CreateSingletonGenerator("time (secs)",
      SI.SECOND.asType(Duration.class)));
  // create.add(new CreateLocationAction());
  create.add(new GenerateGrid());

  return create;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:27,代码来源:OperationsLibrary.java

示例3: areFunctionallyIdenticalUnits

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private static boolean areFunctionallyIdenticalUnits(Unit<?> left, Unit<?> right) {
    if (!left.isCompatible(right)) {
        return false;
    }
    Unit<?> divided = left.divide(right);
    if (!divided.getDimension().equals(Dimension.NONE)) {
        return false;
    }
    return divided.asType(Dimensionless.class).getConverterTo(ONE).equals(IDENTITY);
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:11,代码来源:UnitMapping.java

示例4: getDimension

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public Dimension getDimension(BaseUnit<?> unit) {
    if (unit.equals(SI.METRE)) return Dimension.LENGTH;
    if (unit.equals(SI.KILOGRAM)) return Dimension.MASS;
    if (unit.equals(SI.KELVIN)) return Dimension.TEMPERATURE;
    if (unit.equals(SI.SECOND)) return Dimension.TIME;
    if (unit.equals(SI.AMPERE)) return Dimension.ELECTRIC_CURRENT;
    if (unit.equals(SI.MOLE)) return Dimension.AMOUNT_OF_SUBSTANCE;
    if (unit.equals(SI.CANDELA)) return SI.WATT.getDimension();
    return new Dimension(new BaseUnit<Dimensionless>("[" + unit.getSymbol() + "]"));
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:11,代码来源:Dimension.java

示例5: getY

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Amount<QY> getY(Amount<QX> xValue) {
    /* cast is safe since x and inverseExpConst are the same Dimension */
    @SuppressWarnings("unchecked")
    Amount<Dimensionless> divisionResult = (Amount<Dimensionless>) xValue.divide(inverseExpConst);
    return amplitude.times(Math.exp(divisionResult.doubleValue(ONE)));
}
 
开发者ID:tensorics,项目名称:tensorics-core,代码行数:8,代码来源:ExponentialFunction.java

示例6: test

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void test() {
    Amount<ElectricCurrent> current1 = Amount.valueOf(12, AMPERE);
    Amount<ElectricCurrent> current2 = Amount.valueOf(2, AMPERE);

    @SuppressWarnings("unchecked")
    Amount<Dimensionless> result = (Amount<Dimensionless>) current1.divide(current2);
    assertNotNull(result);
    System.out.println(result.getUnit());
    System.out.println(result.doubleValue(ONE));

}
 
开发者ID:tensorics,项目名称:tensorics-core,代码行数:13,代码来源:ExponentialFunctionTest.java

示例7: isDecibels

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
/**
 * special case. Once a decibels unit has been restored from file, the equals comparison no longer
 * works. So, we've copied the below content from the original sources. The original sources also
 * includes a comparison of db.converter, but we've omitted that, since it's not visible. If we
 * start getting false positives, we'll have to consider using the derived converter object.
 * 
 * @param that
 *          object we're considering
 * @return if it's the units of decibels
 */
private boolean isDecibels(Object that)
{
  final TransformedUnit<Dimensionless> db =
      (TransformedUnit<Dimensionless>) NonSI.DECIBEL;
  if (this == that)
    return true;
  if (!(that instanceof TransformedUnit))
    return false;
  TransformedUnit<?> thatUnit = (TransformedUnit<?>) that;
  return db.getParentUnit().equals(thatUnit.getParentUnit());
}
 
开发者ID:debrief,项目名称:limpet,代码行数:22,代码来源:LimpetLabelProvider.java

示例8: NumberDocument

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public NumberDocument(final DoubleDataset dataset,
    final ICommand predecessor, final Unit<?> qType)
{
  super(dataset, predecessor);

  if (qType == null)
  {
    this.qType = Dimensionless.UNIT;
  }
  else
  {
    this.qType = qType;
  }
}
 
开发者ID:debrief,项目名称:limpet,代码行数:15,代码来源:NumberDocument.java

示例9: BurnSummary

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
public BurnSummary(Burn b) {
	for (Interval i : b.getData().values()) {
		ns = ns.plus(i.dt.times(i.thrust));
		if (i.thrust.isGreaterThan(Amount.valueOf(0.01, SI.NEWTON))) {
			thrustTime = thrustTime.plus(i.dt);
		}
		if (i.thrust.isGreaterThan(maxThrust))
			maxThrust = i.thrust;
		if (i.chamberPressure.isGreaterThan(maxPressure))
			maxPressure = i.chamberPressure;
	}
	
	isp = ns
	.divide(b
			.getMotor()
			.getGrain()
			.volume(Amount.valueOf(0, SI.MILLIMETER))
			.times(b.getMotor()
					.getFuel()
					.getIdealDensity()
					.times(b.getMotor().getFuel()
							.getDensityRatio())))
	.to(SI.METERS_PER_SECOND)
	.divide(Amount.valueOf(9.81,
			SI.METERS_PER_SQUARE_SECOND)).to(SI.SECOND);

	if ( b.getMotor().getChamber().getBurstPressure() != null )
		saftyFactor = b.getMotor().getChamber().getBurstPressure().divide(maxPressure).to(Dimensionless.UNIT).doubleValue(Dimensionless.UNIT);

	Amount<Volume> vol = b.getMotor().getGrain().volume(Amount.valueOf(0, SI.MILLIMETER));
	Amount<VolumetricDensity> ideal = b.getMotor().getFuel().getIdealDensity();
	Amount<VolumetricDensity> actual = ideal.times(b.getMotor().getFuel().getDensityRatio());
	propellantMass = vol.times(actual).to(SI.GRAM);
	
	Amount<Volume> chamber = b.getMotor().getChamber().chamberVolume();
	volumeLoading = vol.divide(chamber).to(Dimensionless.UNIT).doubleValue(Dimensionless.UNIT);
}
 
开发者ID:bkuker,项目名称:motorsim,代码行数:38,代码来源:BurnSummary.java

示例10: burnRate

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Amount<Velocity> burnRate(final Amount<Pressure> pressure) {
	if ( pressure.isLessThan(ZERO_PRESSURE) )
		return ZERO_VELOCITY;
	
	if ( entries.size() == 1 ){
		return entries.get(entries.firstKey()).burnRate;
	}
	
	if ( entries.containsKey(pressure) ){
		return entries.get(pressure).burnRate;
	}
		
	Entry low = null;
	low = entries.get(entries.headMap(pressure).lastKey());
	Entry high = null;
	try {
		high = entries.get(entries.tailMap(pressure).firstKey());
	} catch ( NoSuchElementException e ){
		log.warn("Pressure " + pressure + " is outside of expiermental range for " + this.getName());
		high = low;
		low = entries.get(entries.headMap(low.pressure).lastKey());
	}
	
	Amount<Pressure> lowToHigh = high.pressure.minus(low.pressure);
	Amount<Pressure> lowToTarget = pressure.minus(low.pressure);
	Amount<Dimensionless> frac = lowToTarget.divide(lowToHigh).to(Dimensionless.UNIT);
	
	Amount<Velocity> vdiff = high.burnRate.minus(low.burnRate);
	Amount<Velocity> ret = low.burnRate.plus(vdiff.times(frac));
	
	if ( ret.isLessThan(ZERO_VELOCITY) )
		return ZERO_VELOCITY;
	
	return ret;
	
}
 
开发者ID:bkuker,项目名称:motorsim,代码行数:38,代码来源:EditablePiecewiseLinearFuel.java

示例11: UnitScale

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
private UnitScale(int pmUnitsValue, Unit<Dimensionless> unit) {
    this.pmUnitsValue = pmUnitsValue;
    this.unit = unit;
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:5,代码来源:PcpScale.java

示例12: getUnit

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
public Unit<Dimensionless> getUnit() {
    return unit;
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:5,代码来源:PcpScale.java

示例13: getUnaryOutputUnit

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Override
protected Unit<?> getUnaryOutputUnit(final Unit<?> first)
{
  return Dimensionless.UNIT;
}
 
开发者ID:debrief,项目名称:limpet,代码行数:6,代码来源:TestArithmeticCollections.java

示例14: testCreateSingletonGenerator

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void testCreateSingletonGenerator()
{
  StoreGroup store = new SampleData().getData(10);
  CreateSingletonGenerator generator =
      new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT);
  assertNotNull("Create Single Generator is not NULL", generator);

  List<IStoreItem> selection = new ArrayList<IStoreItem>();
  StoreGroup storeGroup = new StoreGroup("Track 1");
  selection.add(storeGroup);

  IContext mockContext = EasyMock.createMock(MockContext.class);

  Collection<ICommand> singleGeneratorActionFor =
      generator.actionsFor(selection, store, mockContext);
  assertEquals("Create location collection size", 1, singleGeneratorActionFor
      .size());
  ICommand singleGenCommand = singleGeneratorActionFor.iterator().next();

  final String outName = "new_name";
  EasyMock.expect(
      mockContext.getInput("New variable", "Enter name for variable", "new dimensionless"))
      .andReturn(outName).times(1);
  EasyMock.expect(
      mockContext.getInput("New variable",
          "Enter initial value for variable", "100")).andReturn("1234.56")
      .times(1);
  EasyMock.expect(
      mockContext.getInput("New variable",
          "Enter the range for variable (or cancel to leave un-ranged)", "0:100")).andReturn("5:100")
      .times(1);
  EasyMock.replay(mockContext);

  singleGenCommand.execute();

  NumberDocument output = (NumberDocument) singleGenCommand.getOutputs().get(0);
  assertNotNull(output);
  assertEquals("correct name", outName, output.getName());
  assertEquals("correct size", 1, output.size());
  assertEquals("correct value", 1234.56, output.getValueAt(0), 0.01);
  assertEquals("correct range", new Range(5d,100d), output.getRange());
  assertEquals("correct units", Dimensionless.UNIT, output.getUnits());
  assertEquals("no index units", null, output.getIndexUnits());
  assertFalse("not indexed", output.isIndexed());
  assertTrue("is quantity", output.isQuantity());
}
 
开发者ID:debrief,项目名称:limpet,代码行数:48,代码来源:TestOperations.java

示例15: testCreateSingletonGeneratorInvalid

import javax.measure.quantity.Dimensionless; //导入依赖的package包/类
@Test
public void testCreateSingletonGeneratorInvalid()
{
  StoreGroup store = new SampleData().getData(10);
  CreateSingletonGenerator generator =
      new CreateSingletonGenerator("dimensionless", Dimensionless.UNIT);
  assertNotNull("Create Single Generator is not NULL", generator);

  List<IStoreItem> selection = new ArrayList<IStoreItem>();
  StoreGroup storeGroup = new StoreGroup("Track 1");
  selection.add(storeGroup);

  IContext mockContext = EasyMock.createMock(MockContext.class);

  Collection<ICommand> singleGeneratorActionFor =
      generator.actionsFor(selection, store, mockContext);
  assertEquals("Create location collection size", 1, singleGeneratorActionFor
      .size());
  ICommand singleGenCommand = singleGeneratorActionFor.iterator().next();

  final String outName = "new_name";
  EasyMock.expect(
      mockContext.getInput("New variable", "Enter name for variable", "new dimensionless"))
      .andReturn(outName).times(1);
  EasyMock.expect(
      mockContext.getInput("New variable",
          "Enter initial value for variable", "100")).andReturn("1234.56")
      .times(1);
  EasyMock.expect(
      mockContext.getInput("New variable",
          "Enter the range for variable (or cancel to leave un-ranged)", "0:100")).andReturn("")
      .times(1);
  EasyMock.replay(mockContext);

  singleGenCommand.execute();

  NumberDocument output = (NumberDocument) singleGenCommand.getOutputs().get(0);
  assertNotNull(output);    
  assertEquals("correct name", outName, output.getName());
  assertEquals("correct size", 1, output.size());
  assertEquals("correct value", 1234.56, output.getValueAt(0), 0.01);
  assertEquals("correct range", null, output.getRange());
}
 
开发者ID:debrief,项目名称:limpet,代码行数:44,代码来源:TestOperations.java


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