/** * Returns the given root of this dimension. * * @param n the root's order. * @return the result of taking the given root of this dimension. * @throws ArithmeticException if <code>n == 0</code>. */ public final Dimension root(int n) { return new Dimension(this._pseudoUnit.root(n)); }
/** * Returns the given root of this dimension. * * @param n the root's order. * @return the result of taking the given root of this dimension. * @throws ArithmeticException if <code>n == 0</code>. */ public final Dimension root(int n) { return new Dimension(this._pseudoUnit.root(n)); }
/** * Returns the given root of this dimension. * * @param n the root's order. * @return the result of taking the given root of this dimension. * @throws ArithmeticException if <code>n == 0</code>. */ public final Dimension root(int n) { return new Dimension(this._pseudoUnit.root(n)); }
/** * Returns a unit equals to the given root of this unit. * * @param n the root's order. * @return the result of taking the given root of this unit. * @throws ArithmeticException if <code>n == 0</code>. */ public final Unit<? extends Quantity> root(int n) { if (n > 0) { return ProductUnit.getRootInstance(this, n); } else if (n == 0) { throw new ArithmeticException("Root's order of zero"); } else { // n < 0 return ONE.divide(this.root(-n)); } }
/** * Returns a unit equals to the given root of this unit. * * @param n the root's order. * @return the result of taking the given root of this unit. * @throws ArithmeticException if <code>n == 0</code>. */ public final Unit<? extends Quantity> root(int n) { if (n > 0) { return ProductUnit.getRootInstance(this, n); } else if (n == 0) { throw new ArithmeticException("Root's order of zero"); } else { // n < 0 return ONE.divide(this.root(-n)); } }
/** * Returns a unit equals to the given root of this unit. * * @param n the root's order. * @return the result of taking the given root of this unit. * @throws ArithmeticException if <code>n == 0</code>. */ public final Unit<? extends Quantity> root(int n) { if (n > 0) { return ProductUnit.getRootInstance(this, n); } else if (n == 0) { throw new ArithmeticException("Root's order of zero"); } else { // n < 0 return ONE.divide(this.root(-n)); } }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
/** * Returns the square root of this measure. * * @return <code>sqrt(this)</code> * */ public Amount<? extends Quantity> sqrt() { Amount<Q> m = Amount.newInstance(_unit.root(2)); if (this._isExact) { double sqrtDouble = MathLib.sqrt(_exactValue); long sqrtLong = (long) sqrtDouble; if (sqrtLong * sqrtLong == _exactValue) return m.setExact(sqrtLong); } double min = MathLib.sqrt(_minimum); double max = MathLib.sqrt(_maximum); m._isExact = false; m._minimum = (min < 0) ? min * INCREMENT : min * DECREMENT; m._maximum = (max < 0) ? max * DECREMENT : max * INCREMENT; return m; }
unit = g.unit.root(n);
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {
if (n == 2) return this.sqrt(); Amount<Q> m = Amount.newInstance(_unit.root(n)); if (this._isExact) { double rootDouble = MathLib.pow(_exactValue, 1.0 / n);
result = result.root(e.root);
result = result.root(e.root);
result = result.root(e.root);
public ValueType sqrt(CalculatedValue g) { if (g.isComplex() || (g.isReal() && g.real < 0)) { if (g.unit != null) { invalidate(ErrorType.INCOMPATIBLE_UNIT); } else { unit = null; } return setComplexValue(g.getComplex().sqrt()); } else { if (g.unit != null) { unit = g.unit.root(2); } else { unit = null; } return setValue(FastMath.sqrt(g.real)); } }