-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Eigen C++ library (linear algebra: matrices, sparse matrices, vectors, numerical solvers). -- -- NOTE: This library does not follow PVP. Instead, it follows -- Eigen's versioning. Version X.Y.Z.W means that the Eigen version is -- X.Y.Z, and the haskell release is W, where each W release is for bug -- fixes/API improvements. -- -- This module provides Haskell binding for Eigen C++ library. -- -- Eigen is versatile. -- -- -- -- Eigen is fast. -- -- -- -- Eigen is reliable. -- -- -- -- Eigen is elegant. -- -- -- -- Eigen has good compiler support as we run our test suite against many -- compilers to guarantee reliability and work around any compiler bugs. -- Eigen also is standard C++98 and maintains very reasonable compilation -- times. -- -- Eigen is licensed under the MPL2, which is a simple weak copyleft -- license. Common questions about the MPL2 are answered in the official -- MPL2 FAQ at http://www.mozilla.org/MPL/2.0/FAQ.html. -- -- Note that currently, a few features in Eigen rely on third-party code -- licensed under the LGPL: SimplicialCholesky, AMD ordering, and -- constrained_cg. Such features are explicitly disabled by compiling -- Eigen with the EIGEN_MPL2_ONLY preprocessor symbol defined. -- -- Virtually any software may use Eigen. For example, closed-source -- software may use Eigen without having to disclose its own source code. -- Many proprietary and closed-source software projects are using Eigen -- right now, as well as many BSD-licensed projects. -- -- Documentation at the most extent replicates original Eigen -- documentation. @package eigen @version 3.3.7.0 -- | Internal module to Eigen. Here we define all foreign function calls, -- and some typeclasses integral to the public and private interfaces of -- the library. module Eigen.Internal -- | Like Proxy, but specialised to Nat. data Row (r :: Nat) Row :: Row -- | Like Proxy, but specialised to Nat. data Col (c :: Nat) Col :: Col -- | Used internally. Given a KnownNat constraint, turn the -- type-level Nat into an Int. natToInt :: forall n. KnownNat n => Int -- | Cast to and from a C-FFI type Cast is a closed typeclass with -- an associated injective type family. It is closed in the sense that we -- provide only four types with instances for it; and intend for eigen to -- only be used with those four types. The injectivity of the type family -- is then useful for avoiding MPTCs. Cast has two functions; -- toC and fromC, where toC goes from a Haskell type -- to its associated C type for internal use, with the C FFI, and -- fromC goes from the associated C type to the Haskell type. class Cast (a :: Type) where { type family C a = (result :: Type) | result -> a; } toC :: Cast a => a -> C a fromC :: Cast a => C a -> a -- | Complex number for FFI with the same memory layout as -- std::complex<T> data CComplex a CComplex :: !a -> !a -> CComplex a -- | FIXME: Doc data CTriplet a [CTriplet] :: Cast a => !CInt -> !CInt -> !(C a) -> CTriplet a -- | Elem is a closed typeclass that encompasses the properties -- eigen expects its values to possess, and simplifies the external API -- quite a bit. class (Num a, Cast a, Storable a, Storable (C a), Code (C a)) => Elem a -- | Encode a C Type as a CInt -- -- Hack used in FFI wrapper functions when constructing FFI calls class Code a code :: Code a => a -> CInt -- | Hack used in constructing FFI calls. newtype MagicCode MagicCode :: CInt -> MagicCode -- | Hack used in constructing FFI calls. magicCode :: Code a => a -> MagicCode -- | Machine size of a CInt. intSize :: Int -- | FIXME: Doc encodeInt :: CInt -> ByteString -- | FIXME: Doc decodeInt :: ByteString -> CInt -- | FIXME: Doc data CSparseMatrix a -- | FIXME: Doc type CSparseMatrixPtr a = Ptr (CSparseMatrix a) -- | FIXME: Doc data CSolver a -- | FIXME: Doc type CSolverPtr a = Ptr (CSolver a) -- | FIXME: replace with unholyPerformIO (?) performIO :: IO a -> a -- | FIXME: Doc plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b c_freeString :: CString -> IO () call :: IO CString -> IO () free :: Ptr a -> IO () c_setNbThreads :: CInt -> IO () c_getNbThreads :: IO CInt c_random :: CInt -> Ptr (C a) -> CInt -> CInt -> IO CString random :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> IO CString c_identity :: CInt -> Ptr (C a) -> CInt -> CInt -> IO CString identity :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> IO CString c_add :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString add :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_sub :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString sub :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_mul :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_diagonal :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString mul :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString diagonal :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_transpose :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString transpose :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_inverse :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString inverse :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_adjoint :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString adjoint :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_conjugate :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_normalize :: CInt -> Ptr (C a) -> CInt -> CInt -> IO CString conjugate :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString normalize :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> IO CString c_sum :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString sum :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_prod :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString prod :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_mean :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString mean :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_norm :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString norm :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_trace :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString trace :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_squaredNorm :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString squaredNorm :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_blueNorm :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString blueNorm :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_hypotNorm :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString hypotNorm :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_determinant :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString determinant :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> IO CString c_rank :: CInt -> CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString rank :: forall a. Code (C a) => CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_image :: CInt -> CInt -> Ptr (Ptr (C a)) -> Ptr CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString image :: forall a. Code (C a) => CInt -> Ptr (Ptr (C a)) -> Ptr CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_kernel :: CInt -> CInt -> Ptr (Ptr (C a)) -> Ptr CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString kernel :: forall a. Code (C a) => CInt -> Ptr (Ptr (C a)) -> Ptr CInt -> Ptr CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_solve :: CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString solve :: forall a. Code (C a) => CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_relativeError :: CInt -> Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString relativeError :: forall a. Code (C a) => Ptr (C a) -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (C a) -> CInt -> CInt -> IO CString c_sparse_new :: CInt -> CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_new :: forall a. Code (C a) => CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_clone :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_clone :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_fromList :: CInt -> CInt -> CInt -> Ptr (CTriplet a) -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_fromList :: forall a. Code (C a) => CInt -> CInt -> Ptr (CTriplet a) -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_toList :: CInt -> CSparseMatrixPtr a -> Ptr (CTriplet a) -> CInt -> IO CString c_sparse_free :: CInt -> CSparseMatrixPtr a -> IO CString sparse_toList :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CTriplet a) -> CInt -> IO CString sparse_free :: forall a. Code (C a) => CSparseMatrixPtr a -> IO CString c_sparse_makeCompressed :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_makeCompressed :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_uncompress :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_uncompress :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_isCompressed :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_isCompressed :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_transpose :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_transpose :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_adjoint :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_adjoint :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_pruned :: CInt -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_pruned :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_prunedRef :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_prunedRef :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_scale :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_scale :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_nonZeros :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_nonZeros :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_innerSize :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_innerSize :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_outerSize :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_outerSize :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_coeff :: CInt -> CSparseMatrixPtr a -> CInt -> CInt -> Ptr (C a) -> IO CString sparse_coeff :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> CInt -> Ptr (C a) -> IO CString c_sparse_coeffRef :: CInt -> CSparseMatrixPtr a -> CInt -> CInt -> Ptr (Ptr (C a)) -> IO CString c_sparse_cols :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_coeffRef :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> CInt -> Ptr (Ptr (C a)) -> IO CString sparse_cols :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_rows :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> IO CString sparse_rows :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> IO CString c_sparse_norm :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> IO CString sparse_norm :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> IO CString c_sparse_squaredNorm :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> IO CString sparse_squaredNorm :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> IO CString c_sparse_blueNorm :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> IO CString sparse_blueNorm :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> IO CString c_sparse_add :: CInt -> CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_add :: forall a. Code (C a) => CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_sub :: CInt -> CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_sub :: forall a. Code (C a) => CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_mul :: CInt -> CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_mul :: forall a. Code (C a) => CSparseMatrixPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_block :: CInt -> CSparseMatrixPtr a -> CInt -> CInt -> CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_block :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> CInt -> CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_fromMatrix :: CInt -> Ptr (C a) -> CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_fromMatrix :: forall a. Code (C a) => Ptr (C a) -> CInt -> CInt -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_toMatrix :: CInt -> CSparseMatrixPtr a -> Ptr (C a) -> CInt -> CInt -> IO CString sparse_toMatrix :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr (C a) -> CInt -> CInt -> IO CString c_sparse_values :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr (C a)) -> IO CString sparse_values :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr (C a)) -> IO CString c_sparse_outerStarts :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString sparse_outerStarts :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString c_sparse_innerIndices :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString sparse_innerIndices :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString c_sparse_innerNNZs :: CInt -> CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString c_sparse_setZero :: CInt -> CSparseMatrixPtr a -> IO CString sparse_innerNNZs :: forall a. Code (C a) => CSparseMatrixPtr a -> Ptr CInt -> Ptr (Ptr CInt) -> IO CString sparse_setZero :: forall a. Code (C a) => CSparseMatrixPtr a -> IO CString c_sparse_setIdentity :: CInt -> CSparseMatrixPtr a -> IO CString sparse_setIdentity :: forall a. Code (C a) => CSparseMatrixPtr a -> IO CString c_sparse_reserve :: CInt -> CSparseMatrixPtr a -> CInt -> IO CString sparse_reserve :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> IO CString c_sparse_resize :: CInt -> CSparseMatrixPtr a -> CInt -> CInt -> IO CString sparse_resize :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> CInt -> IO CString c_sparse_conservativeResize :: CInt -> CSparseMatrixPtr a -> CInt -> CInt -> IO CString sparse_conservativeResize :: forall a. Code (C a) => CSparseMatrixPtr a -> CInt -> CInt -> IO CString c_sparse_compressInplace :: CInt -> CSparseMatrixPtr a -> IO CString sparse_compressInplace :: forall a. Code (C a) => CSparseMatrixPtr a -> IO CString c_sparse_uncompressInplace :: CInt -> CSparseMatrixPtr a -> IO CString sparse_uncompressInplace :: forall a. Code (C a) => CSparseMatrixPtr a -> IO CString c_sparse_la_newSolver :: CInt -> CInt -> Ptr (CSolverPtr a) -> IO CString sparse_la_newSolver :: forall s a. (Code s, Code (C a)) => s -> Ptr (CSolverPtr a) -> IO CString c_sparse_la_freeSolver :: CInt -> CInt -> CSolverPtr a -> IO CString sparse_la_freeSolver :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> IO CString c_sparse_la_factorize :: CInt -> CInt -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString sparse_la_factorize :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString c_sparse_la_analyzePattern :: CInt -> CInt -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString sparse_la_analyzePattern :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString c_sparse_la_compute :: CInt -> CInt -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString sparse_la_compute :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CSparseMatrixPtr a -> IO CString c_sparse_la_tolerance :: CInt -> CInt -> CSolverPtr a -> Ptr CDouble -> IO CString sparse_la_tolerance :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CDouble -> IO CString c_sparse_la_setTolerance :: CInt -> CInt -> CSolverPtr a -> CDouble -> IO CString sparse_la_setTolerance :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CDouble -> IO CString c_sparse_la_maxIterations :: CInt -> CInt -> CSolverPtr a -> Ptr CInt -> IO CString sparse_la_maxIterations :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CInt -> IO CString c_sparse_la_setMaxIterations :: CInt -> CInt -> CSolverPtr a -> CInt -> IO CString sparse_la_setMaxIterations :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CInt -> IO CString c_sparse_la_info :: CInt -> CInt -> CSolverPtr a -> Ptr CInt -> IO CString sparse_la_info :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CInt -> IO CString c_sparse_la_error :: CInt -> CInt -> CSolverPtr a -> Ptr CDouble -> IO CString sparse_la_error :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CDouble -> IO CString c_sparse_la_iterations :: CInt -> CInt -> CSolverPtr a -> Ptr CInt -> IO CString sparse_la_iterations :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CInt -> IO CString c_sparse_la_solve :: CInt -> CInt -> CSolverPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_la_solve :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CSparseMatrixPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_la_matrixQ :: CInt -> CInt -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_la_matrixQ :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_la_matrixR :: CInt -> CInt -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_la_matrixR :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_la_setPivotThreshold :: CInt -> CInt -> CSolverPtr a -> CDouble -> IO CString sparse_la_setPivotThreshold :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CDouble -> IO CString c_sparse_la_rank :: CInt -> CInt -> CSolverPtr a -> Ptr CInt -> IO CString sparse_la_rank :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr CInt -> IO CString c_sparse_la_matrixL :: CInt -> CInt -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_la_matrixL :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_la_matrixU :: CInt -> CInt -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString sparse_la_matrixU :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (CSparseMatrixPtr a) -> IO CString c_sparse_la_setSymmetric :: CInt -> CInt -> CSolverPtr a -> CInt -> IO CString sparse_la_setSymmetric :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> CInt -> IO CString c_sparse_la_determinant :: CInt -> CInt -> CSolverPtr a -> Ptr (C a) -> IO CString sparse_la_determinant :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (C a) -> IO CString c_sparse_la_logAbsDeterminant :: CInt -> CInt -> CSolverPtr a -> Ptr (C a) -> IO CString sparse_la_logAbsDeterminant :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (C a) -> IO CString c_sparse_la_absDeterminant :: CInt -> CInt -> CSolverPtr a -> Ptr (C a) -> IO CString sparse_la_absDeterminant :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (C a) -> IO CString c_sparse_la_signDeterminant :: CInt -> CInt -> CSolverPtr a -> Ptr (C a) -> IO CString sparse_la_signDeterminant :: forall s a. (Code s, Code (C a)) => s -> CSolverPtr a -> Ptr (C a) -> IO CString instance GHC.Classes.Eq Eigen.Internal.MagicCode instance GHC.Show.Show a => GHC.Show.Show (Eigen.Internal.CComplex a) instance (GHC.Show.Show a, GHC.Show.Show (Eigen.Internal.C a)) => GHC.Show.Show (Eigen.Internal.CTriplet a) instance Data.Binary.Class.Binary Eigen.Internal.MagicCode instance (Foreign.Storable.Storable a, Eigen.Internal.Elem a) => Foreign.Storable.Storable (Eigen.Internal.CTriplet a) instance Eigen.Internal.Elem GHC.Types.Float instance Eigen.Internal.Elem GHC.Types.Double instance Eigen.Internal.Elem (Data.Complex.Complex GHC.Types.Float) instance Eigen.Internal.Elem (Data.Complex.Complex GHC.Types.Double) instance Eigen.Internal.Code Foreign.C.Types.CFloat instance Eigen.Internal.Code Foreign.C.Types.CDouble instance Eigen.Internal.Code (Eigen.Internal.CComplex Foreign.C.Types.CFloat) instance Eigen.Internal.Code (Eigen.Internal.CComplex Foreign.C.Types.CDouble) instance Eigen.Internal.Cast a => Eigen.Internal.Cast (GHC.Types.Int, GHC.Types.Int, a) instance Eigen.Internal.Cast a => Eigen.Internal.Cast (Data.Complex.Complex a) instance Foreign.Storable.Storable a => Foreign.Storable.Storable (Eigen.Internal.CComplex a) instance Eigen.Internal.Cast GHC.Types.Int instance Eigen.Internal.Cast GHC.Types.Float instance Eigen.Internal.Cast GHC.Types.Double instance Foreign.Storable.Storable a => Data.Binary.Class.Binary (Data.Vector.Storable.Vector a) module Eigen.Matrix.Mutable -- | A mutable matrix. See Matrix for details about matrix layout. newtype MMatrix :: Nat -> Nat -> Type -> Type -> Type [MMatrix] :: Vec (n * m) s a -> MMatrix n m s a -- | Alias for single precision mutable matrix type MMatrixXf n m s = MMatrix n m s Float -- | Alias for double precision mutable matrix type MMatrixXd n m s = MMatrix n m s Double -- | Alias for single precision mutable matrix of complex numbers type MMatrixXcf n m s = MMatrix n m s (Complex Float) -- | Alias for double precision mutable matrix of complex numbers type MMatrixXcd n m s = MMatrix n m s (Complex Double) -- | A mutable matrix where the state token is specialised to -- RealWorld. type IOMatrix n m a = MMatrix n m RealWorld a -- | This type does not differ from MSparseMatrix, but might be desirable -- for readability. type STMatrix n m s a = MMatrix n m s a -- | Create a mutable matrix of the given size and fill it with 0 as an -- initial value. new :: (PrimMonad p, Elem a, KnownNat n, KnownNat m) => p (MMatrix n m (PrimState p) a) -- | Create a mutable matrix of the given size and fill it with an initial -- value. replicate :: forall n m p a. (PrimMonad p, Elem a, KnownNat n, KnownNat m) => a -> p (MMatrix n m (PrimState p) a) -- | Yield the element at the given position. read :: forall n m p a r c. (PrimMonad p, Elem a, KnownNat n, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> MMatrix n m (PrimState p) a -> p a -- | Replace the element at the given position. write :: forall n m p a r c. (PrimMonad p, Elem a, KnownNat n, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> MMatrix n m (PrimState p) a -> a -> p () -- | Set all elements of the matrix to a given value. set :: (PrimMonad p, Elem a) => MMatrix n m (PrimState p) a -> a -> p () -- | Copy a matrix. copy :: (PrimMonad p, Elem a) => MMatrix n m (PrimState p) a -> MMatrix n m (PrimState p) a -> p () -- | Pass a pointer to the matrix's data to the IO action. Modifying dat -- through the pointer is unsafe if the matrix could have been frozen -- before the modification. unsafeWith :: forall n m a b. (KnownNat n, KnownNat m, Elem a) => IOMatrix n m a -> (Ptr (C a) -> CInt -> CInt -> IO b) -> IO b -- | Return a mutable storable MVector of the corresponding C types -- to one's mutable matrix. vals :: MMatrix n m s a -> MVector s (C a) -- | Create a mutable matrix from a mutable storable MVector. fromVector :: Elem a => MVector s (C a) -> MMatrix n m s a module Eigen.Matrix -- | Matrix to be used in pure computations. -- -- newtype Matrix :: Nat -> Nat -> Type -> Type [Matrix] :: Vec (n * m) a -> Matrix n m a -- | Used internally to track the size and corresponding C type of the -- matrix. newtype Vec :: Nat -> Type -> Type [Vec] :: Vector (C a) -> Vec n a -- | Alias for single precision matrix type MatrixXf n m = Matrix n m Float -- | Alias for double precision matrix type MatrixXd n m = Matrix n m Double -- | Alias for single precision matrix of complex numbers type MatrixXcf n m = Matrix n m (Complex Float) -- | Alias for double precision matrix of complex numbers type MatrixXcd n m = Matrix n m (Complex Double) -- | Elem is a closed typeclass that encompasses the properties -- eigen expects its values to possess, and simplifies the external API -- quite a bit. class (Num a, Cast a, Storable a, Storable (C a), Code (C a)) => Elem a -- | Used internally. Given a KnownNat constraint, turn the -- type-level Nat into an Int. natToInt :: forall n. KnownNat n => Int -- | Like Proxy, but specialised to Nat. data Row (r :: Nat) Row :: Row -- | Like Proxy, but specialised to Nat. data Col (c :: Nat) Col :: Col -- | Encode the sparse matrix as a lazy bytestring encode :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> ByteString -- | Decode the sparse matrix from a lazy bytestring decode :: (Elem a, KnownNat n, KnownNat m) => ByteString -> Matrix n m a -- | Is matrix empty? null :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Bool -- | Is matrix square? square :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Bool -- | The number of rows in the matrix rows :: forall n m a. KnownNat n => Matrix n m a -> Int -- | The number of colums in the matrix cols :: forall n m a. KnownNat m => Matrix n m a -> Int -- | Return Matrix size as a pair of (rows, cols) dims :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> (Int, Int) -- | Construct an empty 0x0 matrix empty :: Elem a => Matrix 0 0 a -- | Matrix where all coeffs are filled with the given value constant :: forall n m a. (Elem a, KnownNat n, KnownNat m) => a -> Matrix n m a -- | Matrix where all coeffs are filled with 0 zero :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -- | Matrix where all coeffs are filled with 1 ones :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -- | The identity matrix (not necessarily square) identity :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Matrix n m a -- | The random matrix of a given size random :: forall n m a. (Elem a, KnownNat n, KnownNat m) => IO (Matrix n m a) -- | Return the diagonal of a matrix. diagonal :: (Elem a, KnownNat n, KnownNat m, r ~ Min n m, KnownNat r) => Matrix n m a -> Matrix r 1 a -- | Return the value at the given position. (!) :: forall n m a r c. (Elem a, KnownNat n, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> Matrix n m a -> a -- | Return the value at the given position. coeff :: forall n m a r c. (Elem a, KnownNat n, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> Matrix n m a -> a -- | Given a generation function `f :: Int -> Int -> a`, construct a -- Matrix of known size using points in the matrix as inputs. generate :: forall n m a. (Elem a, KnownNat n, KnownNat m) => (Int -> Int -> a) -> Matrix n m a -- | The sum of all coefficients in the matrix sum :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The product of all coefficients in the matrix prod :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The arithmetic mean of all coefficients in the matrix mean :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The trace of a matrix is the sum of the diagonal coefficients. -- -- trace m == sum (diagonal m) trace :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | Given a predicate p, determine if all values in the Matrix satisfy p. all :: (Elem a, KnownNat n, KnownNat m) => (a -> Bool) -> Matrix n m a -> Bool -- | Given a predicate p, determine if any values in the Matrix satisfy p. any :: (Elem a, KnownNat n, KnownNat m) => (a -> Bool) -> Matrix n m a -> Bool -- | Given a predicate p, determine how many values in the Matrix satisfy -- p. count :: (Elem a, KnownNat n, KnownNat m) => (a -> Bool) -> Matrix n m a -> Int -- | For vectors, the l2 norm, and for matrices the Frobenius norm. In both -- cases, it consists in the square root of the sum of the square of all -- the matrix entries. For vectors, this is also equals to the square -- root of the dot product of this with itself. norm :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | For vectors, the squared l2 norm, and for matrices the Frobenius norm. -- In both cases, it consists in the sum of the square of all the matrix -- entries. For vectors, this is also equals to the dot product of this -- with itself. squaredNorm :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The l2 norm of the matrix using the Blue's algorithm. A Portable -- Fortran Program to Find the Euclidean Norm of a Vector, ACM TOMS, Vol -- 4, Issue 1, 1978. blueNorm :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The l2 norm of the matrix avoiding undeflow and overflow. This version -- use a concatenation of hypot calls, and it is very slow. hypotNorm :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> a -- | The determinant of the matrix determinant :: forall n a. (Elem a, KnownNat n) => Matrix n n a -> a -- | Add two matrices. add :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix n m a -> Matrix n m a -- | Subtract two matrices. sub :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix n m a -> Matrix n m a -- | Multiply two matrices. mul :: (Elem a, KnownNat p, KnownNat q, KnownNat r) => Matrix p q a -> Matrix q r a -> Matrix p r a -- | Apply a given function to each element of the matrix. Here is an -- example how to implement scalar matrix multiplication: -- --
--   >>> let a = fromList [[1,2],[3,4]] :: MatrixXf 2 2
--   
--   >>> a
--   Matrix 2x2
--   1.0 2.0
--   3.0 4.0
--   
--   >>> map (*10) a
--   Matrix 2x2
--   10.0    20.0
--   30.0    40.0
--   
map :: Elem a => (a -> a) -> Matrix n m a -> Matrix n m a -- | Apply a given function to each element of the matrix. Here is an -- example how upper triangular matrix can be implemented: >>> -- let a = fromList [[1,2,3],[4,5,6],[7,8,9]] :: MatrixXf >>> a -- Matrix 3x3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 >>> imap (row -- col val -> if row <= col then val else 0) a Matrix 3x3 1.0 2.0 -- 3.0 0.0 5.0 6.0 0.0 0.0 9.0 imap :: (Elem a, KnownNat n, KnownNat m) => (Int -> Int -> a -> a) -> Matrix n m a -> Matrix n m a -- | Provide a view of the matrix for extraction of a subset. data TriangularMode -- | View matrix as a lower triangular matrix. Lower :: TriangularMode -- | View matrix as an upper triangular matrix. Upper :: TriangularMode -- | View matrix as a lower triangular matrix with zeros on the diagonal. StrictlyLower :: TriangularMode -- | View matrix as an upper triangular matrix with zeros on the diagonal. StrictlyUpper :: TriangularMode -- | View matrix as a lower triangular matrix with ones on the diagonal. UnitLower :: TriangularMode -- | View matrix as an upper triangular matrix with ones on the diagonal. UnitUpper :: TriangularMode -- | Triangular view extracted from the current matrix triangularView :: (Elem a, KnownNat n, KnownNat m) => TriangularMode -> Matrix n m a -> Matrix n m a -- | Filter elements in the matrix. Filtered elements will be replaced by -- 0. filter :: Elem a => (a -> Bool) -> Matrix n m a -> Matrix n m a -- | Filter elements in the matrix with an indexed predicate. Filtered -- elements will be replaces by 0. ifilter :: (Elem a, KnownNat n, KnownNat m) => (Int -> Int -> a -> Bool) -> Matrix n m a -> Matrix n m a -- | The length of the matrix. length :: forall n m a r. (Elem a, KnownNat n, KnownNat m, r ~ (n * m), KnownNat r) => Matrix n m a -> Int -- | Left fold of a matrix, where accumulation is lazy. foldl :: (Elem a, KnownNat n, KnownNat m) => (b -> a -> b) -> b -> Matrix n m a -> b -- | Right fold of a matrix, where accumulation is strict. foldl' :: Elem a => (b -> a -> b) -> b -> Matrix n m a -> b -- | Inverse of the matrix For small fixed sizes up to 4x4, this method -- uses cofactors. In the general case, this method uses PartialPivLU -- decomposition inverse :: forall n a. (Elem a, KnownNat n) => Matrix n n a -> Matrix n n a -- | Adjoint of the matrix adjoint :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix m n a -- | Transpose of the matrix transpose :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix m n a -- | Conjugate of the matrix conjugate :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix n m a -- | Normalise the matrix by dividing it on its norm normalize :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> Matrix n m a -- | Apply a destructive operation to a matrix. The operation will be -- performed in-place, if it is safe to do so - otherwise, it will create -- a copy of the matrix. modify :: (Elem a, KnownNat n, KnownNat m) => (forall s. MMatrix n m s a -> ST s ()) -> Matrix n m a -> Matrix n m a -- | Extract rectangular block from matrix defined by startRow startCol -- blockRows blockCols block :: forall sr sc br bc n m a. (Elem a, KnownNat sr, KnownNat sc, KnownNat br, KnownNat bc, KnownNat n, KnownNat m) => (sr <= n, sc <= m, br <= n, bc <= m) => Row sr -> Col sc -> Row br -> Col bc -> Matrix n m a -> Matrix br bc a -- | Turn a mutable matrix into an immutable matrix without copying. The -- mutable matrix should not be modified after this conversion. unsafeFreeze :: (Elem a, KnownNat n, KnownNat m, PrimMonad p) => MMatrix n m (PrimState p) a -> p (Matrix n m a) -- | Pass a pointer to the matrix's data to the IO action. The data may not -- be modified through the pointer. unsafeWith :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> (Ptr (C a) -> CInt -> CInt -> IO b) -> IO b -- | Convert a list to a matrix. Returns Nothing if the dimensions -- of the list do not match that of the matrix. fromList :: forall n m a. (Elem a, KnownNat n, KnownNat m) => [[a]] -> Maybe (Matrix n m a) -- | Convert a matrix to a list. toList :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> [[a]] instance GHC.Read.Read Eigen.Matrix.TriangularMode instance GHC.Show.Show Eigen.Matrix.TriangularMode instance GHC.Enum.Enum Eigen.Matrix.TriangularMode instance GHC.Classes.Eq Eigen.Matrix.TriangularMode instance (Eigen.Internal.Elem a, GHC.Show.Show a, GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m) => GHC.Show.Show (Eigen.Matrix.Matrix n m a) instance (GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m, Eigen.Internal.Elem a) => Data.Binary.Class.Binary (Eigen.Matrix.Matrix n m a) -- | Some of Eigen's algorithms can exploit the multiple cores present in -- your hardware. To this end, it is enough to enable OpenMP on your -- compiler, for instance: GCC: -fopenmp. You can control the number of -- threads that will be used using either by the OpenMP API or by Eigen's -- API using the following priority: -- --
    --
  1. OMP_NUM_THREADS=n ./my_program
  2. --
  3. setNbThreads n
  4. --
