Packages

• package
Definition Classes
root
• package

The Scala API for Quantities, Units of Measure and Dimensional Analysis

Squants

The Scala API for Quantities, Units of Measure and Dimensional Analysis

Overview

Squants is a framework of data types and a domain specific language (DSL) for representing Quantities, their Units of Measure, and their Dimensional relationships. The API supports typesafe dimensional analysis, improved domain models and more. All types are immutable and thread-safe.

Typedefs and implicits for common usages

Definition Classes
root
Version

0.1

Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package
Definition Classes
squants
• package

Squants Market API

Squants Market API

Market Types are similar but not quite the same as other quantities in the library.

The primary type, squants.market.Money, is derived from Quantity, and its Units of Measure are Currencies. However, because the conversion multipliers between units can not be predefined, many of the behaviors have been overridden and augmented to realize correct behavior.

squants.market.Prices represent a Ratio between Money and some other Quantity. Prices can be created from ratios of Money and a Quantity

```val money: Money = USD(10)
val length: Length = Meters(1)
val price: Price[Length] = money / length```

Multiplying a Price * Quantity will yield Money amount that represents the cost of the quantity

`val cost: Money = price * Meters(3.8)`

and multiplying Price * Money will yield the corresponding Quantity amount

```val budget: Money = USD(250)
val quote: Length = price * budget```

squants.market.CurrencyExchangeRates represent conversion rates between currencies. Use them to explicitly convert Money values in one currency to values in another.

squants.market.MoneyContext provide the implicit context necessary to perform cross-currency operations on Money values with conversions automatically applied.

Some binary math operations will work on Moneys of like Currency with no MoneyContext in scope. Attempts to perform these operations on Moneys of dissimilar currencies will throw an exception at runtime.

Other operations, including direct conversions to other currencies, require a MoneyContext and will not compile without it. However, there is no compile time check to determine if the correct exchange rates will be available at runtime. Operation requiring conversion without the required rates available will throw a NoSuchExchangeRateException at runtime.

The defaultMoneyContext uses the USD as the default and provides a list of ~20 common currencies, and NO exchange rates. If your application requires something different you should initialize your own implicit MoneyContext

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• package

Definition Classes
squants
Since

0.1

• AbstractQuantityNumeric
• BaseDimension
• BinarySystem
• Dimension
• Dimensionless
• DimensionlessConversions
• DimensionlessUnit
• DoubleVector
• Dozen
• Each
• Gross
• LikeRatio
• MetricSystem
• Percent
• PrimaryUnit
• Quantity
• QuantityParseException
• QuantityRange
• QuantityVector
• Ratio
• SVector
• Score
• SiBaseUnit
• SiUnit
• SquantifiedBigDecimal
• SquantifiedDouble
• SquantifiedLong
• UnitConverter
• UnitOfMeasure
t

squants

SVector 

Companion object SVector

trait SVector[A] extends AnyRef

Root trait for representing Vectors

A

Type for the Vector's coordinate values

Source
SVector.scala
Since

0.3.0

Linear Supertypes
Known Subclasses
Ordering
1. Alphabetic
2. By Inheritance
Inherited
1. SVector
2. AnyRef
3. Any
1. Hide All
2. Show All
Visibility
1. Public
2. All

Type Members

1. abstract type SVectorType <: SVector[A]

Abstract Value Members

1. abstract def angle(coordinateX: Int = 0, coordinateY: Int = 1, unit: AngleUnit = Radians)

The angle between the two Cartesian coordinates at the supplied indices

The angle between the two Cartesian coordinates at the supplied indices

coordinateX

index of the abscissa coordinate (defaults to 0)

coordinateY

index of the ordinate coordinate (defaults to 1)

unit

unit for the angle (theta) component (defaults to Radians)

returns

Angle

2. abstract def coordinates: Seq[A]

The list of values that makeup the Vector's Cartesian coordinates

3. abstract def crossProduct(that: DoubleVector): SVector[A]

Create the Cross Product of two Vectors

Create the Cross Product of two Vectors

that

Vector[A]

4. abstract def divide(that: Double)

Reduce a Vector

Reduce a Vector

that

Double

5. abstract def dotProduct(that: DoubleVector): A

Create the Dot Product of two Vectors

Create the Dot Product of two Vectors

that

Double

6. abstract def magnitude: A

The scalar value of the Vector

7. abstract def minus(that: SVectorType)

Subtract two Vectors

Subtract two Vectors

that

Vector[A]

8. abstract def normalize

Creates the Unit Vector which corresponds to this vector

9. abstract def plus(that: SVectorType)

that

Vector[A]

10. abstract def times(that: Double)

Scale a Vector

Scale a Vector

that

Double

Concrete Value Members

1. final def !=(arg0: Any)
Definition Classes
AnyRef → Any
2. final def ##(): Int
Definition Classes
AnyRef → Any
3. def #*: (DoubleVector) ⇒ SVector[A]
4. def *(that: DoubleVector): A
5. def *: (Double) ⇒ SVectorType
6. def +: (SVectorType) ⇒ SVectorType
7. def -: (SVectorType) ⇒ SVectorType
8. def /(that: Double)
9. final def ==(arg0: Any)
Definition Classes
AnyRef → Any
10. final def asInstanceOf[T0]: T0
Definition Classes
Any
11. def clone()
Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws( ... )
12. final def eq(arg0: AnyRef)
Definition Classes
AnyRef
13. def equals(arg0: Any)
Definition Classes
AnyRef → Any
14. def finalize(): Unit
Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws( classOf[java.lang.Throwable] )
15. final def getClass(): Class[_]
Definition Classes
AnyRef → Any
16. def hashCode(): Int
Definition Classes
AnyRef → Any
17. final def isInstanceOf[T0]
Definition Classes
Any
18. final def ne(arg0: AnyRef)
Definition Classes
AnyRef
19. final def notify(): Unit
Definition Classes
AnyRef
20. final def notifyAll(): Unit
Definition Classes
AnyRef
21. def polar(coordinateX: Int = 0, coordinateY: Int = 1, unit: AngleUnit = Radians): (A, Angle)

The polar coordinates (r, theta) of the two Cartesian coordinates at the supplied indices

The polar coordinates (r, theta) of the two Cartesian coordinates at the supplied indices

coordinateX

index of the abscissa coordinate (defaults to 0)

coordinateY

index of the ordinate coordinate (defaults to 1)

unit

unit for the angle (theta) component (defaults to Radians)

returns

(A, Angle)

22. final def synchronized[T0](arg0: ⇒ T0): T0
Definition Classes
AnyRef
23. def toString(): String
Definition Classes
AnyRef → Any
24. final def wait(): Unit
Definition Classes
AnyRef
Annotations
@throws( ... )
25. final def wait(arg0: Long, arg1: Int): Unit
Definition Classes
AnyRef
Annotations
@throws( ... )
26. final def wait(arg0: Long): Unit
Definition Classes
AnyRef
Annotations
@throws( ... )