numeric-quest 0.1.1.3 → 0.2
raw patch · 4 files changed
+20/−42 lines, 4 files
Files
- Orthogonals.lhs +15/−29
- QuantumVector.lhs +1/−1
- Roots.hs +2/−10
- numeric-quest.cabal +2/−2
Orthogonals.lhs view
@@ -304,7 +304,7 @@ by some algorithms. So far we have been able to avoid this. <pre> -> class Scalar a where+> class Eq a => Scalar a where > coupled :: a->a > norm :: [a] -> a > almostZero :: a -> Bool@@ -317,10 +317,10 @@ > scaled = scaled' > instance Scalar Float where-> coupled x = x-> norm u = sqrt (bra_ket u u)-> almostZero x = (abs x) < 1.0e-8-> scaled = scaled'+> coupled x = x+> norm u = sqrt (bra_ket u u)+> almostZero x = (abs x) < 1.0e-8+> scaled = scaled' > instance (Integral a) => Scalar (Ratio a) where > coupled x = x@@ -380,15 +380,11 @@ > normalized :: (Scalar a, Fractional a) => [a] -> [a] > normalized u =-> [uk/n | uk <- u]-> where-> n = norm u+> map (/norm u) u > scaled' :: (Fractional t, Ord t) => [t] -> [t] > scaled' u =-> [uk/um | uk <- u]-> where-> um = maximum [abs uk| uk <- u]+> map (/norminf u) u </pre> <hr>@@ -783,7 +779,7 @@ <pre> -> one_ket_solution :: (Fractional a, Scalar a) => [[a]] -> [a] -> [a]+> one_ket_solution :: (Scalar a, Fractional a) => [[a]] -> [a] -> [a] > one_ket_solution a b = > -- > -- List representing vector |x>, which is@@ -951,7 +947,7 @@ <pre> -> factors_QR :: (Fractional a, Scalar a) => [[a]] -> ([[a]],[[a]])+> factors_QR :: (Scalar a, Fractional a) => [[a]] -> ([[a]],[[a]]) > factors_QR a = > -- > -- A pair of matrices (Q, R), such that@@ -979,7 +975,7 @@ <pre> -> determinant :: (Fractional a, Scalar a) => [[a]] -> a+> determinant :: (Scalar a, Fractional a) => [[a]] -> a > determinant a = > let (q,r) = factors_QR a > -- matrix Q is not normed so we have to respect the norms of its rows@@ -1188,7 +1184,7 @@ <pre> -> similar_to :: (Fractional a, Scalar a) => [[a]] -> [[a]]+> similar_to :: (Scalar a, Fractional a) => [[a]] -> [[a]] > similar_to a = > -- > -- List of columns of matrix A1 similar to A@@ -1201,7 +1197,7 @@ > where > (q,r) = factors_QR a -> iterated_eigenvalues :: (Scalar a1, Fractional a1, Num a) => [[a1]] -> a -> [[a1]]+> iterated_eigenvalues :: (Scalar a1, Fractional a1, Eq a, Num a) => [[a1]] -> a -> [[a1]] > iterated_eigenvalues a n > -- > -- List of vectors representing@@ -1215,7 +1211,7 @@ > | otherwise = (diagonals a) > : iterated_eigenvalues (similar_to a) (n-1) -> eigenvalues :: (Scalar a1, Fractional a1, Num a) => [[a1]] -> a -> [a1]+> eigenvalues :: (Scalar a1, Fractional a1, Eq a, Num a) => [[a1]] -> a -> [a1] > eigenvalues a n > -- > -- Eigenvalues of matrix A@@ -1789,24 +1785,14 @@ > -- > -- Unit square matrix of with dimensions m x m > ---> [g 0 k | k <- [0..(m-1)]]-> where-> g i k-> | i == m = []-> | i == k = 1:(g (i+1) k)-> | otherwise = 0:(g (i+1) k)->+> [ [ if j==k then 1 else 0 | j <- [0 .. m-1] ] | k <- [0 .. m-1]] > unit_vector :: Num a => Int -> Int -> [a] > unit_vector i m = > -- > -- Unit vector of length m > -- with 1 at position i, zero otherwise-> [g i k| k <- [0..(m-1)]]-> where-> g j k-> | j == k = 1-> | otherwise = 0+> map (\k -> if k==i then 1 else 0) [0 .. m-1] > diagonals :: [[a]] -> [a] > diagonals a =
QuantumVector.lhs view
@@ -1129,7 +1129,7 @@ > showsPrec n (j :<+ k) = showsPrec n j . showString " + " . showsPrec n k -> showsScalar :: (RealFloat t) => Int -> Complex t -> String -> String+> showsScalar :: (Show t, RealFloat t) => Int -> Complex t -> String -> String > showsScalar n x@(a :+ b) > | b == 0 = showsPrec n a . showString " " > | otherwise = showString "(" .showsPrec n x . showString ") "
Roots.hs view
@@ -77,20 +77,12 @@ u y a b = a + b*y polynomial_derivative :: Num a => [a] -> [a]-polynomial_derivative as+polynomial_derivative as = -- -- List of coefficients for derivative of polynomial -- a0 + a1 x + a2 x^2 ... --- | as == [] = []- | otherwise = deriv 1 (drop 1 as) []- where- deriv n bs cs- | bs == [] = reverse2 cs- | otherwise = deriv (n+1) (tail bs) ((n*(head bs)):cs)- reverse2 cs- | cs == [] = []- | otherwise = reverse cs+ zipWith (*) (iterate (1+) 1) (drop 1 as) ----------------------------------------------------------------------------- --
numeric-quest.cabal view
@@ -1,5 +1,5 @@ Name: numeric-quest-Version: 0.1.1.3+Version: 0.2 License: GPL License-File: LICENSE Author: Jan Skibinski@@ -17,7 +17,7 @@ README Source-Repository this- Tag: 0.1.1.3+ Tag: 0.2 Type: darcs Location: http://code.haskell.org/~thielema/numeric-quest/