-- -- Unless setNbThreads has been called, Eigen uses the number of threads -- specified by OpenMP. You can restore this behaviour by calling -- setNbThreads n -- -- Currently, the following algorithms can make use of multi-threading: -- general matrix - matrix products PartialPivLU. module Eigen.Parallel -- | Sets the max number of threads reserved for Eigen setNbThreads :: Int -> IO () -- | Gets the max number of threads reserved for Eigen getNbThreads :: IO Int module Eigen.Solver.LA -- |
--   Decomposition           Requirements on the matrix          Speed   Accuracy  Rank  Kernel  Image
--   
--   PartialPivLU            Invertible                          ++      +         -     -       -
--   FullPivLU               None                                -       +++       +     +       +
--   HouseholderQR           None                                ++      +         -     -       -
--   ColPivHouseholderQR     None                                +       ++        +     -       -
--   FullPivHouseholderQR    None                                -       +++       +     -       -
--   LLT                     Positive definite                   +++     +         -     -       -
--   LDLT                    Positive or negative semidefinite   +++     ++        -     -       -
--   JacobiSVD               None                                -       +++       +     -       -
--   
-- -- The best way to do least squares solving for square matrices is with a -- SVD decomposition (JacobiSVD) data Decomposition -- | LU decomposition of a matrix with partial pivoting. PartialPivLU :: Decomposition -- | LU decomposition of a matrix with complete pivoting. FullPivLU :: Decomposition -- | Householder QR decomposition of a matrix. HouseholderQR :: Decomposition -- | Householder rank-revealing QR decomposition of a matrix with -- column-pivoting. ColPivHouseholderQR :: Decomposition -- | Householder rank-revealing QR decomposition of a matrix with full -- pivoting. FullPivHouseholderQR :: Decomposition -- | Standard Cholesky decomposition (LL^T) of a matrix. LLT :: Decomposition -- | Robust Cholesky decomposition of a matrix with pivoting. LDLT :: Decomposition -- | Two-sided Jacobi SVD decomposition of a rectangular matrix. JacobiSVD :: Decomposition -- | solve :: (KnownNat n, KnownNat m, KnownNat n1, KnownNat m1, Elem a) => Decomposition -> Matrix n m a -> Matrix n1 m1 a -> Matrix m 1 a -- | relativeError :: (KnownNat n, KnownNat m, KnownNat n1, KnownNat m1, KnownNat n2, KnownNat m2, Elem a) => Matrix n m a -> Matrix n1 m1 a -> Matrix n2 m2 a -> a -- | The rank of the matrix. rank :: (KnownNat n, KnownNat m, Elem a) => Decomposition -> Matrix n m a -> Int -- | Return the matrix whose columns form a basis of the null-space of -- A. kernel :: forall a n m. (Elem a, KnownNat n, KnownNat m) => Decomposition -> Matrix n m a -> Matrix n m a -- | Return a matrix whose columns form a basis of the column-space of -- A. image :: forall a n m. (Elem a, KnownNat n, KnownNat m) => Decomposition -> Matrix n m a -> Matrix n m a -- | -- -- -- --
--   import Data.Eigen.LA
--   main = print $ linearRegression (Row @5)
--     [
--       [-4.32, 3.02, 6.89],
--       [-3.79, 2.01, 5.39],
--       [-4.01, 2.41, 6.01],
--       [-3.86, 2.09, 5.55],
--       [-4.10, 2.58, 6.32]
--     ]
--   
-- -- produces the following output -- --
--   Just ([-2.3466569233817127,-0.2534897541434826,-0.1749653335680988],1.8905965120153139e-3)
--   
linearRegression :: forall r. (KnownNat r) => Row r -> [[Double]] -> Maybe ([Double], Double) instance GHC.Read.Read Eigen.Solver.LA.Decomposition instance GHC.Show.Show Eigen.Solver.LA.Decomposition instance GHC.Classes.Eq Eigen.Solver.LA.Decomposition instance GHC.Enum.Enum Eigen.Solver.LA.Decomposition module Eigen.SparseMatrix.Mutable -- | Mutable sparse matrix. See SparseMatrix for details about -- matrix layout. newtype MSparseMatrix :: Nat -> Nat -> Type -> Type -> Type [MSparseMatrix] :: (ForeignPtr (CSparseMatrix a)) -> MSparseMatrix n m s a -- | A sparse matrix where the state token is specialised to -- ReadWorld. type IOSparseMatrix n m a = MSparseMatrix n m RealWorld a -- | This type does not differ from MSparseMatrix, but might be -- desirable for readability. type STSparseMatrix n m s a = MSparseMatrix n m s a -- | Create a new sparse matrix with the given size rows x cols. new :: forall m n p a. (Elem a, KnownNat n, KnownNat m, PrimMonad p) => p (MSparseMatrix n m (PrimState p) a) -- | Preallocates for non zeros. The matrix must be in compressed mode. reserve :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> Int -> p () -- | Returns the number of rows of the matrix. rows :: forall n m s a. (Elem a, KnownNat n, KnownNat m) => MSparseMatrix n m s a -> Int -- | Returns the number of columns of the matrix. cols :: forall n m s a. (Elem a, KnownNat n, KnownNat m) => MSparseMatrix n m s a -> Int -- | Returns the number of rows (resp. columns) of the matrix if the -- storage order is column majour (resp. row majour) innerSize :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p Int -- | Returns the number of columns (resp. rows) of the matrix if the -- storage order is column majour (resp. row majour) outerSize :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p Int -- | Returns the number of nonzero coefficients. nonZeros :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p Int -- | Returns whether or not the matrix is in compressed form. compressed :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p Bool -- | Turns the matrix into compressed format. compress :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p () -- | Decompresses the matrix. uncompress :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p () -- | Read the value of the matrix at position i,j. This function returns -- Scalar(0) if the element is an explicit 0. read :: forall n m r c p a. (Elem a, PrimMonad p, KnownNat n, KnownNat m, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> MSparseMatrix n m (PrimState p) a -> p a -- | Writes the value of the matrix at position i, j. -- This function turns the matrix into a non compressed form if that was -- not the case. -- -- This is a O(log(nnz_j)) operation (binary search) plus the -- cost of element insertion if the element does not already exist. -- -- Cost of element insertion is sorted insertion in O(1) if the elements -- of each inner vector are inserted in increasing inner index order, and -- in O(nnz_j) for a random insertion. write :: forall n m r c p a. (Elem a, PrimMonad p, KnownNat n, KnownNat m, KnownNat r, KnownNat c, r <= n, c <= m) => MSparseMatrix n m (PrimState p) a -> Row r -> Col c -> a -> p () -- | Remove all non zeros, but keep allocated memory. setZero :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p () -- | Sets the matrix to the identity matrix. setIdentity :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p () module Eigen.SparseMatrix -- | A versatible sparse matrix representation. SparseMatrix is the main -- sparse matrix representation of Eigen's sparse module. It offers high -- performance and low memory usage. It implements a more versatile -- variant of the widely-used Compressed Column (or Row) Storage scheme. -- It consists of four compact arrays: * values: stores the -- coefficient values of the non-zeros. * innerIndices: stores the -- row (resp. column) indices of the non-zeros. * outerStarts: -- stores for each column (resp. row) the index of the first non-zero in -- the previous two arrays. * innerNNZs: stores the number of -- non-zeros of each column (resp. row). The word inner refers to an -- inner vector that is a column for a column-major matrix, or a row for -- a row-major matrix. The word outer refers to the other direction. This -- storage scheme is better explained on an example. The following matrix -- 0 3 0 0 0 22 0 0 0 17 7 5 0 1 0 0 0 0 0 0 0 0 14 0 8 and -- one of its possible sparse, column major representation: -- values: 22 7 _ 3 5 14 _ _ 1 _ 17 8 innerIndices: 1 2 _ 0 2 4 _ _ 2 _ 1 -- 4 outerStarts: 0 3 5 8 10 12 innerNNZs: 2 2 1 1 2 Currently the -- elements of a given inner vector are guaranteed to be always sorted by -- increasing inner indices. The "_" indicates available free space to -- quickly insert new elements. Assuming no reallocation is needed, the -- insertion of a random element is therefore in O(nnz_j) where -- nnz_j is the number of nonzeros of the respective inner -- vector. On the other hand, inserting elements with increasing inner -- indices in a given inner vector is much more efficient since this only -- requires to increase the respective innerNNZs entry that is a -- O(1) operation. The case where no empty space is available is -- a special case, and is refered as the compressed mode. It corresponds -- to the widely used Compressed Column (or Row) Storage schemes (CCS or -- CRS). Any SparseMatrix can be turned to this form by calling -- the compress function. In this case, one can remark that the -- innerNNZs array is redundant with outerStarts because we -- the equality: InnerNNZs[j] = OuterStarts[j+1]-OuterStarts[j]. -- Therefore, in practice a call to compress frees this buffer. -- The results of Eigen's operations always produces compressed sparse -- matrices. On the other hand, the insertion of a new element into a -- SparseMatrix converts this later to the uncompressed mode. For -- more infomration please see Eigen documentation page. newtype SparseMatrix :: Nat -> Nat -> Type -> Type [SparseMatrix] :: ForeignPtr (CSparseMatrix a) -> SparseMatrix n m a -- | Alias for single precision sparse matrix type SparseMatrixXf n m = SparseMatrix n m Float -- | Alias for double precision sparse matrix type SparseMatrixXd n m = SparseMatrix n m Double -- | Alias for single previsiom sparse matrix of complex numbers type SparseMatrixXcf n m = SparseMatrix n m (Complex Float) -- | Alias for double prevision sparse matrix of complex numbers type SparseMatrixXcd n m = SparseMatrix n m (Complex Double) -- | Number of elements in the sparse matrix, including zeros elems :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> Int -- | Get the coefficient values of the non-zeros. values :: Elem a => SparseMatrix n m a -> Vector a -- | Get the row indices of the non-zeros. innerIndices :: Elem a => SparseMatrix n m a -> Vector Int -- | Gets for each column the index of the first non-zero in the previous -- two arrays. outerStarts :: Elem a => SparseMatrix n m a -> Vector Int -- | Gets the number of non-zeros of each column. The word inner refers to -- an inner vector that is a column for a column-major matrix, or a row -- for a row-major matrix. The word outer refers to the other direction innerNNZs :: Elem a => SparseMatrix n m a -> Maybe (Vector Int) -- | Number of colums in the sparse matrix cols :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> Col m -- | Number of rows in the sparse matrix rows :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> Row n -- | Sparse matrix coefficient at the given row and column coeff :: forall n m r c a. (Elem a, KnownNat n, KnownNat m, KnownNat r, KnownNat c, r <= n, c <= m) => Row r -> Col c -> SparseMatrix n m a -> a -- | Matrix coefficient at the given row and column (!) :: forall n m r c a. (Elem a, KnownNat n, KnownNat m, KnownNat r, KnownNat c, r <= n, c <= m) => SparseMatrix n m a -> (Row r, Col c) -> a -- | Return a single row of the sparse matrix. getRow :: forall n m r a. (Elem a, KnownNat n, KnownNat m, KnownNat r, r <= n, 1 <= n) => Row r -> SparseMatrix n m a -> SparseMatrix 1 m a -- | Return a single column of the sparse matrix. getCol :: forall n m c a. (Elem a, KnownNat n, KnownNat m, KnownNat c, c <= m, 1 <= m) => Col c -> SparseMatrix n m a -> SparseMatrix n 1 a -- | Return all rows of the sparse matrix. getRows :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> [SparseMatrix 1 m a] -- | Return all columns of a sparse matrix. getCols :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> [SparseMatrix n 1 a] -- | Returns a single column of the sparse matrix. This is unsafe because -- it allows out-of-bounds access. unsafeGetCol :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Int -> SparseMatrix n m a -> SparseMatrix n 1 a -- | Returns a single row of the sparse matrix. This is unsafe because it -- allows out-of-bounds access. unsafeGetRow :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Int -> SparseMatrix n m a -> SparseMatrix 1 m a -- | Get a sparse matrix from a list of rows. This operation is unsafe -- because we cannot unify the length of the list with the type variable -- n. unsafeFromRows :: forall n m a. (Elem a, KnownNat n, KnownNat m) => [SparseMatrix 1 m a] -> SparseMatrix n m a -- | Get a sparse matrix from a list of columns. This operation is unsafe -- because we cannot unify the length of the list with the type variable -- m. unsafeFromCols :: forall n m a. (Elem a, KnownNat n, KnownNat m) => [SparseMatrix n 1 a] -> SparseMatrix n m a -- | Construct a sparse matrix from a list of triples (row, val, col) fromList :: (Elem a, KnownNat n, KnownNat m) => [(Int, Int, a)] -> SparseMatrix n m a -- | Convert a sparse matrix to the list of triplets (row, col, val). -- Compressed elements will not be included. toList :: Elem a => SparseMatrix n m a -> [(Int, Int, a)] -- | Construct asparse matrix of the given size from the storable vector of -- triplets (row, col, val) fromVector :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Vector (CTriplet a) -> SparseMatrix n m a -- | Convert a sparse matrix to the list of triplets (row, col, val). -- Compressed elements will not be included. toVector :: Elem a => SparseMatrix n m a -> Vector (CTriplet a) fromVectorSized :: forall n m a. (Elem a, KnownNat n, KnownNat m) => Int -> Int -> Vector (CTriplet a) -> SparseMatrix n m a fromListSized :: (Elem a, KnownNat n, KnownNat m) => Int -> Int -> [(Int, Int, a)] -> SparseMatrix n m a -- | Construct a sparsematrix from a two-dimensional list of values. If the -- dimensions of the list do not match that of the list, Nothing -- is returned. Zero values will be compressed. fromDenseList :: forall n m a. (Elem a, Eq a, KnownNat n, KnownNat m) => [[a]] -> Maybe (SparseMatrix n m a) -- | Construct asparse matrix of the given size from the storable vector of -- triplets (row, col, val) fromVector :: forall n m a. (Elem a, KnownNat -- n, KnownNat m) => VS.Vector (CTriplet a) -> SparseMatrix n m a -- fromVector tris = let !c_rs = toC $! natToInt n !c_cs = toC $! -- natToInt m !len = toC $! VS.length tris in Internal.performIO $ -- VS.unsafeWith tris $ p -> alloca $ pq -> do Internal.call $ -- Internal.sparse_fromList c_rs c_cs p len pq peek pq >>= _mk -- -- Convert a sparse matrix to a (n X m) dense list of values. toDenseList :: forall n m a. (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> [[a]] -- | Construct a sparse matrix from a dense matrix. zero-elements will be -- compressed. fromMatrix :: (Elem a, KnownNat n, KnownNat m) => Matrix n m a -> SparseMatrix n m a -- | Construct a dense matrix from a sparse matrix toMatrix :: (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> Matrix n m a -- | For vectors, the l2 norm, and for matrices the Frobenius norm. In both -- cases, it consists in the square root of the sum of the square of all -- the matrix entries. For vectors, this is also equals to the square -- root of the dot product of this with itself. norm :: Elem a => SparseMatrix n m a -> a -- | For vectors, the squared l2 norm, and for matrices the Frobenius norm. -- In both cases, it consists in the sum of the square of all the matrix -- entries. For vectors, this is also equals to the dot product of this -- with itself. squaredNorm :: Elem a => SparseMatrix n m a -> a -- | The l2 norm of the matrix using the Blue's algorithm. A Portable -- Fortran Program to Find the Euclidean Norm of a Vector, ACM TOMS, Vol -- 4, Issue 1, 1978. blueNorm :: Elem a => SparseMatrix n m a -> a -- | Extract a rectangular block from the sparse matrix, given a startRow, -- startCol, blockRows, blockCols block :: forall sr sc br bc n m a. (Elem a, KnownNat sr, KnownNat sc, KnownNat br, KnownNat bc, KnownNat n, KnownNat m) => (sr <= n, sc <= m, br <= n, bc <= m) => Row sr -> Col sc -> Row br -> Col bc -> SparseMatrix n m a -> SparseMatrix br bc a unsafeBlock :: (Elem a) => Int -> Int -> Int -> Int -> SparseMatrix n m a -> SparseMatrix n1 m1 a -- | Number of non-zeros elements in the sparse matrix nonZeros :: Elem a => SparseMatrix n m a -> Int -- | Minor dimension with respect to the storage order innerSize :: Elem a => SparseMatrix n m a -> Int -- | Major dimension with respect to the storage order outerSize :: Elem a => SparseMatrix n m a -> Int -- | Add two sparse matrices by adding the corresponding entries together. add :: Elem a => SparseMatrix n m a -> SparseMatrix n m a -> SparseMatrix n m a -- | Subtract two sparse matrices by subtracting the corresponding entries -- together. sub :: Elem a => SparseMatrix n m a -> SparseMatrix n m a -> SparseMatrix n m a -- | Matrix multiplication. mul :: Elem a => SparseMatrix p q a -> SparseMatrix q r a -> SparseMatrix p r a -- | Suppresses all nonzeros which are much smaller than the reference -- under the tolerance epsilon pruned :: Elem a => a -> SparseMatrix n m a -> SparseMatrix n m a -- | Multiply matrix on a given scalar scale :: Elem a => a -> SparseMatrix n m a -> SparseMatrix n m a -- | Transpose of the sparse matrix transpose :: Elem a => SparseMatrix n m a -> SparseMatrix m n a -- | Adjoint of the sparse matrix adjoint :: Elem a => SparseMatrix n m a -> SparseMatrix m n a -- | Map a function over the SparseMatrix. map :: (Elem a, Elem b, KnownNat n, KnownNat m) => (a -> b) -> SparseMatrix n m a -> SparseMatrix n m b -- | Map an indexed function over the SparseMatrix. imap :: (Elem a, Elem b, KnownNat n, KnownNat m) => (Int -> Int -> a -> b) -> SparseMatrix n m a -> SparseMatrix n m b -- | The matrix in the compressed format compress :: Elem a => SparseMatrix n m a -> SparseMatrix n m a -- | The matrix in the uncompressed format uncompress :: Elem a => SparseMatrix n m a -> SparseMatrix n m a -- | Is the matrix compressed? compressed :: Elem a => SparseMatrix n m a -> Bool -- | Encode the sparse matrix as a lazy bytestring encode :: (Elem a, KnownNat n, KnownNat m) => SparseMatrix n m a -> ByteString -- | Decode the sparse matrix from a lazy bytestring decode :: (Elem a, KnownNat n, KnownNat m) => ByteString -> SparseMatrix n m a -- | Yield a mutable copy of the immutable matrix. thaw :: (Elem a, PrimMonad p) => SparseMatrix n m a -> p (MSparseMatrix n m (PrimState p) a) -- | Yield an immutable copy of the mutable matrix freeze :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p (SparseMatrix n m a) -- | Unsafely convert an immutable matrix to a mutable one without copying. -- The immutable matrix may not be used after this operation. unsafeThaw :: (Elem a, PrimMonad p) => SparseMatrix n m a -> p (MSparseMatrix n m (PrimState p) a) -- | Unsafely convert a mutable matrix to an immutable one without copying. -- The mutable matrix may not be used after this operation. unsafeFreeze :: (Elem a, PrimMonad p) => MSparseMatrix n m (PrimState p) a -> p (SparseMatrix n m a) instance (Eigen.Internal.Elem a, GHC.Show.Show a, GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m) => GHC.Show.Show (Eigen.SparseMatrix.SparseMatrix n m a) instance (Eigen.Internal.Elem a, GHC.TypeNats.KnownNat n, GHC.TypeNats.KnownNat m) => Data.Binary.Class.Binary (Eigen.SparseMatrix.SparseMatrix n m a) -- | This documentation is based on original Eigen page Solving Sparse -- Linear Systems -- -- Eigen currently provides a limited set of built-in MPL2 compatible -- solvers. They are summarized in the following table: -- --
--   Sparse solver       Solver kind             Matrix kind         Notes
--   
--   ConjugateGradient   Classic iterative CG    SPD                 Recommended for large symmetric
--                                                                   problems (e.g., 3D Poisson eq.)
--   BiCGSTAB            Iterative stabilized    Square
--                       bi-conjugate gradient
--   SparseLU            LU factorization        Square              Optimized for small and large problems
--                                                                   with irregular patterns
--   SparseQR            QR factorization        Any, rectangular    Recommended for least-square problems,
--                                                                   has a basic rank-revealing feature
--   
-- -- All these solvers follow the same general concept. Here is a typical -- and general example: -- --
--   let
--       a :: SparseMatrixXd
--       a = ... -- fill a
--   
--       b :: SparseMatrixXd
--       b = ... -- fill b
--   
--       validate msg = info >>= (when fail msg) . (/= Success)
--   
--   // solve Ax = b
--   runSolverT solver $ do
--       compute a
--       validate "decomposition failed"
--   
--       x <- solve b
--       validate "solving failed"
--   
--       // solve for another right hand side
--       x1 <- solve b1
--   
-- -- In the case where multiple problems with the same sparsity pattern -- have to be solved, then the "compute" step can be decomposed as -- follow: -- --
--   runSolverT solver $ do
--       analyzePattern a1
--       factorize a1
--       x1 <- solve b1
--       x2 <- solve b2
--   
--       factorize a2
--       x1 <- solve b1
--       x2 <- solve b2
--   
-- -- Finally, each solver provides some specific features, such as -- determinant, access to the factors, controls of the iterations, and so -- on. module Eigen.Solver.SparseLA class Code s => Solver s -- | For direct methods, the solution is computed at the machine precision. class Solver s => DirectSolver s -- | Sometimes, the solution need not be too accurate. In this case, the -- iterative methods are more suitable and the desired accuracy can be -- set before the solve step using setTolerance. class Solver s => IterativeSolver s -- | Ordering methods for sparse matrices. They are typically used to -- reduce the number of elements during the sparse matrix decomposition -- (LLT, LU, QR). Precisely, in a -- preprocessing step, a permutation matrix P is computed using -- those ordering methods and applied to the columns of the matrix. Using -- for instance the sparse Cholesky decomposition, it is expected that -- the nonzeros elements in LLT(A*P) will be much smaller than -- that in LLT(A). data OrderingMethod -- | The column approximate minimum degree ordering The matrix should be in -- column-major and compressed format COLAMDOrdering :: OrderingMethod -- | The natural ordering (identity) NaturalOrdering :: OrderingMethod data Preconditioner -- | A preconditioner based on the digonal entries -- -- It allows to approximately solve for A.x = b problems assuming A is a -- diagonal matrix. In other words, this preconditioner neglects all off -- diagonal entries and, in Eigen's language, solves for: -- A.diagonal().asDiagonal() . x = b This preconditioner is -- suitable for both selfadjoint and general problems. The diagonal -- entries are pre-inverted and stored into a dense vector. -- -- A variant that has yet to be implemented would attempt to preserve the -- norm of each column. DiagonalPreconditioner :: Preconditioner -- | A naive preconditioner which approximates any matrix as the identity -- matrix IdentityPreconditioner :: Preconditioner -- | A conjugate gradient solver for sparse self-adjoint problems. -- -- This class allows to solve for A.x = b sparse linear problems -- using a conjugate gradient algorithm. The sparse matrix A -- must be selfadjoint. -- -- The maximal number of iterations and tolerance value can be controlled -- via the setMaxIterations and setTolerance methods. The -- defaults are the size of the problem for the maximal number of -- iterations and epsilon for the tolerance newtype ConjugateGradient ConjugateGradient :: Preconditioner -> ConjugateGradient -- | A bi conjugate gradient stabilized solver for sparse square problems. -- -- This class allows to solve for A.x = b sparse linear problems -- using a bi conjugate gradient stabilized algorithm. The vectors -- x and b can be either dense or sparse. -- -- The maximal number of iterations and tolerance value can be controlled -- via the setMaxIterations and setTolerance methods. The -- defaults are the size of the problem for the maximal number of -- iterations and epsilon for the tolerance newtype BiCGSTAB BiCGSTAB :: Preconditioner -> BiCGSTAB -- | Sparse supernodal LU factorization for general matrices. -- -- This class implements the supernodal LU factorization for general -- matrices. It uses the main techniques from the sequential SuperLU -- package. It handles transparently real and complex arithmetics -- with single and double precision, depending on the scalar type of your -- input matrix. The code has been optimized to provide BLAS-3 operations -- during supernode-panel updates. It benefits directly from the built-in -- high-performant Eigen BLAS routines. Moreover, when the size of a -- supernode is very small, the BLAS calls are avoided to enable a better -- optimization from the compiler. For best performance, you should -- compile it with NDEBUG flag to avoid the numerous bounds checking on -- vectors. -- -- An important parameter of this class is the ordering method. It is -- used to reorder the columns (and eventually the rows) of the matrix to -- reduce the number of new elements that are created during numerical -- factorization. The cheapest method available is COLAMD. See -- OrderingMethods module for the list of built-in and external -- ordering methods. newtype SparseLU SparseLU :: OrderingMethod -> SparseLU -- | Sparse left-looking rank-revealing QR factorization. -- -- This class implements a left-looking rank-revealing QR decomposition -- of sparse matrices. When a column has a norm less than a given -- tolerance it is implicitly permuted to the end. The QR factorization -- thus obtained is given by A*P = Q*R where R is upper -- triangular or trapezoidal. -- -- P is the column permutation which is the product of the -- fill-reducing and the rank-revealing permutations. -- -- Q is the orthogonal matrix represented as products of -- Householder reflectors. -- -- R is the sparse triangular or trapezoidal matrix. The later -- occurs when A is rank-deficient. newtype SparseQR SparseQR :: OrderingMethod -> SparseQR data ComputationInfo -- | Computation was successful. Success :: ComputationInfo -- | The provided data did not satisfy the prerequisites. NumericalIssue :: ComputationInfo -- | Iterative procedure did not converge. NoConvergence :: ComputationInfo -- | The inputs are invalid, or the algorithm has been improperly called. -- When assertions are enabled, such errors trigger an error. InvalidInput :: ComputationInfo newtype SolverT s a p c SolverT :: (ReaderT (s, ForeignPtr (CSolver a)) p c) -> SolverT s a p c runSolverT :: (Solver s, MonadIO p, Elem a) => s -> SolverT s a p c -> p c -- | Initializes the iterative solver for the sparsity pattern of the -- matrix A for further solving Ax=b problems. analyzePattern :: (Solver s, MonadIO p, Elem a) => SparseMatrix n m a -> SolverT s a p () -- | Initializes the iterative solver with the numerical values of the -- matrix A for further solving Ax=b problems. factorize :: (Solver s, MonadIO p, Elem a) => SparseMatrix n m a -> SolverT s a p () -- | Initializes the iterative solver with the matrix A for -- further solving Ax=b problems. -- -- The compute method is equivalent to calling both -- analyzePattern and factorize. compute :: (Solver s, MonadIO p, Elem a) => SparseMatrix n m a -> SolverT s a p () -- | An expression of the solution x of Ax=b using the -- current decomposition of A. solve :: (Solver s, MonadIO p, Elem a) => SparseMatrix n m a -> SolverT s a p (SparseMatrix n m a) -- | The solution x of Ax=b using the current -- decomposition of A and x0 as an initial solution. -- solveWithGuess :: (Solver s, MonadIO p, I.Elem a) => -- SM.SparseMatrix n m a -> SM.SparseMatrix n m a -> SolverT s a p -- (SM.SparseMatrix n m a) solveWithGuess (SM.SparseMatrix fb) -- (SM.SparseMatrix fx0) = SolverT $ ask >>= (i,fs) -> liftIO $ -- withForeignPtr fs $ s -> withForeignPtr fb $ b -> withForeignPtr -- fx0 $ x0 -> alloca $ px -> do I.call $ -- I.sparse_la_solveWithGuess i s b x0 px x <- peek px SM.SparseMatrix -- $ FC.newForeignPtr x (I.call $ I.sparse_free x) -- -- info :: (Solver s, MonadIO p, Elem a) => SolverT s a p ComputationInfo -- | The tolerance threshold used by the stopping criteria. tolerance :: (IterativeSolver s, MonadIO p, Elem a) => SolverT s a p Double -- | Sets the tolerance threshold used by the stopping criteria. -- -- This value is used as an upper bound to the relative residual error: -- |Ax-b|/|b|. The default value is the machine precision given -- by epsilon setTolerance :: (IterativeSolver s, MonadIO p, Elem a) => Double -> SolverT s a p () -- | The max number of iterations. It is either the value setted by -- setMaxIterations or, by default, twice the number of columns of the -- matrix. maxIterations :: (IterativeSolver s, MonadIO p, Elem a) => SolverT s a p Int -- | Sets the max number of iterations. Default is twice the number of -- columns of the matrix. setMaxIterations :: (IterativeSolver s, MonadIO p, Elem a) => Int -> SolverT s a p () -- | The tolerance error reached during the last solve. It is a close -- approximation of the true relative residual error |Ax-b|/|b|. error :: (IterativeSolver s, MonadIO p, Elem a) => SolverT s a p Double -- | The number of iterations performed during the last solve iterations :: (IterativeSolver s, MonadIO p, Elem a) => SolverT s a p Int -- | Returns the b sparse upper triangular matrix R of -- the QR factorization. matrixR :: (MonadIO p, Elem a) => SolverT SparseQR a p (SparseMatrix n m a) -- | Returns the matrix Q as products of sparse Householder -- reflectors. matrixQ :: (MonadIO p, Elem a) => SolverT SparseQR a p (SparseMatrix n m a) -- | Returns the number of non linearly dependent columns as determined by -- the pivoting threshold. rank :: (MonadIO p, Elem a) => SolverT SparseQR a p Int -- | Sets the threshold that is used to determine linearly dependent -- columns during the factorization. -- -- In practice, if during the factorization the norm of the column that -- has to be eliminated is below this threshold, then the entire column -- is treated as zero, and it is moved at the end. setPivotThreshold :: (MonadIO p, Elem a) => Double -> SolverT SparseQR a p () -- | Indicate that the pattern of the input matrix is symmetric setSymmetric :: (MonadIO p, Elem a) => Bool -> SolverT SparseLU a p () -- | Returns the matrix L matrixL :: (MonadIO p, Elem a) => SolverT SparseLU a p (SparseMatrix n m a) -- | Returns the matrix U matrixU :: (MonadIO p, Elem a) => SolverT SparseLU a p (SparseMatrix n m a) -- | The determinant of the matrix. determinant :: (MonadIO p, Elem a) => SolverT SparseLU a p a -- | The absolute value of the determinant of the matrix of which *this is -- the QR decomposition. -- -- A determinant can be very big or small, so for matrices of large -- enough dimension, there is a risk of overflow/underflow. One way to -- work around that is to use logAbsDeterminant instead. absDeterminant :: (MonadIO p, Elem a) => SolverT SparseLU a p a -- | A number representing the sign of the determinant signDeterminant :: (MonadIO p, Elem a) => SolverT SparseLU a p a -- | The natural log of the absolute value of the determinant of the matrix -- of which this is the QR decomposition -- -- This method is useful to work around the risk of overflow/underflow -- that's inherent to the determinant computation. logAbsDeterminant :: (MonadIO p, Elem a) => SolverT SparseLU a p a instance Control.Monad.Trans.Class.MonadTrans (Eigen.Solver.SparseLA.SolverT s a) instance GHC.Base.Monad p => GHC.Base.Monad (Eigen.Solver.SparseLA.SolverT s a p) instance GHC.Base.Applicative p => GHC.Base.Applicative (Eigen.Solver.SparseLA.SolverT s a p) instance GHC.Base.Functor p => GHC.Base.Functor (Eigen.Solver.SparseLA.SolverT s a p) instance GHC.Read.Read Eigen.Solver.SparseLA.ComputationInfo instance GHC.Show.Show Eigen.Solver.SparseLA.ComputationInfo instance GHC.Enum.Enum Eigen.Solver.SparseLA.ComputationInfo instance GHC.Classes.Eq Eigen.Solver.SparseLA.ComputationInfo instance GHC.Read.Read Eigen.Solver.SparseLA.SparseQR instance GHC.Show.Show Eigen.Solver.SparseLA.SparseQR instance GHC.Read.Read Eigen.Solver.SparseLA.SparseLU instance GHC.Show.Show Eigen.Solver.SparseLA.SparseLU instance GHC.Read.Read Eigen.Solver.SparseLA.BiCGSTAB instance GHC.Show.Show Eigen.Solver.SparseLA.BiCGSTAB instance GHC.Read.Read Eigen.Solver.SparseLA.ConjugateGradient instance GHC.Show.Show Eigen.Solver.SparseLA.ConjugateGradient instance GHC.Read.Read Eigen.Solver.SparseLA.Preconditioner instance GHC.Show.Show Eigen.Solver.SparseLA.Preconditioner instance GHC.Read.Read Eigen.Solver.SparseLA.OrderingMethod instance GHC.Show.Show Eigen.Solver.SparseLA.OrderingMethod instance Eigen.Solver.SparseLA.Solver Eigen.Solver.SparseLA.SparseQR instance Eigen.Solver.SparseLA.DirectSolver Eigen.Solver.SparseLA.SparseQR instance Eigen.Internal.Code Eigen.Solver.SparseLA.SparseQR instance Eigen.Solver.SparseLA.Solver Eigen.Solver.SparseLA.SparseLU instance Eigen.Solver.SparseLA.DirectSolver Eigen.Solver.SparseLA.SparseLU instance Eigen.Internal.Code Eigen.Solver.SparseLA.SparseLU instance Eigen.Solver.SparseLA.Solver Eigen.Solver.SparseLA.BiCGSTAB instance Eigen.Solver.SparseLA.IterativeSolver Eigen.Solver.SparseLA.BiCGSTAB instance Eigen.Internal.Code Eigen.Solver.SparseLA.BiCGSTAB instance Eigen.Solver.SparseLA.Solver Eigen.Solver.SparseLA.ConjugateGradient instance Eigen.Solver.SparseLA.IterativeSolver Eigen.Solver.SparseLA.ConjugateGradient instance Eigen.Internal.Code Eigen.Solver.SparseLA.ConjugateGradient