final case class Quantity[A, D <: HList](value: A) extends AnyVal with Product with Serializable
Represents a dimensional quantity
- A
the Numeric type of the quantity e.g. Int, Float, Double
- D
the dimensions
- value
the coefficient
scala> import spire.implicits._ scala> import libra._, libra.si._ scala> Quantity[Double, Term[Length, Metre, Fraction[1, 1]] :: HNil](5.5) // represents 5.5 m scala> res0: Quantity[Double, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(5.5)
- Alphabetic
- By Inheritance
- Quantity
- Serializable
- Serializable
- Product
- Equals
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Quantity(value: A)
- value
the coefficient
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
def
*[D1 <: HList](q1: Quantity[A, D1])(implicit m: Multiply[Quantity[A, D], Quantity[A, D1]]): Out
Alias for multiply
Alias for multiply
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 2.m * 3.m res0: Quantity[Int, Term[Length, Metre, Fraction[2, 1]] :: HNil] = Quantity(6)
-
def
+[D1 <: HList](q1: Quantity[A, D1])(implicit a: Add[Quantity[A, D], Quantity[A, D1]]): Out
Alias for add
Alias for add
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 3.m + 2.m res1: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(5)
-
def
-[D1 <: HList](q1: Quantity[A, D1])(implicit a: Add[Quantity[A, D], Quantity[A, D1]], g: AdditiveGroup[A]): Out
Alias for subtract
Alias for subtract
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 3.m - 2.m res1: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(1)
-
def
/[D1 <: HList](q1: Quantity[A, D1])(implicit d: Divide[Quantity[A, D], Quantity[A, D1]]): Out
Alias for divide
Alias for divide
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 4.0.m / 2.0.m res0: Quantity[Double, HNil] = Quantity(2.0)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
def
^[P <: Singleton with Int](pow: P)(implicit p: Power[Quantity[A, D], P]): Out
Alias for power
Alias for power
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 2.0.m^(3) res0: Quantity[Double, Term[Length, Metre, Fraction[3, 1]] :: HNil] = Quantity(8.0)
-
def
add[D1 <: HList](q1: Quantity[A, D1])(implicit a: Add[Quantity[A, D], Quantity[A, D1]]): Out
Adds another quantity using the spire AdditiveSemigroup.
Adds another quantity using the spire AdditiveSemigroup.
- q1
the quantity to add. This must have the equivalient dimensions.
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 3.m add 2.m res1: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(5)
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
divide[D1 <: HList](q1: Quantity[A, D1])(implicit d: Divide[Quantity[A, D], Quantity[A, D1]]): Out
Divides by a quantity
Divides by a quantity
- q1
the quantity to divide by
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 4.0.m divide 2.0.m res0: Quantity[Double, HNil] = Quantity(2.0)
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
def
invert()(implicit i: Invert[Quantity[A, D]]): Out
Raises the quantity to the power of -1
Raises the quantity to the power of -1
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> val x = 2.0.m x: Quantity[Double, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(2.0) scala> x.invert res2: Quantity[Double, Term[Length, Metre, Fraction[-1, 1]] :: HNil] = Quantity(0.5)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
multiply[D1 <: HList](q1: Quantity[A, D1])(implicit m: Multiply[Quantity[A, D], Quantity[A, D1]]): Out
Multiplies by a quantity
Multiplies by a quantity
- q1
the quantity to multiply by
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 2.m multiply 3.m res0: Quantity[Int, Term[Length, Metre, Fraction[2, 1]] :: HNil] = Quantity(6)
-
def
negate()(implicit ev: AdditiveGroup[A]): Quantity[A, D]
Negates the quantity
Negates the quantity
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> val x = 2.m x: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(2) scala> x.negate res2: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(-2)
-
def
power[P <: Singleton with Int]()(implicit p: Power[Quantity[A, D], P]): Out
Raises to a power
Raises to a power
- P
the Integer power to raise by
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 2.0.m.power[3] res0: Quantity[Double, Term[Length, Metre, Fraction[3, 1]] :: HNil] = Quantity(8.0)
-
def
show()(implicit s: Show[Quantity[A, D]]): String
The standard index form String
The standard index form String
scala> import spire.implicits._ scala> import libra._, libra.si._ scala> 2.m.show res0: String = 2 m [L]
-
def
subtract[D1 <: HList](q1: Quantity[A, D1])(implicit a: Add[Quantity[A, D], Quantity[A, D1]], group: AdditiveGroup[A]): Out
Subtracts another quantity using the spire AdditiveGroup
Subtracts another quantity using the spire AdditiveGroup
- q1
the quantity to subtract. This must have the equivalient dimensions.
scala> import spire.implicits._ scala> import shapeless._ scala> import libra._, libra.si._ scala> 3.m subtract 2.m res1: Quantity[Int, Term[Length, Metre, Fraction[1, 1]] :: HNil] = Quantity(1)
- def to[U <: Unit[_]](implicit to: ConvertTo[Quantity[A, D], U]): Out
- val value: A