Packages

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

Example:
  1. 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)
Linear Supertypes
Serializable, Serializable, Product, Equals, AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Quantity
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyVal
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Quantity(value: A)

    value

    the coefficient

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. 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)
  4. 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)
  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)
  6. 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)
  7. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  8. 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)
  9. 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)
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. 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)
  12. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  13. 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)
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. 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)
  16. 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)
  17. 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)
  18. 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]
  19. 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)
  20. def to[U <: Unit[_]](implicit to: ConvertTo[Quantity[A, D], U]): Out
  21. val value: A

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyVal

Inherited from Any

Ungrouped