Search in sources :

Example 6 with Unit

use of org.tensorics.core.units.Unit in project tensorics-core by tensorics.

the class TensorCalculationsTest method profileQuantifiedRepetitiveTensor.

@Ignore
@Test
public void profileQuantifiedRepetitiveTensor() {
    final Unit unit = JScienceUnit.of(SI.METER);
    CoordinateRange range = CoordinateRange.fromSize(TensorSize.ofXYZ(100, 1000, 1));
    List<ProfileResult> results = profileTensorCreationNTimes(10, range, new ValueFactory<QuantifiedValue<Double>>() {

        @Override
        public QuantifiedValue<Double> create(int x, int y, int z) {
            return Tensorics.quantityOf(valueForBig(x, y, z, 2.0), unit).withError(0.0);
        }
    });
    printProfileResult(results);
}
Also used : Unit(org.tensorics.core.units.Unit) JScienceUnit(org.tensorics.core.units.JScienceUnit) QuantifiedValue(org.tensorics.core.quantity.QuantifiedValue) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with Unit

use of org.tensorics.core.units.Unit in project tensorics-core by tensorics.

the class QuantityMultiplicativeInversion method perform.

@Override
public QuantifiedValue<S> perform(QuantifiedValue<S> scalar) {
    S newValue = environment().field().multiplicativeInversion().perform(scalar.value());
    QuantificationStrategy<S> quant = environment().quantification();
    Unit newUnit = quant.divide(quant.one(), scalar.unit());
    /* XXX is the error propagated correctly here? */
    return Tensorics.quantityOf(newValue, newUnit).withError(scalar.error()).withValidity(scalar.validity());
}
Also used : Unit(org.tensorics.core.units.Unit)

Aggregations

Unit (org.tensorics.core.units.Unit)7 JScienceUnit (org.tensorics.core.units.JScienceUnit)4 UnitConverter (javax.measure.converter.UnitConverter)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 QuantifiedValue (org.tensorics.core.quantity.QuantifiedValue)1