{-# LANGUAGE TypeFamilies #-}
module Numeric.LAPACK.Orthogonal (
leastSquares,
minimumNorm,
leastSquaresMinimumNormRCond,
pseudoInverseRCond,
determinant,
determinantAbsolute,
complement,
householder,
householderTall,
) where
import qualified Numeric.LAPACK.Orthogonal.Householder as HH
import qualified Numeric.LAPACK.Orthogonal.Plain as Plain
import qualified Numeric.LAPACK.Matrix.Triangular as Triangular
import qualified Numeric.LAPACK.Matrix.Array as ArrMatrix
import qualified Numeric.LAPACK.Matrix.Basic as Basic
import qualified Numeric.LAPACK.Matrix.Extent.Private as Extent
import Numeric.LAPACK.Matrix.Array (Full, Tall, Square)
import Numeric.LAPACK.Matrix.Private (ShapeInt)
import Numeric.LAPACK.Scalar (RealOf)
import qualified Numeric.Netlib.Class as Class
import qualified Data.Array.Comfort.Shape as Shape
import Data.Tuple.HT (mapSnd)
leastSquares ::
(Extent.C vert, Extent.C horiz,
Shape.C height, Eq height, Shape.C width, Shape.C nrhs, Class.Floating a) =>
Full horiz Extent.Small height width a ->
Full vert horiz height nrhs a ->
Full vert horiz width nrhs a
leastSquares = ArrMatrix.lift2 Plain.leastSquares
minimumNorm ::
(Extent.C vert, Extent.C horiz,
Shape.C height, Eq height, Shape.C width, Shape.C nrhs, Class.Floating a) =>
Full Extent.Small vert height width a ->
Full vert horiz height nrhs a ->
Full vert horiz width nrhs a
minimumNorm = ArrMatrix.lift2 Plain.minimumNorm
leastSquaresMinimumNormRCond ::
(Extent.C vert, Extent.C horiz,
Shape.C height, Eq height, Shape.C width, Shape.C nrhs, Class.Floating a) =>
RealOf a ->
Full horiz vert height width a ->
Full vert horiz height nrhs a ->
(Int, Full vert horiz width nrhs a)
leastSquaresMinimumNormRCond rcond a b =
mapSnd ArrMatrix.lift0 $
Plain.leastSquaresMinimumNormRCond
rcond (ArrMatrix.toVector a) (ArrMatrix.toVector b)
pseudoInverseRCond ::
(Extent.C vert, Extent.C horiz, Shape.C height, Shape.C width,
Class.Floating a) =>
RealOf a ->
Full vert horiz height width a ->
(Int, Full horiz vert width height a)
pseudoInverseRCond rcond =
mapSnd (ArrMatrix.lift0 . Basic.recheck) .
Plain.pseudoInverseRCond rcond .
Basic.uncheck . ArrMatrix.toVector
householder ::
(Extent.C vert, Extent.C horiz, Shape.C height, Shape.C width,
Class.Floating a) =>
Full vert horiz height width a ->
(Square height a, Full vert horiz height width a)
householder a =
let hh = HH.fromMatrix a
in (HH.extractQ hh, HH.extractR hh)
householderTall ::
(Extent.C vert, Shape.C height, Shape.C width, Class.Floating a) =>
Full vert Extent.Small height width a ->
(Full vert Extent.Small height width a, Triangular.Upper width a)
householderTall a =
let hh = HH.fromMatrix a
in (HH.tallExtractQ hh, HH.tallExtractR hh)
determinant :: (Shape.C sh, Class.Floating a) => Square sh a -> a
determinant = HH.determinant . HH.fromMatrix
determinantAbsolute ::
(Extent.C vert, Extent.C horiz, Shape.C height, Shape.C width,
Class.Floating a) =>
Full vert horiz height width a -> RealOf a
determinantAbsolute = Plain.determinantAbsolute . ArrMatrix.toVector
complement ::
(Shape.C height, Shape.C width, Class.Floating a) =>
Tall height width a -> Tall height ShapeInt a
complement = ArrMatrix.lift1 Plain.complement