-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Linear algebra and numerical computations -- -- This library provides a purely functional interface to basic linear -- algebra and other numerical computations, internally implemented using -- GSL, BLAS and LAPACK. @package hmatrix @version 0.5.2.2 -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_elljac.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Elljac elljac_e :: Double -> Double -> (Double, Double, Double) -- | Low level interface to vector operations. module Numeric.GSL.Vector data FunCodeS Norm2 :: FunCodeS AbsSum :: FunCodeS MaxIdx :: FunCodeS Max :: FunCodeS MinIdx :: FunCodeS Min :: FunCodeS -- | obtains different functions of a vector: norm1, norm2, max, min, -- posmax, posmin, etc. toScalarR :: FunCodeS -> Vector Double -> Double data FunCodeV Sin :: FunCodeV Cos :: FunCodeV Tan :: FunCodeV Abs :: FunCodeV ASin :: FunCodeV ACos :: FunCodeV ATan :: FunCodeV Sinh :: FunCodeV Cosh :: FunCodeV Tanh :: FunCodeV ASinh :: FunCodeV ACosh :: FunCodeV ATanh :: FunCodeV Exp :: FunCodeV Log :: FunCodeV Sign :: FunCodeV Sqrt :: FunCodeV -- | map of real vectors with given function vectorMapR :: FunCodeV -> Vector Double -> Vector Double -- | map of complex vectors with given function vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) data FunCodeSV Scale :: FunCodeSV Recip :: FunCodeSV AddConstant :: FunCodeSV Negate :: FunCodeSV PowSV :: FunCodeSV PowVS :: FunCodeSV -- | map of real vectors with given function vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double -- | map of complex vectors with given function vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) data FunCodeVV Add :: FunCodeVV Sub :: FunCodeVV Mul :: FunCodeVV Div :: FunCodeVV Pow :: FunCodeVV ATan2 :: FunCodeVV -- | elementwise operation on real vectors vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double -- | elementwise operation on complex vectors vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) instance Enum FunCodeS instance Enum FunCodeVV instance Enum FunCodeSV instance Enum FunCodeV -- | In-place manipulation inside the ST monad. See examples/inplace.hs in -- the distribution. module Data.Packed.ST data STVector s t newVector :: (Element t) => t -> Int -> ST s (STVector s t) thawVector :: (Storable t) => Vector t -> ST s (STVector s t) freezeVector :: (Storable t) => STVector s1 t -> ST s2 (Vector t) runSTVector :: (Storable t) => (forall s. ST s (STVector s t)) -> Vector t readVector :: (Storable t) => STVector s t -> Int -> ST s t writeVector :: (Storable t) => STVector s t -> Int -> t -> ST s () modifyVector :: (Storable t) => STVector s t -> Int -> (t -> t) -> ST s () liftSTVector :: (Storable t) => (Vector t -> a) -> STVector s1 t -> ST s2 a data STMatrix s t newMatrix :: (Element t) => t -> Int -> Int -> ST s (STMatrix s t) thawMatrix :: (Storable t) => Matrix t -> ST s (STMatrix s t) freezeMatrix :: (Storable t) => STMatrix s1 t -> ST s2 (Matrix t) runSTMatrix :: (Storable t) => (forall s. ST s (STMatrix s t)) -> Matrix t readMatrix :: (Storable t) => STMatrix s t -> Int -> Int -> ST s t writeMatrix :: (Storable t) => STMatrix s t -> Int -> Int -> t -> ST s () modifyMatrix :: (Storable t) => STMatrix s t -> Int -> Int -> (t -> t) -> ST s () liftSTMatrix :: (Storable t) => (Matrix t -> a) -> STMatrix s1 t -> ST s2 a newUndefinedVector :: (Element t) => Int -> ST s (STVector s t) unsafeReadVector :: (Storable t) => STVector s t -> Int -> ST s t unsafeWriteVector :: (Storable t) => STVector s t -> Int -> t -> ST s () unsafeThawVector :: (Storable t) => Vector t -> ST s (STVector s t) unsafeFreezeVector :: (Storable t) => STVector s1 t -> ST s2 (Vector t) newUndefinedMatrix :: (Element t) => MatrixOrder -> Int -> Int -> ST s (STMatrix s t) unsafeReadMatrix :: (Storable t) => STMatrix s t -> Int -> Int -> ST s t unsafeWriteMatrix :: (Storable t) => STMatrix s t -> Int -> Int -> t -> ST s () unsafeThawMatrix :: (Storable t) => Matrix t -> ST s (STMatrix s t) unsafeFreezeMatrix :: (Storable t) => STMatrix s1 t -> ST s2 (Matrix t) -- | Numerical differentiation. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Numerical-Differentiation.html#Numerical-Differentiation -- -- From the GSL manual: "The functions described in this chapter compute -- numerical derivatives by finite differencing. An adaptive algorithm is -- used to find the best choice of finite difference and to estimate the -- error in the derivative." module Numeric.GSL.Differentiation -- | Adaptive central difference algorithm, gsl_deriv_central. For -- example: -- --
--    > let deriv = derivCentral 0.01 
--    > deriv sin (pi/4)
--   (0.7071067812000676,1.0600063101654055e-10)
--    > cos (pi/4)
--   0.7071067811865476 
--   
derivCentral :: Double -> (Double -> Double) -> Double -> (Double, Double) -- | Adaptive forward difference algorithm, gsl_deriv_forward. The -- function is evaluated only at points greater than x, and never at x -- itself. The derivative is returned in result and an estimate of its -- absolute error is returned in abserr. This function should be used if -- f(x) has a discontinuity at x, or is undefined for values less than x. -- A backward derivative can be obtained using a negative step. derivForward :: Double -> (Double -> Double) -> Double -> (Double, Double) -- | Adaptive backward difference algorithm, gsl_deriv_backward. derivBackward :: Double -> (Double -> Double) -> Double -> (Double, Double) -- | Numerical integration routines. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Numerical-Integration.html#Numerical-Integration module Numeric.GSL.Integration -- | Numerical integration using gsl_integration_qng (useful for -- fast integration of smooth functions). For example: -- --
--   > let quad = integrateQNG 1E-6 
--   > quad (\x -> 4/(1+x*x)) 0 1 
--   (3.141592653589793,3.487868498008632e-14)
--   
integrateQNG :: Double -> (Double -> Double) -> Double -> Double -> (Double, Double) -- | Numerical integration using gsl_integration_qags (adaptive -- integration with singularities). For example: -- --
--   > let quad = integrateQAGS 1E-9 1000 
--   > let f a x = x**(-0.5) * log (a*x)
--   > quad (f 1) 0 1
--   (-3.999999999999974,4.871658632055187e-13)
--   
integrateQAGS :: Double -> Int -> (Double -> Double) -> Double -> Double -> (Double, Double) -- | Fourier Transform. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Fast-Fourier-Transforms.html#Fast-Fourier-Transforms module Numeric.GSL.Fourier -- | Fast 1D Fourier transform of a Vector (Complex -- Double) using gsl_fft_complex_forward. It uses -- the same scaling conventions as GNU Octave. -- --
--   > fft (fromList [1,2,3,4])
--   vector (4) [10.0 :+ 0.0,(-2.0) :+ 2.0,(-2.0) :+ 0.0,(-2.0) :+ (-2.0)]
--   
fft :: Vector (Complex Double) -> Vector (Complex Double) -- | The inverse of fft, using gsl_fft_complex_inverse. ifft :: Vector (Complex Double) -> Vector (Complex Double) -- | Polynomials. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/General-Polynomial-Equations.html#General-Polynomial-Equations module Numeric.GSL.Polynomials -- | Solution of general polynomial equations, using -- gsl_poly_complex_solve. For example, the three solutions of x^3 -- + 8 = 0 -- --
--   > polySolve [8,0,0,1]
--   [(-1.9999999999999998) :+ 0.0,
--    1.0 :+ 1.732050807568877,
--    1.0 :+ (-1.732050807568877)]
--   
-- -- The example in the GSL manual: To find the roots of x^5 -1 = 0: -- --
--   > polySolve [-1, 0, 0, 0, 0, 1]
--   [(-0.8090169943749475) :+ 0.5877852522924731,
--   (-0.8090169943749475) :+ (-0.5877852522924731),
--   0.30901699437494734 :+ 0.9510565162951536,
--   0.30901699437494734 :+ (-0.9510565162951536),
--   1.0 :+ 0.0]
--   
polySolve :: [Double] -> [Complex Double] -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_airy.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Airy airy_Ai_e :: Double -> Precision -> (Double, Double) airy_Ai :: Double -> Precision -> Double airy_Bi_e :: Double -> Precision -> (Double, Double) airy_Bi :: Double -> Precision -> Double airy_Ai_scaled_e :: Double -> Precision -> (Double, Double) airy_Ai_scaled :: Double -> Precision -> Double airy_Bi_scaled_e :: Double -> Precision -> (Double, Double) airy_Bi_scaled :: Double -> Precision -> Double airy_Ai_deriv_e :: Double -> Precision -> (Double, Double) airy_Ai_deriv :: Double -> Precision -> Double airy_Bi_deriv_e :: Double -> Precision -> (Double, Double) airy_Bi_deriv :: Double -> Precision -> Double airy_Ai_deriv_scaled_e :: Double -> Precision -> (Double, Double) airy_Ai_deriv_scaled :: Double -> Precision -> Double airy_Bi_deriv_scaled_e :: Double -> Precision -> (Double, Double) airy_Bi_deriv_scaled :: Double -> Precision -> Double airy_zero_Ai_e :: CInt -> (Double, Double) airy_zero_Ai :: CInt -> Double airy_zero_Bi_e :: CInt -> (Double, Double) airy_zero_Bi :: CInt -> Double airy_zero_Ai_deriv_e :: CInt -> (Double, Double) airy_zero_Ai_deriv :: CInt -> Double airy_zero_Bi_deriv_e :: CInt -> (Double, Double) airy_zero_Bi_deriv :: CInt -> Double data Precision PrecDouble :: Precision PrecSingle :: Precision PrecApprox :: Precision -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_bessel.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Bessel bessel_J0_e :: Double -> (Double, Double) bessel_J0 :: Double -> Double bessel_J1_e :: Double -> (Double, Double) bessel_J1 :: Double -> Double bessel_Jn_e :: CInt -> Double -> (Double, Double) bessel_Jn :: CInt -> Double -> Double bessel_Y0_e :: Double -> (Double, Double) bessel_Y0 :: Double -> Double bessel_Y1_e :: Double -> (Double, Double) bessel_Y1 :: Double -> Double bessel_Yn_e :: CInt -> Double -> (Double, Double) bessel_Yn :: CInt -> Double -> Double bessel_I0_e :: Double -> (Double, Double) bessel_I0 :: Double -> Double bessel_I1_e :: Double -> (Double, Double) bessel_I1 :: Double -> Double bessel_In_e :: CInt -> Double -> (Double, Double) bessel_In :: CInt -> Double -> Double bessel_I0_scaled_e :: Double -> (Double, Double) bessel_I0_scaled :: Double -> Double bessel_I1_scaled_e :: Double -> (Double, Double) bessel_I1_scaled :: Double -> Double bessel_In_scaled_e :: CInt -> Double -> (Double, Double) bessel_In_scaled :: CInt -> Double -> Double bessel_K0_e :: Double -> (Double, Double) bessel_K0 :: Double -> Double bessel_K1_e :: Double -> (Double, Double) bessel_K1 :: Double -> Double bessel_Kn_e :: CInt -> Double -> (Double, Double) bessel_Kn :: CInt -> Double -> Double bessel_K0_scaled_e :: Double -> (Double, Double) bessel_K0_scaled :: Double -> Double bessel_K1_scaled_e :: Double -> (Double, Double) bessel_K1_scaled :: Double -> Double bessel_Kn_scaled_e :: CInt -> Double -> (Double, Double) bessel_Kn_scaled :: CInt -> Double -> Double bessel_j0_e :: Double -> (Double, Double) bessel_j0 :: Double -> Double bessel_j1_e :: Double -> (Double, Double) bessel_j1 :: Double -> Double bessel_j2_e :: Double -> (Double, Double) bessel_j2 :: Double -> Double bessel_jl_e :: CInt -> Double -> (Double, Double) bessel_jl :: CInt -> Double -> Double bessel_y0_e :: Double -> (Double, Double) bessel_y0 :: Double -> Double bessel_y1_e :: Double -> (Double, Double) bessel_y1 :: Double -> Double bessel_y2_e :: Double -> (Double, Double) bessel_y2 :: Double -> Double bessel_yl_e :: CInt -> Double -> (Double, Double) bessel_yl :: CInt -> Double -> Double bessel_i0_scaled_e :: Double -> (Double, Double) bessel_i0_scaled :: Double -> Double bessel_i1_scaled_e :: Double -> (Double, Double) bessel_i1_scaled :: Double -> Double bessel_i2_scaled_e :: Double -> (Double, Double) bessel_i2_scaled :: Double -> Double bessel_il_scaled_e :: CInt -> Double -> (Double, Double) bessel_il_scaled :: CInt -> Double -> Double bessel_k0_scaled_e :: Double -> (Double, Double) bessel_k0_scaled :: Double -> Double bessel_k1_scaled_e :: Double -> (Double, Double) bessel_k1_scaled :: Double -> Double bessel_k2_scaled_e :: Double -> (Double, Double) bessel_k2_scaled :: Double -> Double bessel_kl_scaled_e :: CInt -> Double -> (Double, Double) bessel_kl_scaled :: CInt -> Double -> Double bessel_Jnu_e :: Double -> Double -> (Double, Double) bessel_Jnu :: Double -> Double -> Double bessel_Ynu_e :: Double -> Double -> (Double, Double) bessel_Ynu :: Double -> Double -> Double bessel_Inu_scaled_e :: Double -> Double -> (Double, Double) bessel_Inu_scaled :: Double -> Double -> Double bessel_Inu_e :: Double -> Double -> (Double, Double) bessel_Inu :: Double -> Double -> Double bessel_Knu_scaled_e :: Double -> Double -> (Double, Double) bessel_Knu_scaled :: Double -> Double -> Double bessel_Knu_e :: Double -> Double -> (Double, Double) bessel_Knu :: Double -> Double -> Double bessel_lnKnu_e :: Double -> Double -> (Double, Double) bessel_lnKnu :: Double -> Double -> Double bessel_zero_J0_e :: CInt -> (Double, Double) bessel_zero_J0 :: CInt -> Double bessel_zero_J1_e :: CInt -> (Double, Double) bessel_zero_J1 :: CInt -> Double bessel_zero_Jnu_e :: Double -> CInt -> (Double, Double) bessel_zero_Jnu :: Double -> CInt -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_clausen.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Clausen clausen_e :: Double -> (Double, Double) clausen :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_coulomb.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Coulomb hydrogenicR_1_e :: Double -> Double -> (Double, Double) hydrogenicR_1 :: Double -> Double -> Double hydrogenicR_e :: CInt -> CInt -> Double -> Double -> (Double, Double) hydrogenicR :: CInt -> CInt -> Double -> Double -> Double coulomb_CL_e :: Double -> Double -> (Double, Double) -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_coupling.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Coupling coupling_3j_e :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> (Double, Double) coupling_3j :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> Double coupling_6j_e :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> (Double, Double) coupling_6j :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> Double coupling_RacahW_e :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> (Double, Double) coupling_RacahW :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> Double coupling_9j_e :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> (Double, Double) coupling_9j :: CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> CInt -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_dawson.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Dawson dawson_e :: Double -> (Double, Double) dawson :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_debye.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Debye debye_1_e :: Double -> (Double, Double) debye_1 :: Double -> Double debye_2_e :: Double -> (Double, Double) debye_2 :: Double -> Double debye_3_e :: Double -> (Double, Double) debye_3 :: Double -> Double debye_4_e :: Double -> (Double, Double) debye_4 :: Double -> Double debye_5_e :: Double -> (Double, Double) debye_5 :: Double -> Double debye_6_e :: Double -> (Double, Double) debye_6 :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_dilog.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Dilog dilog_e :: Double -> (Double, Double) dilog :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_elementary.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Elementary multiply_e :: Double -> Double -> (Double, Double) multiply :: Double -> Double -> Double multiply_err_e :: Double -> Double -> Double -> Double -> (Double, Double) -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_ellint.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Ellint ellint_Kcomp_e :: Double -> Precision -> (Double, Double) ellint_Kcomp :: Double -> Precision -> Double ellint_Ecomp_e :: Double -> Precision -> (Double, Double) ellint_Ecomp :: Double -> Precision -> Double ellint_Pcomp_e :: Double -> Double -> Precision -> (Double, Double) ellint_Pcomp :: Double -> Double -> Precision -> Double ellint_Dcomp_e :: Double -> Precision -> (Double, Double) ellint_Dcomp :: Double -> Precision -> Double ellint_F_e :: Double -> Double -> Precision -> (Double, Double) ellint_F :: Double -> Double -> Precision -> Double ellint_E_e :: Double -> Double -> Precision -> (Double, Double) ellint_E :: Double -> Double -> Precision -> Double ellint_P_e :: Double -> Double -> Double -> Precision -> (Double, Double) ellint_P :: Double -> Double -> Double -> Precision -> Double ellint_D_e :: Double -> Double -> Double -> Precision -> (Double, Double) ellint_D :: Double -> Double -> Double -> Precision -> Double ellint_RC_e :: Double -> Double -> Precision -> (Double, Double) ellint_RC :: Double -> Double -> Precision -> Double ellint_RD_e :: Double -> Double -> Double -> Precision -> (Double, Double) ellint_RD :: Double -> Double -> Double -> Precision -> Double ellint_RF_e :: Double -> Double -> Double -> Precision -> (Double, Double) ellint_RF :: Double -> Double -> Double -> Precision -> Double ellint_RJ_e :: Double -> Double -> Double -> Double -> Precision -> (Double, Double) ellint_RJ :: Double -> Double -> Double -> Double -> Precision -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_erf.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Erf erfc_e :: Double -> (Double, Double) erfc :: Double -> Double log_erfc_e :: Double -> (Double, Double) log_erfc :: Double -> Double erf_e :: Double -> (Double, Double) erf :: Double -> Double erf_Z_e :: Double -> (Double, Double) erf_Q_e :: Double -> (Double, Double) erf_Z :: Double -> Double erf_Q :: Double -> Double hazard_e :: Double -> (Double, Double) hazard :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_exp.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Exp exp_e :: Double -> (Double, Double) exp :: Double -> Double exp_e10_e :: Double -> (Double, Int, Double) exp_mult_e :: Double -> Double -> (Double, Double) exp_mult :: Double -> Double -> Double exp_mult_e10_e :: Double -> Double -> (Double, Int, Double) expm1_e :: Double -> (Double, Double) expm1 :: Double -> Double exprel_e :: Double -> (Double, Double) exprel :: Double -> Double exprel_2_e :: Double -> (Double, Double) exprel_2 :: Double -> Double exprel_n_e :: CInt -> Double -> (Double, Double) exprel_n :: CInt -> Double -> Double exp_err_e :: Double -> Double -> (Double, Double) exp_err_e10_e :: Double -> Double -> (Double, Int, Double) exp_mult_err_e :: Double -> Double -> Double -> Double -> (Double, Double) exp_mult_err_e10_e :: Double -> Double -> Double -> Double -> (Double, Int, Double) -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_expint.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Expint expint_E1_e :: Double -> (Double, Double) expint_E1 :: Double -> Double expint_E2_e :: Double -> (Double, Double) expint_E2 :: Double -> Double expint_En_e :: CInt -> Double -> (Double, Double) expint_En :: CInt -> Double -> Double expint_E1_scaled_e :: Double -> (Double, Double) expint_E1_scaled :: Double -> Double expint_E2_scaled_e :: Double -> (Double, Double) expint_E2_scaled :: Double -> Double expint_En_scaled_e :: CInt -> Double -> (Double, Double) expint_En_scaled :: CInt -> Double -> Double expint_Ei_e :: Double -> (Double, Double) expint_Ei :: Double -> Double expint_Ei_scaled_e :: Double -> (Double, Double) expint_Ei_scaled :: Double -> Double shi_e :: Double -> (Double, Double) shi :: Double -> Double chi_e :: Double -> (Double, Double) chi :: Double -> Double expint_3_e :: Double -> (Double, Double) expint_3 :: Double -> Double si_e :: Double -> (Double, Double) si :: Double -> Double ci_e :: Double -> (Double, Double) ci :: Double -> Double atanint_e :: Double -> (Double, Double) atanint :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_fermi_dirac.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Fermi_dirac fermi_dirac_m1_e :: Double -> (Double, Double) fermi_dirac_m1 :: Double -> Double fermi_dirac_0_e :: Double -> (Double, Double) fermi_dirac_0 :: Double -> Double fermi_dirac_1_e :: Double -> (Double, Double) fermi_dirac_1 :: Double -> Double fermi_dirac_2_e :: Double -> (Double, Double) fermi_dirac_2 :: Double -> Double fermi_dirac_int_e :: CInt -> Double -> (Double, Double) fermi_dirac_int :: CInt -> Double -> Double fermi_dirac_mhalf_e :: Double -> (Double, Double) fermi_dirac_mhalf :: Double -> Double fermi_dirac_half_e :: Double -> (Double, Double) fermi_dirac_half :: Double -> Double fermi_dirac_3half_e :: Double -> (Double, Double) fermi_dirac_3half :: Double -> Double fermi_dirac_inc_0_e :: Double -> Double -> (Double, Double) fermi_dirac_inc_0 :: Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_gamma.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Gamma lngamma_e :: Double -> (Double, Double) lngamma :: Double -> Double gamma_e :: Double -> (Double, Double) gamma :: Double -> Double gammastar_e :: Double -> (Double, Double) gammastar :: Double -> Double gammainv_e :: Double -> (Double, Double) gammainv :: Double -> Double taylorcoeff_e :: CInt -> Double -> (Double, Double) taylorcoeff :: CInt -> Double -> Double fact_e :: CInt -> (Double, Double) fact :: CInt -> Double doublefact_e :: CInt -> (Double, Double) doublefact :: CInt -> Double lnfact_e :: CInt -> (Double, Double) lnfact :: CInt -> Double lndoublefact_e :: CInt -> (Double, Double) lndoublefact :: CInt -> Double lnchoose_e :: CInt -> CInt -> (Double, Double) lnchoose :: CInt -> CInt -> Double choose_e :: CInt -> CInt -> (Double, Double) choose :: CInt -> CInt -> Double lnpoch_e :: Double -> Double -> (Double, Double) lnpoch :: Double -> Double -> Double poch_e :: Double -> Double -> (Double, Double) poch :: Double -> Double -> Double pochrel_e :: Double -> Double -> (Double, Double) pochrel :: Double -> Double -> Double gamma_inc_Q_e :: Double -> Double -> (Double, Double) gamma_inc_Q :: Double -> Double -> Double gamma_inc_P_e :: Double -> Double -> (Double, Double) gamma_inc_P :: Double -> Double -> Double gamma_inc_e :: Double -> Double -> (Double, Double) gamma_inc :: Double -> Double -> Double lnbeta_e :: Double -> Double -> (Double, Double) lnbeta :: Double -> Double -> Double beta_e :: Double -> Double -> (Double, Double) beta :: Double -> Double -> Double beta_inc_e :: Double -> Double -> Double -> (Double, Double) beta_inc :: Double -> Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_gegenbauer.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Gegenbauer gegenpoly_1_e :: Double -> Double -> (Double, Double) gegenpoly_2_e :: Double -> Double -> (Double, Double) gegenpoly_3_e :: Double -> Double -> (Double, Double) gegenpoly_1 :: Double -> Double -> Double gegenpoly_2 :: Double -> Double -> Double gegenpoly_3 :: Double -> Double -> Double gegenpoly_n_e :: CInt -> Double -> Double -> (Double, Double) gegenpoly_n :: CInt -> Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_hyperg.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Hyperg hyperg_0F1_e :: Double -> Double -> (Double, Double) hyperg_0F1 :: Double -> Double -> Double hyperg_1F1_int_e :: CInt -> CInt -> Double -> (Double, Double) hyperg_1F1_int :: CInt -> CInt -> Double -> Double hyperg_1F1_e :: Double -> Double -> Double -> (Double, Double) hyperg_1F1 :: Double -> Double -> Double -> Double hyperg_U_int_e :: CInt -> CInt -> Double -> (Double, Double) hyperg_U_int :: CInt -> CInt -> Double -> Double hyperg_U_int_e10_e :: CInt -> CInt -> Double -> (Double, Int, Double) hyperg_U_e :: Double -> Double -> Double -> (Double, Double) hyperg_U :: Double -> Double -> Double -> Double hyperg_U_e10_e :: Double -> Double -> Double -> (Double, Int, Double) hyperg_2F1_e :: Double -> Double -> Double -> Double -> (Double, Double) hyperg_2F1 :: Double -> Double -> Double -> Double -> Double hyperg_2F1_conj_e :: Double -> Double -> Double -> Double -> (Double, Double) hyperg_2F1_conj :: Double -> Double -> Double -> Double -> Double hyperg_2F1_renorm_e :: Double -> Double -> Double -> Double -> (Double, Double) hyperg_2F1_renorm :: Double -> Double -> Double -> Double -> Double hyperg_2F1_conj_renorm_e :: Double -> Double -> Double -> Double -> (Double, Double) hyperg_2F1_conj_renorm :: Double -> Double -> Double -> Double -> Double hyperg_2F0_e :: Double -> Double -> Double -> (Double, Double) hyperg_2F0 :: Double -> Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_laguerre.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Laguerre laguerre_1_e :: Double -> Double -> (Double, Double) laguerre_2_e :: Double -> Double -> (Double, Double) laguerre_3_e :: Double -> Double -> (Double, Double) laguerre_1 :: Double -> Double -> Double laguerre_2 :: Double -> Double -> Double laguerre_3 :: Double -> Double -> Double laguerre_n_e :: CInt -> Double -> Double -> (Double, Double) laguerre_n :: CInt -> Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_lambert.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Lambert lambert_W0_e :: Double -> (Double, Double) lambert_W0 :: Double -> Double lambert_Wm1_e :: Double -> (Double, Double) lambert_Wm1 :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_legendre.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Legendre legendre_Pl_e :: CInt -> Double -> (Double, Double) legendre_Pl :: CInt -> Double -> Double legendre_P1_e :: Double -> (Double, Double) legendre_P2_e :: Double -> (Double, Double) legendre_P3_e :: Double -> (Double, Double) legendre_P1 :: Double -> Double legendre_P2 :: Double -> Double legendre_P3 :: Double -> Double legendre_Q0_e :: Double -> (Double, Double) legendre_Q0 :: Double -> Double legendre_Q1_e :: Double -> (Double, Double) legendre_Q1 :: Double -> Double legendre_Ql_e :: CInt -> Double -> (Double, Double) legendre_Ql :: CInt -> Double -> Double legendre_Plm_e :: CInt -> CInt -> Double -> (Double, Double) legendre_Plm :: CInt -> CInt -> Double -> Double legendre_sphPlm_e :: CInt -> CInt -> Double -> (Double, Double) legendre_sphPlm :: CInt -> CInt -> Double -> Double legendre_array_size :: CInt -> CInt -> CInt conicalP_half_e :: Double -> Double -> (Double, Double) conicalP_half :: Double -> Double -> Double conicalP_mhalf_e :: Double -> Double -> (Double, Double) conicalP_mhalf :: Double -> Double -> Double conicalP_0_e :: Double -> Double -> (Double, Double) conicalP_0 :: Double -> Double -> Double conicalP_1_e :: Double -> Double -> (Double, Double) conicalP_1 :: Double -> Double -> Double conicalP_sph_reg_e :: CInt -> Double -> Double -> (Double, Double) conicalP_sph_reg :: CInt -> Double -> Double -> Double conicalP_cyl_reg_e :: CInt -> Double -> Double -> (Double, Double) conicalP_cyl_reg :: CInt -> Double -> Double -> Double legendre_H3d_0_e :: Double -> Double -> (Double, Double) legendre_H3d_0 :: Double -> Double -> Double legendre_H3d_1_e :: Double -> Double -> (Double, Double) legendre_H3d_1 :: Double -> Double -> Double legendre_H3d_e :: CInt -> Double -> Double -> (Double, Double) legendre_H3d :: CInt -> Double -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_log.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Log log_e :: Double -> (Double, Double) log :: Double -> Double log_abs_e :: Double -> (Double, Double) log_abs :: Double -> Double log_1plusx_e :: Double -> (Double, Double) log_1plusx :: Double -> Double log_1plusx_mx_e :: Double -> (Double, Double) log_1plusx_mx :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_pow_int.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Pow_int pow_int_e :: Double -> CInt -> (Double, Double) pow_int :: Double -> CInt -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_psi.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Psi psi_int_e :: CInt -> (Double, Double) psi_int :: CInt -> Double psi_e :: Double -> (Double, Double) psi :: Double -> Double psi_1piy_e :: Double -> (Double, Double) psi_1piy :: Double -> Double psi_1_int_e :: CInt -> (Double, Double) psi_1_int :: CInt -> Double psi_1_e :: Double -> (Double, Double) psi_1 :: Double -> Double psi_n_e :: CInt -> Double -> (Double, Double) psi_n :: CInt -> Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_synchrotron.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Synchrotron synchrotron_1_e :: Double -> (Double, Double) synchrotron_1 :: Double -> Double synchrotron_2_e :: Double -> (Double, Double) synchrotron_2 :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_transport.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Transport transport_2_e :: Double -> (Double, Double) transport_2 :: Double -> Double transport_3_e :: Double -> (Double, Double) transport_3 :: Double -> Double transport_4_e :: Double -> (Double, Double) transport_4 :: Double -> Double transport_5_e :: Double -> (Double, Double) transport_5 :: Double -> Double -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_trig.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Trig sin_e :: Double -> (Double, Double) sin :: Double -> Double cos_e :: Double -> (Double, Double) cos :: Double -> Double hypot_e :: Double -> Double -> (Double, Double) hypot :: Double -> Double -> Double sinc_e :: Double -> (Double, Double) sinc :: Double -> Double lnsinh_e :: Double -> (Double, Double) lnsinh :: Double -> Double lncosh_e :: Double -> (Double, Double) lncosh :: Double -> Double sin_err_e :: Double -> Double -> (Double, Double) cos_err_e :: Double -> Double -> (Double, Double) angle_restrict_symm :: Double -> Double angle_restrict_pos :: Double -> Double angle_restrict_symm_err_e :: Double -> (Double, Double) angle_restrict_pos_err_e :: Double -> (Double, Double) -- | Wrappers for selected functions described at: -- -- -- http://www.google.com/search?q=gsl_sf_zeta.h&as_sitesearch=www.gnu.org/software/gsl/manual&btnI=Lucky module Numeric.GSL.Special.Zeta zeta_int_e :: CInt -> (Double, Double) zeta_int :: CInt -> Double zeta_e :: Double -> (Double, Double) zeta :: Double -> Double zetam1_e :: Double -> (Double, Double) zetam1 :: Double -> Double zetam1_int_e :: CInt -> (Double, Double) zetam1_int :: CInt -> Double hzeta_e :: Double -> Double -> (Double, Double) hzeta :: Double -> Double -> Double eta_int_e :: CInt -> (Double, Double) eta_int :: CInt -> Double eta_e :: Double -> (Double, Double) eta :: Double -> Double -- | Wrappers for selected special functions. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Special-Functions.html#Special-Functions module Numeric.GSL.Special -- | Conversion of Vectors and Matrices to and from the standard Haskell -- arrays. (provisional) module Data.Packed.Convert -- | creates an immutable Array from an hmatrix Vector (to do: unboxed) arrayFromVector :: (Storable t) => Vector t -> Array Int t vectorFromArray :: (Storable t) => Array Int t -> Vector t -- | creates a mutable array from an hmatrix Vector (to do: unboxed) mArrayFromVector :: (MArray b t (ST s), Storable t) => Vector t -> ST s (b Int t) -- | creates a mutable Array from an hmatrix Vector for manipulation with -- runSTUArray (to do: unboxed) vectorFromMArray :: (Storable t, MArray a t (ST s)) => a Int t -> ST s (Vector t) -- | Creates a StorableArray indexed from 0 to dim -1. (Memory is -- efficiently copied, so you can then freely modify the obtained array) vectorToStorableArray :: (Storable t) => Vector t -> IO (StorableArray Int t) -- | Creates a Vector from a StorableArray. (Memory is efficiently copied, -- so posterior changes in the array will not affect the result) storableArrayToVector :: (Storable t) => StorableArray Int t -> IO (Vector t) arrayFromMatrix :: Matrix Double -> UArray (Int, Int) Double matrixFromArray :: UArray (Int, Int) Double -> Matrix Double mArrayFromMatrix :: (MArray b Double m) => Matrix Double -> m (b (Int, Int) Double) matrixFromMArray :: (MArray a Double (ST s)) => a (Int, Int) Double -> ST s (Matrix Double) -- | The implementation of the Vector and Matrix types is not -- exposed, but the library can be easily extended with additional -- foreign functions using the tools in this module. Illustrative usage -- examples can be found in the examples/devel folder included -- in the package. module Data.Packed.Development createVector :: (Storable a) => Int -> IO (Vector a) createMatrix :: (Storable a) => MatrixOrder -> Int -> Int -> IO (Matrix a) type Adapt f t r = t -> ((f -> r) -> IO ()) -> IO () vec :: Adapt (CInt -> Ptr t -> r) (Vector t) r mat :: Adapt (CInt -> CInt -> Ptr t -> r) (Matrix t) r app1 :: f -> Adapt f t (IO CInt) -> t -> String -> IO () app2 :: f -> Adapt f t1 r -> t1 -> Adapt r t2 (IO CInt) -> t2 -> String -> IO () app3 :: f -> Adapt f t1 r1 -> t1 -> Adapt r1 t2 r2 -> t2 -> Adapt r2 t3 (IO CInt) -> t3 -> String -> IO () app4 :: f -> Adapt f t1 r1 -> t1 -> Adapt r1 t2 r2 -> t2 -> Adapt r2 t3 r3 -> t3 -> Adapt r3 t4 (IO CInt) -> t4 -> String -> IO () data MatrixOrder RowMajor :: MatrixOrder ColumnMajor :: MatrixOrder orderOf :: Matrix t -> MatrixOrder cmat :: (Element t) => Matrix t -> Matrix t fmat :: (Element t) => Matrix t -> Matrix t -- | 1D arrays suitable for numeric computations using external libraries. module Data.Packed.Vector -- | A one-dimensional array of objects stored in a contiguous memory -- block. data Vector t -- | creates a Vector from a list: -- --
--   > fromList [2,3,5,7]
--   4 |> [2.0,3.0,5.0,7.0]
--   
fromList :: (Storable a) => [a] -> Vector a -- | An alternative to fromList with explicit dimension. The input -- list is explicitly truncated if it is too long, so it may safely be -- used, for instance, with infinite lists. -- -- This is the format used in the instances for Show (Vector a). (|>) :: (Storable a) => Int -> [a] -> Vector a -- | extracts the Vector elements to a list -- --
--   > toList (linspace 5 (1,10))
--   [1.0,3.25,5.5,7.75,10.0]
--   
toList :: (Storable a) => Vector a -> [a] -- | number of elements dim :: Vector t -> Int -- | Reads a vector position: -- --
--   > fromList [0..9] @> 7
--   7.0
--   
(@>) :: (Storable t) => Vector t -> Int -> t -- | takes a number of consecutive elements from a Vector -- --
--   > subVector 2 3 (fromList [1..10])
--   3 |> [3.0,4.0,5.0]
--   
subVector :: (Storable t) => Int -> Int -> Vector t -> Vector t -- | creates a new Vector by joining a list of Vectors -- --
--   > join [fromList [1..5], constant 1 3]
--   8 |> [1.0,2.0,3.0,4.0,5.0,1.0,1.0,1.0]
--   
join :: (Storable t) => [Vector t] -> Vector t -- | creates a vector with a given number of equal components: -- --
--   > constant 2 7
--   7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]
--   
constant :: (Element a) => a -> Int -> Vector a -- | Creates a real vector containing a range of values: -- --
--   > linspace 5 (-3,7)
--   5 |> [-3.0,-0.5,2.0,4.5,7.0]
--   
linspace :: Int -> (Double, Double) -> Vector Double vectorMax :: Vector Double -> Double vectorMin :: Vector Double -> Double vectorMaxIndex :: Vector Double -> Int vectorMinIndex :: Vector Double -> Int -- | map on Vectors mapVector :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b -- | zipWith for Vectors zipVector :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c -- | Loads a vector from an ASCII file (the number of elements must be -- known in advance). fscanfVector :: FilePath -> Int -> IO (Vector Double) -- | Saves the elements of a vector, with a given format (%f, %e, %g), to -- an ASCII file. fprintfVector :: FilePath -> String -> Vector Double -> IO () -- | Loads a vector from a binary file (the number of elements must be -- known in advance). freadVector :: FilePath -> Int -> IO (Vector Double) -- | Saves the elements of a vector to a binary file. fwriteVector :: FilePath -> Vector Double -> IO () liftVector :: (Storable a, Storable b) => (a -> b) -> Vector a -> Vector b liftVector2 :: (Storable a, Storable b, Storable c) => (a -> b -> c) -> Vector a -> Vector b -> Vector c foldLoop :: (Int -> t -> t) -> t -> Int -> t foldVector :: (Double -> b -> b) -> b -> Vector Double -> b foldVectorG :: (Storable a) => (Int -> (Int -> a) -> t -> t) -> t -> Vector a -> t -- | A Matrix representation suitable for numerical computations using -- LAPACK and GSL. module Data.Packed.Matrix -- | Auxiliary class. class (Storable a, Floating a) => Element a -- | Matrix representation suitable for GSL and LAPACK computations. data Matrix t rows :: Matrix t -> Int cols :: Matrix t -> Int -- | An easy way to create a matrix: -- --
--   > (2><3)[1..6]
--   (2><3)
--    [ 1.0, 2.0, 3.0
--    , 4.0, 5.0, 6.0 ]
--   
-- -- This is the format produced by the instances of Show (Matrix a), which -- can also be used for input. -- -- The input list is explicitly truncated, so that it can safely be used -- with lists that are too long (like infinite lists). -- -- Example: -- --
--   > (2>|<3)[1..]
--   (2><3)
--    [ 1.0, 2.0, 3.0
--    , 4.0, 5.0, 6.0 ]
--   
(><) :: (Element a) => Int -> Int -> [a] -> Matrix a -- | Matrix transpose. trans :: Matrix t -> Matrix t -- | Creates a matrix from a vector by grouping the elements in rows with -- the desired number of columns. (GNU-Octave groups by columns. To do it -- you can define reshapeF r = trans . reshape r where r is the -- desired number of rows.) -- --
--   > reshape 4 (fromList [1..12])
--   (3><4)
--    [ 1.0,  2.0,  3.0,  4.0
--    , 5.0,  6.0,  7.0,  8.0
--    , 9.0, 10.0, 11.0, 12.0 ]
--   
reshape :: (Element t) => Int -> Vector t -> Matrix t -- | Creates a vector by concatenation of rows -- --
--   > flatten (ident 3)
--   9 |> [1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0]
--   
flatten :: (Element t) => Matrix t -> Vector t -- | Creates a Matrix from a list of lists (considered as rows). -- --
--   > fromLists [[1,2],[3,4],[5,6]]
--   (3><2)
--    [ 1.0, 2.0
--    , 3.0, 4.0
--    , 5.0, 6.0 ]
--   
fromLists :: (Element t) => [[t]] -> Matrix t -- | the inverse of Data.Packed.Matrix.fromLists toLists :: (Element t) => Matrix t -> [[t]] -- | Reads a matrix position. (@@>) :: (Storable t) => Matrix t -> (Int, Int) -> t -- | creates a 1-row matrix from a vector asRow :: (Element a) => Vector a -> Matrix a -- | creates a 1-column matrix from a vector asColumn :: (Element a) => Vector a -> Matrix a -- | creates a Matrix from a list of vectors fromRows :: (Element t) => [Vector t] -> Matrix t -- | extracts the rows of a matrix as a list of vectors toRows :: (Element t) => Matrix t -> [Vector t] -- | Creates a matrix from a list of vectors, as columns fromColumns :: (Element t) => [Vector t] -> Matrix t -- | Creates a list of vectors from the columns of a matrix toColumns :: (Element t) => Matrix t -> [Vector t] -- | Creates a matrix from blocks given as a list of lists of matrices: -- --
--   > let a = diag $ fromList [5,7,2]
--   > let b = reshape 4 $ constant (-1) 12
--   > fromBlocks [[a,b],[b,a]]
--   (6><7)
--    [  5.0,  0.0,  0.0, -1.0, -1.0, -1.0, -1.0
--    ,  0.0,  7.0,  0.0, -1.0, -1.0, -1.0, -1.0
--    ,  0.0,  0.0,  2.0, -1.0, -1.0, -1.0, -1.0
--    , -1.0, -1.0, -1.0, -1.0,  5.0,  0.0,  0.0
--    , -1.0, -1.0, -1.0, -1.0,  0.0,  7.0,  0.0
--    , -1.0, -1.0, -1.0, -1.0,  0.0,  0.0,  2.0 ]
--   
fromBlocks :: (Element t) => [[Matrix t]] -> Matrix t -- | creates matrix by repetition of a matrix a given number of rows and -- columns -- --
--   > repmat (ident 2) 2 3 :: Matrix Double
--   (4><6)
--    [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
--    , 0.0, 1.0, 0.0, 1.0, 0.0, 1.0
--    , 1.0, 0.0, 1.0, 0.0, 1.0, 0.0
--    , 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]
--   
repmat :: (Element t) => Matrix t -> Int -> Int -> Matrix t -- | Reverse rows flipud :: (Element t) => Matrix t -> Matrix t -- | Reverse columns fliprl :: (Element t) => Matrix t -> Matrix t -- | Extracts a submatrix from a matrix. subMatrix :: (Element a) => (Int, Int) -> (Int, Int) -> Matrix a -> Matrix a -- | Creates a matrix with the first n rows of another matrix takeRows :: (Element t) => Int -> Matrix t -> Matrix t -- | Creates a copy of a matrix without the first n rows dropRows :: (Element t) => Int -> Matrix t -> Matrix t -- | Creates a matrix with the first n columns of another matrix takeColumns :: (Element t) => Int -> Matrix t -> Matrix t -- | Creates a copy of a matrix without the first n columns dropColumns :: (Element t) => Int -> Matrix t -> Matrix t -- | rearranges the rows of a matrix according to the order given in a list -- of integers. extractRows :: (Element t) => [Int] -> Matrix t -> Matrix t -- | creates the identity matrix of given dimension ident :: (Element a) => Int -> Matrix a -- | Creates a square matrix with a given diagonal. diag :: (Element a) => Vector a -> Matrix a -- | creates a rectangular diagonal matrix -- --
--   > diagRect (constant 5 3) 3 4 :: Matrix Double
--   (3><4)
--    [ 5.0, 0.0, 0.0, 0.0
--    , 0.0, 5.0, 0.0, 0.0
--    , 0.0, 0.0, 5.0, 0.0 ]
--   
diagRect :: (Element t, Num t) => Vector t -> Int -> Int -> Matrix t -- | extracts the diagonal from a rectangular matrix takeDiag :: (Element t) => Matrix t -> Vector t -- | application of a vector function on the flattened matrix elements liftMatrix :: (Element a, Element b) => (Vector a -> Vector b) -> Matrix a -> Matrix b -- | application of a vector function on the flattened matrices elements liftMatrix2 :: (Element t, Element a, Element b) => (Vector a -> Vector b -> Vector t) -> Matrix a -> Matrix b -> Matrix t -- | Creates a string from a matrix given a separator and a function to -- show each entry. Using this function the user can easily define any -- desired display function: -- --
--   import Text.Printf(printf)
--   
-- --
--   disp = putStrLn . format "  " (printf "%.2f")
--   
format :: (Element t) => String -> (t -> String) -> Matrix t -> String -- | Loads a matrix from an ASCII file formatted as a 2D table. loadMatrix :: FilePath -> IO (Matrix Double) -- | Saves a matrix as 2D ASCII table. saveMatrix :: FilePath -> String -> Matrix Double -> IO () -- | Loads a matrix from an ASCII file (the number of rows and columns must -- be known in advance). fromFile :: FilePath -> (Int, Int) -> IO (Matrix Double) -- | obtains the number of rows and columns in an ASCII data file -- (provisionally using unix's wc). fileDimensions :: FilePath -> IO (Int, Int) -- | reads a matrix from a string containing a table of numbers. readMatrix :: String -> Matrix Double fromArray2D :: (Element e) => Array (Int, Int) e -> Matrix e -- | Minimization of a multidimensional function using some of the -- algorithms described in: -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Multidimensional-Minimization.html -- -- The example in the GSL manual: -- --
--   f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30
--   
--   main = do
--       let (s,p) = minimize NMSimplex2 1E-2 30 [1,1] f [5,7]
--       print s
--       print p
--   
--   > main
--   [0.9920430849306288,1.9969168063253182]
--    0.000  512.500  1.130  6.500  5.000
--    1.000  290.625  1.409  5.250  4.000
--    2.000  290.625  1.409  5.250  4.000
--    3.000  252.500  1.409  5.500  1.000
--    ...
--   22.000   30.001  0.013  0.992  1.997
--   23.000   30.001  0.008  0.992  1.997
--   
-- -- The path to the solution can be graphically shown by means of: -- --
--   Graphics.Plot.mplot $ drop 3 (toColumns p)
--   
-- -- Taken from the GSL manual: -- -- The vector Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm is a -- quasi-Newton method which builds up an approximation to the second -- derivatives of the function f using the difference between successive -- gradient vectors. By combining the first and second derivatives the -- algorithm is able to take Newton-type steps towards the function -- minimum, assuming quadratic behavior in that region. -- -- The bfgs2 version of this minimizer is the most efficient version -- available, and is a faithful implementation of the line minimization -- scheme described in Fletcher's Practical Methods of Optimization, -- Algorithms 2.6.2 and 2.6.4. It supercedes the original bfgs routine -- and requires substantially fewer function and gradient evaluations. -- The user-supplied tolerance tol corresponds to the parameter sigma -- used by Fletcher. A value of 0.1 is recommended for typical use -- (larger values correspond to less accurate line searches). -- -- The nmsimplex2 version is a new O(N) implementation of the earlier -- O(N^2) nmsimplex minimiser. It calculates the size of simplex as the -- rms distance of each vertex from the center rather than the mean -- distance, which has the advantage of allowing a linear update. module Numeric.GSL.Minimization -- | Minimization without derivatives. minimize :: MinimizeMethod -> Double -> Int -> [Double] -> ([Double] -> Double) -> [Double] -> ([Double], Matrix Double) data MinimizeMethod NMSimplex :: MinimizeMethod NMSimplex2 :: MinimizeMethod -- | Minimization with derivatives. minimizeD :: MinimizeMethodD -> Double -> Int -> Double -> Double -> ([Double] -> Double) -> ([Double] -> [Double]) -> [Double] -> ([Double], Matrix Double) data MinimizeMethodD ConjugateFR :: MinimizeMethodD ConjugatePR :: MinimizeMethodD VectorBFGS :: MinimizeMethodD VectorBFGS2 :: MinimizeMethodD SteepestDescent :: MinimizeMethodD minimizeNMSimplex :: ([Double] -> Double) -> [Double] -> [Double] -> Double -> Int -> ([Double], Matrix Double) minimizeConjugateGradient :: Double -> Double -> Double -> Int -> ([Double] -> Double) -> ([Double] -> [Double]) -> [Double] -> ([Double], Matrix Double) minimizeVectorBFGS2 :: Double -> Double -> Double -> Int -> ([Double] -> Double) -> ([Double] -> [Double]) -> [Double] -> ([Double], Matrix Double) instance Enum MinimizeMethodD instance Eq MinimizeMethodD instance Show MinimizeMethodD instance Bounded MinimizeMethodD instance Enum MinimizeMethod instance Eq MinimizeMethod instance Show MinimizeMethod instance Bounded MinimizeMethod -- | Multidimensional root finding. -- -- -- http://www.gnu.org/software/gsl/manual/html_node/Multidimensional-Root_002dFinding.html -- -- The example in the GSL manual: -- --
--   import Numeric.GSL
--   import Numeric.LinearAlgebra(format)
--   import Text.Printf(printf)
--   
--   rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ]
--   
--   disp = putStrLn . format "  " (printf "%.3f")
--   
--   main = do
--       let (sol,path) = root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5]
--       print sol
--       disp path
--   
--   > main
--   [1.0,1.0]
--    0.000  -10.000  -5.000  11.000  -1050.000
--    1.000   -3.976  24.827   4.976     90.203
--    2.000   -3.976  24.827   4.976     90.203
--    3.000   -3.976  24.827   4.976     90.203
--    4.000   -1.274  -5.680   2.274    -73.018
--    5.000   -1.274  -5.680   2.274    -73.018
--    6.000    0.249   0.298   0.751      2.359
--    7.000    0.249   0.298   0.751      2.359
--    8.000    1.000   0.878  -0.000     -1.218
--    9.000    1.000   0.989  -0.000     -0.108
--   10.000    1.000   1.000   0.000      0.000
--   
module Numeric.GSL.Root -- | Nonlinear multidimensional root finding using algorithms that do not -- require any derivative information to be supplied by the user. Any -- derivatives needed are approximated by finite differences. root :: RootMethod -> Double -> Int -> ([Double] -> [Double]) -> [Double] -> ([Double], Matrix Double) data RootMethod Hybrids :: RootMethod Hybrid :: RootMethod DNewton :: RootMethod Broyden :: RootMethod -- | Nonlinear multidimensional root finding using both the function and -- its derivatives. rootJ :: RootMethodJ -> Double -> Int -> ([Double] -> [Double]) -> ([Double] -> [[Double]]) -> [Double] -> ([Double], Matrix Double) data RootMethodJ HybridsJ :: RootMethodJ HybridJ :: RootMethodJ Newton :: RootMethodJ GNewton :: RootMethodJ instance Enum RootMethodJ instance Eq RootMethodJ instance Show RootMethodJ instance Bounded RootMethodJ instance Enum RootMethod instance Eq RootMethod instance Show RootMethod instance Bounded RootMethod -- | This module reexports all the available GSL functions (except those in -- Numeric.LinearAlgebra). module Numeric.GSL -- | This action removes the GSL default error handler (which aborts the -- program), so that GSL errors can be handled by Haskell (using -- Control.Exception) and ghci doesn't abort. setErrorHandlerOff :: IO () -- | The Vector and Matrix types and some utilities. module Data.Packed -- | conversion utilities class (Element e) => Container c e toComplex :: (Container c e, RealFloat e) => (c e, c e) -> c (Complex e) fromComplex :: (Container c e, RealFloat e) => c (Complex e) -> (c e, c e) comp :: (Container c e, RealFloat e) => c e -> c (Complex e) conj :: (Container c e, RealFloat e) => c (Complex e) -> c (Complex e) real :: (Container c e) => c Double -> c e complex :: (Container c e) => c e -> c (Complex Double) instance Container Matrix (Complex Double) instance Container Matrix Double instance Container Vector (Complex Double) instance Container Vector Double -- | Basic optimized operations on vectors and matrices. module Numeric.LinearAlgebra.Linear -- | A generic interface for vectors and matrices to a few -- element-by-element functions in Numeric.GSL.Vector. class (Container c e) => Linear c e scale :: (Linear c e) => e -> c e -> c e addConstant :: (Linear c e) => e -> c e -> c e add :: (Linear c e) => c e -> c e -> c e sub :: (Linear c e) => c e -> c e -> c e mul :: (Linear c e) => c e -> c e -> c e divide :: (Linear c e) => c e -> c e -> c e scaleRecip :: (Linear c e) => e -> c e -> c e equal :: (Linear c e) => c e -> c e -> Bool instance (Linear Vector a, Container Matrix a) => Linear Matrix a instance Linear Vector (Complex Double) instance Linear Vector Double -- | This module exports Show, Read, Eq, Num, Fractional, and Floating -- instances for Vector and Matrix. -- -- In the context of the standard numeric operators, one-component -- vectors and matrices automatically expand to match the dimensions of -- the other operand. module Numeric.LinearAlgebra.Instances instance (Storable a) => Monoid (Vector a) instance (Linear Vector a, Floating (Vector a), Fractional (Matrix a)) => Floating (Matrix a) instance Floating (Vector (Complex Double)) instance Floating (Vector Double) instance (Linear Vector a, Fractional (Vector a), Num (Matrix a)) => Fractional (Matrix a) instance (Linear Vector a, Num (Vector a)) => Fractional (Vector a) instance (Linear Matrix a, Num (Vector a)) => Num (Matrix a) instance (Eq a, Element a) => Eq (Matrix a) instance Num (Vector (Complex Double)) instance Num (Vector Double) instance (Eq a, Element a) => Eq (Vector a) instance (Element a, Read a) => Read (Vector a) instance (Element a, Read a) => Read (Matrix a) instance (Show a, Storable a) => Show (Vector a) instance (Show a, Element a) => Show (Matrix a) -- | Wrappers for a few LAPACK functions -- (http://www.netlib.org/lapack). module Numeric.LinearAlgebra.LAPACK -- | Matrix product based on BLAS's dgemm. multiplyR :: Matrix Double -> Matrix Double -> Matrix Double -- | Matrix product based on BLAS's zgemm. multiplyC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dgesvd, which computes the full svd -- decomposition of a real matrix. -- -- (u,s,v)=full svdR m so that m=u <> s <> -- trans v. svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) -- | Wrapper for LAPACK's dgesvd, which computes the full svd -- decomposition of a real matrix. -- -- (u,s,v)=full svdRdd m so that m=u <> s <> -- trans v. svdRdd :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) -- | Wrapper for LAPACK's zgesvd, which computes the full svd -- decomposition of a complex matrix. -- -- (u,s,v)=full svdC m so that m=u <> comp s <> -- trans v. svdC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector Double, Matrix (Complex Double)) -- | Wrapper for LAPACK's zgeev, which computes the eigenvalues and -- right eigenvectors of a general complex matrix: -- -- if (l,v)=eigC m then m <> v = v <> diag -- l. -- -- The eigenvectors are the columns of v. The eigenvalues are not sorted. eigC :: Matrix (Complex Double) -> (Vector (Complex Double), Matrix (Complex Double)) -- | Wrapper for LAPACK's dgeev, which computes the eigenvalues and -- right eigenvectors of a general real matrix: -- -- if (l,v)=eigR m then m <> v = v <> diag -- l. -- -- The eigenvectors are the columns of v. The eigenvalues are not sorted. eigR :: Matrix Double -> (Vector (Complex Double), Matrix (Complex Double)) -- | Wrapper for LAPACK's dsyev, which computes the eigenvalues and -- right eigenvectors of a symmetric real matrix: -- -- if (l,v)=eigSl m then m <> v = v <> diag -- l. -- -- The eigenvectors are the columns of v. The eigenvalues are sorted in -- descending order (use eigS' for ascending order). eigS :: Matrix Double -> (Vector Double, Matrix Double) -- | Wrapper for LAPACK's zheev, which computes the eigenvalues and -- right eigenvectors of a hermitian complex matrix: -- -- if (l,v)=eigH m then m <> s v = v <> diag -- l. -- -- The eigenvectors are the columns of v. The eigenvalues are sorted in -- descending order (use eigH' for ascending order). eigH :: Matrix (Complex Double) -> (Vector Double, Matrix (Complex Double)) eigS' :: Matrix Double -> (Vector Double, Matrix Double) eigH' :: Matrix (Complex Double) -> (Vector Double, Matrix (Complex Double)) -- | Wrapper for LAPACK's dgesv, which solves a general real linear -- system (for several right-hand sides) internally using the lu -- decomposition. linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double -- | Wrapper for LAPACK's zgesv, which solves a general complex -- linear system (for several right-hand sides) internally using the lu -- decomposition. linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dgels, which obtains the least squared -- error solution of an overconstrained real linear system or the minimum -- norm solution of an underdetermined system, for several right-hand -- sides. For rank deficient systems use linearSolveSVDR. linearSolveLSR :: Matrix Double -> Matrix Double -> Matrix Double -- | Wrapper for LAPACK's zgels, which obtains the least squared -- error solution of an overconstrained complex linear system or the -- minimum norm solution of an underdetermined system, for several -- right-hand sides. For rank deficient systems use -- linearSolveSVDC. linearSolveLSC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dgelss, which obtains the minimum norm -- solution to a real linear least squares problem Ax=B using the svd, -- for several right-hand sides. Admits rank deficient systems but it is -- slower than linearSolveLSR. The effective rank of A is -- determined by treating as zero those singular valures which are less -- than rcond times the largest singular value. If rcond == Nothing -- machine precision is used. linearSolveSVDR :: Maybe Double -> Matrix Double -> Matrix Double -> Matrix Double -- | Wrapper for LAPACK's zgelss, which obtains the minimum norm -- solution to a complex linear least squares problem Ax=B using the svd, -- for several right-hand sides. Admits rank deficient systems but it is -- slower than linearSolveLSC. The effective rank of A is -- determined by treating as zero those singular valures which are less -- than rcond times the largest singular value. If rcond == Nothing -- machine precision is used. linearSolveSVDC :: Maybe Double -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dgetrf, which computes a LU factorization -- of a general real matrix. luR :: Matrix Double -> (Matrix Double, [Int]) -- | Wrapper for LAPACK's zgees, which computes a Schur -- factorization of a square complex matrix. luC :: Matrix (Complex Double) -> (Matrix (Complex Double), [Int]) -- | Wrapper for LAPACK's dgetrs, which solves a general real linear -- system (for several right-hand sides) from a precomputed LU -- decomposition. lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double -- | Wrapper for LAPACK's zgetrs, which solves a general real linear -- system (for several right-hand sides) from a precomputed LU -- decomposition. lusC :: Matrix (Complex Double) -> [Int] -> Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dpotrf, which computes the Cholesky -- factorization of a real symmetric positive definite matrix. cholS :: Matrix Double -> Matrix Double -- | Wrapper for LAPACK's zpotrf, which computes the Cholesky -- factorization of a complex Hermitian positive definite matrix. cholH :: Matrix (Complex Double) -> Matrix (Complex Double) -- | Wrapper for LAPACK's dgeqr2, which computes a QR factorization -- of a real matrix. qrR :: Matrix Double -> (Matrix Double, Vector Double) -- | Wrapper for LAPACK's zgeqr2, which computes a QR factorization -- of a complex matrix. qrC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) -- | Wrapper for LAPACK's dgehrd, which computes a Hessenberg -- factorization of a square real matrix. hessR :: Matrix Double -> (Matrix Double, Vector Double) -- | Wrapper for LAPACK's zgehrd, which computes a Hessenberg -- factorization of a square complex matrix. hessC :: Matrix (Complex Double) -> (Matrix (Complex Double), Vector (Complex Double)) -- | Wrapper for LAPACK's dgees, which computes a Schur -- factorization of a square real matrix. schurR :: Matrix Double -> (Matrix Double, Matrix Double) -- | Wrapper for LAPACK's zgees, which computes a Schur -- factorization of a square complex matrix. schurC :: Matrix (Complex Double) -> (Matrix (Complex Double), Matrix (Complex Double)) -- | A generic interface for some common functions. Using it we can write -- higher level algorithms and testing properties both for real and -- complex matrices. -- -- In any case, the specific functions for particular base types can also -- be explicitly imported from Numeric.LinearAlgebra.LAPACK. module Numeric.LinearAlgebra.Algorithms -- | Auxiliary typeclass used to define generic computations for both real -- and complex matrices. class (Normed (Matrix t), Linear Vector t, Linear Matrix t) => Field t -- | Matrix product. multiply :: (Field t) => Matrix t -> Matrix t -> Matrix t -- | Euclidean inner product. dot :: (Field t) => Vector t -> Vector t -> t -- | Outer product of two vectors. -- --
--   > fromList [1,2,3] `outer` fromList [5,2,3]
--   (3><3)
--    [  5.0, 2.0, 3.0
--    , 10.0, 4.0, 6.0
--    , 15.0, 6.0, 9.0 ]
--   
outer :: (Field t) => Vector t -> Vector t -> Matrix t -- | Kronecker product of two matrices. -- --
--   m1=(2><3)
--    [ 1.0,  2.0, 0.0
--    , 0.0, -1.0, 3.0 ]
--   m2=(4><3)
--    [  1.0,  2.0,  3.0
--    ,  4.0,  5.0,  6.0
--    ,  7.0,  8.0,  9.0
--    , 10.0, 11.0, 12.0 ]
--   
-- --
--   > kronecker m1 m2
--   (8><9)
--    [  1.0,  2.0,  3.0,   2.0,   4.0,   6.0,  0.0,  0.0,  0.0
--    ,  4.0,  5.0,  6.0,   8.0,  10.0,  12.0,  0.0,  0.0,  0.0
--    ,  7.0,  8.0,  9.0,  14.0,  16.0,  18.0,  0.0,  0.0,  0.0
--    , 10.0, 11.0, 12.0,  20.0,  22.0,  24.0,  0.0,  0.0,  0.0
--    ,  0.0,  0.0,  0.0,  -1.0,  -2.0,  -3.0,  3.0,  6.0,  9.0
--    ,  0.0,  0.0,  0.0,  -4.0,  -5.0,  -6.0, 12.0, 15.0, 18.0
--    ,  0.0,  0.0,  0.0,  -7.0,  -8.0,  -9.0, 21.0, 24.0, 27.0
--    ,  0.0,  0.0,  0.0, -10.0, -11.0, -12.0, 30.0, 33.0, 36.0 ]
--   
kronecker :: (Field t) => Matrix t -> Matrix t -> Matrix t -- | Solution of a general linear system (for several right-hand sides) -- using lapacks' dgesv or zgesv. It is similar to luSolve . -- luPacked, but linearSolve raises an error if called on -- a singular system. See also other versions of linearSolve in -- Numeric.LinearAlgebra.LAPACK. linearSolve :: (Field t) => Matrix t -> Matrix t -> Matrix t -- | Solution of a linear system (for several right hand sides) from the -- precomputed LU factorization obtained by luPacked. luSolve :: (Field t) => (Matrix t, [Int]) -> Matrix t -> Matrix t linearSolveSVD :: (Field t) => Matrix t -> Matrix t -> Matrix t -- | Inverse of a square matrix using lapacks' dgesv and zgesv. inv :: (Field t) => Matrix t -> Matrix t -- | Pseudoinverse of a general matrix using lapack's dgelss or zgelss. pinv :: (Field t) => Matrix t -> Matrix t -- | determinant of a square matrix, computed from the LU decomposition. det :: (Field t) => Matrix t -> t -- | Number of linearly independent rows or columns. rank :: (Field t) => Matrix t -> Int -- | Reciprocal of the 2-norm condition number of a matrix, computed from -- the SVD. rcond :: (Field t) => Matrix t -> Double -- | Singular value decomposition using lapack's dgesvd or zgesvd. svd :: (Field t) => Matrix t -> (Matrix t, Vector Double, Matrix t) -- | A version of svd which returns an appropriate diagonal matrix -- with the singular values. -- -- If (u,d,v) = full svd m then m == u <> d <> -- trans v. full :: (Element t) => (Matrix t -> (Matrix t, Vector Double, Matrix t)) -> Matrix t -> (Matrix t, Matrix Double, Matrix t) -- | A version of svd which returns only the nonzero singular values -- and the corresponding rows and columns of the rotations. -- -- If (u,s,v) = economy svd m then m == u <> diag s -- <> trans v. economy :: (Element t) => (Matrix t -> (Matrix t, Vector Double, Matrix t)) -> Matrix t -> (Matrix t, Vector Double, Matrix t) -- | Eigenvalues and eigenvectors of a general square matrix using lapack's -- dgeev or zgeev. -- -- If (s,v) = eig m then m <> v == v <> diag -- s eig :: (Field t) => Matrix t -> (Vector (Complex Double), Matrix (Complex Double)) -- | Eigenvalues and Eigenvectors of a complex hermitian or real symmetric -- matrix using lapack's dsyev or zheev. -- -- If (s,v) = eigSH m then m == v <> diag s <> -- ctrans v eigSH :: (Field t) => Matrix t -> (Vector Double, Matrix t) -- | Similar to eigSH without checking that the input matrix is -- hermitian or symmetric. eigSH' :: (Field t) => Matrix t -> (Vector Double, Matrix t) -- | QR factorization using lapack's dgeqr2 or zgeqr2. -- -- If (q,r) = qr m then m == q <> r, where q is -- unitary and r is upper triangular. qr :: (Field t) => Matrix t -> (Matrix t, Matrix t) -- | Cholesky factorization of a positive definite hermitian or symmetric -- matrix using lapack's dpotrf or zportrf. -- -- If c = chol m then m == ctrans c <> c. chol :: (Field t) => Matrix t -> Matrix t -- | Similar to chol without checking that the input matrix is -- hermitian or symmetric. cholSH :: (Field t) => Matrix t -> Matrix t -- | Hessenberg factorization using lapack's dgehrd or zgehrd. -- -- If (p,h) = hess m then m == p <> h <> ctrans -- p, where p is unitary and h is in upper Hessenberg form. hess :: (Field t) => Matrix t -> (Matrix t, Matrix t) -- | Schur factorization using lapack's dgees or zgees. -- -- If (u,s) = schur m then m == u <> s <> ctrans -- u, where u is unitary and s is a Shur matrix. A complex Schur -- matrix is upper triangular. A real Schur matrix is upper triangular in -- 2x2 blocks. -- -- "Anything that the Jordan decomposition can do, the Schur -- decomposition can do better!" (Van Loan) schur :: (Field t) => Matrix t -> (Matrix t, Matrix t) -- | Explicit LU factorization of a general matrix using lapack's dgetrf or -- zgetrf. -- -- If (l,u,p,s) = lu m then m == p <> l <> -- u, where l is lower triangular, u is upper triangular, p is a -- permutation matrix and s is the signature of the permutation. lu :: (Field t) => Matrix t -> (Matrix t, Matrix t, Matrix t, t) -- | Obtains the LU decomposition of a matrix in a compact data structure -- suitable for luSolve. luPacked :: (Field t) => Matrix t -> (Matrix t, [Int]) -- | Matrix exponential. It uses a direct translation of Algorithm 11.3.1 -- in Golub & Van Loan, based on a scaled Pade approximation. expm :: (Field t) => Matrix t -> Matrix t -- | Matrix square root. Currently it uses a simple iterative algorithm -- described in Wikipedia. It only works with invertible matrices that -- have a real solution. For diagonalizable matrices you can try -- matFunc sqrt. -- --
--   m = (2><2) [4,9
--              ,0,4] :: Matrix Double
--   
-- --
--   >sqrtm m
--   (2><2)
--    [ 2.0, 2.25
--    , 0.0,  2.0 ]
--   
sqrtm :: (Field t) => Matrix t -> Matrix t -- | Generic matrix functions for diagonalizable matrices. For instance: -- --
--   logm = matFunc log
--   
matFunc :: (Field t) => (Complex Double -> Complex Double) -> Matrix t -> Matrix (Complex Double) -- | The nullspace of a matrix from its SVD decomposition. nullspacePrec :: (Field t) => Double -> Matrix t -> [Vector t] -- | The nullspace of a matrix, assumed to be one-dimensional, with default -- tolerance (shortcut for last . nullspacePrec 1). nullVector :: (Field t) => Matrix t -> Vector t -- | Objects which have a p-norm. Using it you can define convenient -- shortcuts: -- --
--   norm2 x = pnorm PNorm2 x
--   
-- --
--   frobenius m = norm2 . flatten $ m
--   
class Normed t pnorm :: (Normed t) => NormType -> t -> Double data NormType Infinity :: NormType PNorm1 :: NormType PNorm2 :: NormType -- | Generic conjugate transpose. ctrans :: (Field t) => Matrix t -> Matrix t -- | The machine precision of a Double: eps = 2.22044604925031e-16 -- (the value used by GNU-Octave). eps :: Double -- | The imaginary unit: i = 0.0 :+ 1.0 i :: Complex Double haussholder :: (Field a) => a -> Vector a -> Matrix a unpackQR :: (Field t) => (Matrix t, Vector t) -> (Matrix t, Matrix t) unpackHess :: (Field t) => (Matrix t -> (Matrix t, Vector t)) -> Matrix t -> (Matrix t, Matrix t) pinvTol :: Double -> Matrix Double -> Matrix Double instance Normed (Matrix (Complex Double)) instance Normed (Matrix Double) instance Normed (Vector (Complex Double)) instance Normed (Vector Double) instance Field (Complex Double) instance Field Double -- | (Very provisional) operators for frequent operations. module Numeric.LinearAlgebra.Interface -- | matrix product (<>) :: (Mul a b c, Field t) => a t -> b t -> c t -- |
--   u <.> v = dot u v
--   
(<.>) :: (Field t) => Vector t -> Vector t -> t -- | least squares solution of a linear system, similar to the \ operator -- of Matlab/Octave (based on linearSolveSVD). (<\>) :: (Field a) => Matrix a -> Vector a -> Vector a -- |
--   x .* a = scale x a
--   
(.*) :: (Linear c a) => a -> c a -> c a -- |
--   a */ x = scale (recip x) a
--   
(*/) :: (Linear c a) => c a -> a -> c a -- | Horizontal concatenation of matrices and vectors: -- --
--   > (ident 3 <-> 3 * ident 3) <|> fromList [1..6.0]
--   (6><4)
--    [ 1.0, 0.0, 0.0, 1.0
--    , 0.0, 1.0, 0.0, 2.0
--    , 0.0, 0.0, 1.0, 3.0
--    , 3.0, 0.0, 0.0, 4.0
--    , 0.0, 3.0, 0.0, 5.0
--    , 0.0, 0.0, 3.0, 6.0 ]
--   
(<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t -- | Vertical concatenation of matrices and vectors. (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t instance Joinable Vector Matrix instance Joinable Matrix Vector instance Joinable Matrix Matrix instance Mul Vector Matrix Vector instance Mul Matrix Vector Vector instance Mul Matrix Matrix Matrix -- | Basic matrix computations implemented by BLAS, LAPACK and GSL. -- -- This module reexports the most comon functions (including -- Numeric.LinearAlgebra.Instances). module Numeric.LinearAlgebra -- | Some tests. module Numeric.LinearAlgebra.Tests qCheck :: (Testable prop) => Int -> prop -> IO () -- | All tests must pass with a maximum dimension of about 20 (some tests -- may fail with bigger sizes due to precision loss). runTests :: Int -> IO () -- | Very basic (and provisional) drawing tools using gnuplot and -- imageMagick. -- -- This module is deprecated. It will be replaced by improved drawing -- tools based on the Gnuplot package by Henning Thielemann. module Graphics.Plot -- | plots several vectors against the first one mplot :: [Vector Double] -> IO () -- | Draws a list of functions over a desired range and with a desired -- number of points -- --
--   > plot [sin, cos, sin.(3*)] (0,2*pi) 1000
--   
plot :: [Vector Double -> Vector Double] -> (Double, Double) -> Int -> IO () -- | Draws a parametric curve. For instance, to draw a spiral we can do -- something like: -- --
--   > parametricPlot (\t->(t * sin t, t * cos t)) (0,10*pi) 1000
--   
parametricPlot :: (Vector Double -> (Vector Double, Vector Double)) -> (Double, Double) -> Int -> IO () -- | Draws the surface represented by the function f in the desired ranges -- and number of points, internally using mesh. -- --
--   > let f x y = cos (x + y) 
--   > splot f (0,pi) (0,2*pi) 50    
--   
splot :: (Matrix Double -> Matrix Double -> Matrix Double) -> (Double, Double) -> (Double, Double) -> Int -> IO () -- | Draws a 3D surface representation of a real matrix. -- --
--   > mesh (hilb 20)
--   
-- -- In certain versions you can interactively rotate the graphic using the -- mouse. mesh :: Matrix Double -> IO () mesh' :: Matrix Double -> IO () -- | From vectors x and y, it generates a pair of matrices to be used as x -- and y arguments for matrix functions. meshdom :: Vector Double -> Vector Double -> (Matrix Double, Matrix Double) -- | writes a matrix to pgm image file matrixToPGM :: Matrix Double -> String -- | imshow shows a representation of a matrix as a gray level image using -- ImageMagick's display. imshow :: Matrix Double -> IO () gnuplotX :: String -> IO ()