exp-pairs-0.2.1.0: Linear programming over exponent pairs

Math.ExpPairs.Matrix3

Description

Matrices of order 3 and efficient multiplication algorithms.

Synopsis

# Documentation

data Matrix3 t Source #

Matrix of order 3.

Constructors

 Matrix3 Fieldsa11 :: !t a12 :: !t a13 :: !t a21 :: !t a22 :: !t a23 :: !t a31 :: !t a32 :: !t a33 :: !t
Instances
 Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methodsfmap :: (a -> b) -> Matrix3 a -> Matrix3 b #(<\$) :: a -> Matrix3 b -> Matrix3 a # Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methodsfold :: Monoid m => Matrix3 m -> m #foldMap :: Monoid m => (a -> m) -> Matrix3 a -> m #foldr :: (a -> b -> b) -> b -> Matrix3 a -> b #foldr' :: (a -> b -> b) -> b -> Matrix3 a -> b #foldl :: (b -> a -> b) -> b -> Matrix3 a -> b #foldl' :: (b -> a -> b) -> b -> Matrix3 a -> b #foldr1 :: (a -> a -> a) -> Matrix3 a -> a #foldl1 :: (a -> a -> a) -> Matrix3 a -> a #toList :: Matrix3 a -> [a] #null :: Matrix3 a -> Bool #length :: Matrix3 a -> Int #elem :: Eq a => a -> Matrix3 a -> Bool #maximum :: Ord a => Matrix3 a -> a #minimum :: Ord a => Matrix3 a -> a #sum :: Num a => Matrix3 a -> a #product :: Num a => Matrix3 a -> a # Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methodstraverse :: Applicative f => (a -> f b) -> Matrix3 a -> f (Matrix3 b) #sequenceA :: Applicative f => Matrix3 (f a) -> f (Matrix3 a) #mapM :: Monad m => (a -> m b) -> Matrix3 a -> m (Matrix3 b) #sequence :: Monad m => Matrix3 (m a) -> m (Matrix3 a) # Eq t => Eq (Matrix3 t) Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methods(==) :: Matrix3 t -> Matrix3 t -> Bool #(/=) :: Matrix3 t -> Matrix3 t -> Bool # Fractional t => Fractional (Matrix3 t) Source # fromRational returns a diagonal matrix Instance detailsDefined in Math.ExpPairs.Matrix3 Methods(/) :: Matrix3 t -> Matrix3 t -> Matrix3 t #recip :: Matrix3 t -> Matrix3 t # Num t => Num (Matrix3 t) Source # fromInteger returns a diagonal matrix Instance detailsDefined in Math.ExpPairs.Matrix3 Methods(+) :: Matrix3 t -> Matrix3 t -> Matrix3 t #(-) :: Matrix3 t -> Matrix3 t -> Matrix3 t #(*) :: Matrix3 t -> Matrix3 t -> Matrix3 t #negate :: Matrix3 t -> Matrix3 t #abs :: Matrix3 t -> Matrix3 t #signum :: Matrix3 t -> Matrix3 t # Show t => Show (Matrix3 t) Source # Instance detailsDefined in Math.ExpPairs.Matrix3 MethodsshowsPrec :: Int -> Matrix3 t -> ShowS #show :: Matrix3 t -> String #showList :: [Matrix3 t] -> ShowS # Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Associated Typestype Rep (Matrix3 t) :: Type -> Type # Methodsfrom :: Matrix3 t -> Rep (Matrix3 t) x #to :: Rep (Matrix3 t) x -> Matrix3 t # NFData t => NFData (Matrix3 t) Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methodsrnf :: Matrix3 t -> () # Pretty t => Pretty (Matrix3 t) Source # Instance detailsDefined in Math.ExpPairs.Matrix3 Methodspretty :: Matrix3 t -> Doc ann #prettyList :: [Matrix3 t] -> Doc ann # type Rep (Matrix3 t) Source # Instance detailsDefined in Math.ExpPairs.Matrix3 type Rep (Matrix3 t) = D1 (MetaData "Matrix3" "Math.ExpPairs.Matrix3" "exp-pairs-0.2.1.0-J4IGbuSTVwXCgBqjoU0P5n" False) (C1 (MetaCons "Matrix3" PrefixI True) (((S1 (MetaSel (Just "a11") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t) :*: S1 (MetaSel (Just "a12") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t)) :*: (S1 (MetaSel (Just "a13") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t) :*: S1 (MetaSel (Just "a21") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t))) :*: ((S1 (MetaSel (Just "a22") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t) :*: S1 (MetaSel (Just "a23") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t)) :*: (S1 (MetaSel (Just "a31") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t) :*: (S1 (MetaSel (Just "a32") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t) :*: S1 (MetaSel (Just "a33") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 t))))))

fromList :: [t] -> Matrix3 t Source #

Convert a list of 9 elements into Matrix3. Reverse conversion can be done by toList.

det :: Num t => Matrix3 t -> t Source #

Compute the determinant of a matrix.

multCol :: Num t => Matrix3 t -> (t, t, t) -> (t, t, t) Source #

Multiplicate a matrix by a column vector.

normalize :: Integral t => Matrix3 t -> Matrix3 t Source #

Divide all elements of the matrix by their greatest common divisor. This is useful for matrices of projective transformations to reduce the magnitude of computations.

makarovMult :: Num t => Matrix3 t -> Matrix3 t -> Matrix3 t Source #

Multiplicate matrices under assumption that multiplication of elements is commutative. Requires 22 multiplications and 66 additions. It becomes faster than vanilla multiplication '(*)', which requires 27 multiplications and 18 additions, when matrix's elements are large (> 700 digits) integers.

An algorithm follows O. M. Makarov. An algorithm for multiplication of $$3 \times 3$$ matrices. Zh. Vychisl. Mat. i Mat. Fiz., 26(2):293–294, 320, 1986. Our contribution is reducing the number of additions from 105 to 66 by well-thought choice of intermediate variables.

ladermanMult :: Num t => Matrix3 t -> Matrix3 t -> Matrix3 t Source #

Multiplicate matrices. Requires 23 multiplications and 62 additions. It becomes faster than vanilla multiplication '(*)', which requires 27 multiplications and 18 additions, when matrix's elements are large (> 700 digits) integers.

An algorithm follows J. Laderman. A noncommutative algorithm for multiplying $$3 \times 3$$ matrices using 23 multiplications. Bull. Amer. Math. Soc., 82:126–128, 1976. Our contribution is reducing the number of additions from 98 to 62 by well-thought choice of intermediate variables.