safe-tensor-0.2.1.1: Dependently typed tensor algebra
Copyright(c) Nils Alex 2020
LicenseMIT
Maintainernils.alex@fau.de
Safe HaskellSafe
LanguageHaskell2010

Math.Tensor.LinearAlgebra.Scalar

Description

Scalar types for usage as Tensor values.

Synopsis

Documentation

newtype Lin a Source #

Linear combination represented as mapping from variable number to prefactor.

Constructors

Lin (IntMap a) 

Instances

Instances details
Eq a => Eq (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

(==) :: Lin a -> Lin a -> Bool #

(/=) :: Lin a -> Lin a -> Bool #

Ord a => Ord (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

compare :: Lin a -> Lin a -> Ordering #

(<) :: Lin a -> Lin a -> Bool #

(<=) :: Lin a -> Lin a -> Bool #

(>) :: Lin a -> Lin a -> Bool #

(>=) :: Lin a -> Lin a -> Bool #

max :: Lin a -> Lin a -> Lin a #

min :: Lin a -> Lin a -> Lin a #

Show a => Show (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

showsPrec :: Int -> Lin a -> ShowS #

show :: Lin a -> String #

showList :: [Lin a] -> ShowS #

Generic (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Associated Types

type Rep (Lin a) :: Type -> Type #

Methods

from :: Lin a -> Rep (Lin a) x #

to :: Rep (Lin a) x -> Lin a #

NFData a => NFData (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

rnf :: Lin a -> () #

type Rep (Lin a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

type Rep (Lin a) = D1 ('MetaData "Lin" "Math.Tensor.LinearAlgebra.Scalar" "safe-tensor-0.2.1.1-HV6XtoU04VwKCpzbN3KLoQ" 'True) (C1 ('MetaCons "Lin" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IntMap a))))

data Poly a Source #

Polynomial: Can be constant, affine, or something of higher rank which is not yet implemented.

Constructors

Const !a

constant value

Affine !a !(Lin a)

constant value plus linear term

NotSupported

higher rank

Instances

Instances details
Eq a => Eq (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

(==) :: Poly a -> Poly a -> Bool #

(/=) :: Poly a -> Poly a -> Bool #

(Num a, Eq a) => Num (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

(+) :: Poly a -> Poly a -> Poly a #

(-) :: Poly a -> Poly a -> Poly a #

(*) :: Poly a -> Poly a -> Poly a #

negate :: Poly a -> Poly a #

abs :: Poly a -> Poly a #

signum :: Poly a -> Poly a #

fromInteger :: Integer -> Poly a #

Ord a => Ord (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

compare :: Poly a -> Poly a -> Ordering #

(<) :: Poly a -> Poly a -> Bool #

(<=) :: Poly a -> Poly a -> Bool #

(>) :: Poly a -> Poly a -> Bool #

(>=) :: Poly a -> Poly a -> Bool #

max :: Poly a -> Poly a -> Poly a #

min :: Poly a -> Poly a -> Poly a #

Show a => Show (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

showsPrec :: Int -> Poly a -> ShowS #

show :: Poly a -> String #

showList :: [Poly a] -> ShowS #

Generic (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Associated Types

type Rep (Poly a) :: Type -> Type #

Methods

from :: Poly a -> Rep (Poly a) x #

to :: Rep (Poly a) x -> Poly a #

NFData a => NFData (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

Methods

rnf :: Poly a -> () #

type Rep (Poly a) Source # 
Instance details

Defined in Math.Tensor.LinearAlgebra.Scalar

type Rep (Poly a) = D1 ('MetaData "Poly" "Math.Tensor.LinearAlgebra.Scalar" "safe-tensor-0.2.1.1-HV6XtoU04VwKCpzbN3KLoQ" 'False) (C1 ('MetaCons "Const" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: (C1 ('MetaCons "Affine" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Lin a))) :+: C1 ('MetaCons "NotSupported" 'PrefixI 'False) (U1 :: Type -> Type)))

singletonPoly Source #

Arguments

:: a

constant

-> Int

variable number

-> a

prefactor

-> Poly a 

Produces an affine value \(c + a\cdot x_i\)

polyMap :: (a -> b) -> Poly a -> Poly b Source #

Maps over Poly

getVars :: Poly a -> [Int] Source #

Returns list of variable numbers present in the polynomial.

shiftVars :: Int -> Poly a -> Poly a Source #

Shifts variable numbers in the polynomial by a constant value.

normalize :: (Fractional a, Eq a) => Poly a -> Poly a Source #

Normalizes a polynomial: \[ \mathrm{normalize}(c) = 1 \\ \mathrm{normalize}(c + a_1\cdot x_1 + a_2\cdot x_2 + \dots + a_n\cdot x_n) = \frac{c}{a_1} + 1\cdot x_1 + \frac{a_2}{a_1}\cdot x_2 + \dots + \frac{a_n}{a_1}\cdot x_n \]