Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,32 @@
import Data.List (transpose)
(<+>)
:: Num a
=> [a] -> [a] -> [a]
(<+>) = zipWith (+)
(<*>)
:: Num a
=> [a] -> [a] -> a
(<*>) = (sum .) . zipWith (*)
newtype Mat a =
Mat [[a]]
deriving (Eq, Show)
instance Num a =>
Num (Mat a) where
negate (Mat x) = Mat $ map (map negate) x
Mat x + Mat y = Mat $ zipWith (<+>) x y
Mat x * Mat y =
Mat
[ [ xs Main.<*> ys -- Main prefix to distinguish fron applicative operator
| ys <- transpose y ]
| xs <- x ]
abs = undefined
fromInteger _ = undefined -- don't know dimension of the desired matrix
signum = undefined
-- TEST ----------------------------------------------------------------------
main :: IO ()
main = print $ Mat [[1, 2], [0, 1]] ^ 4

View file

@ -0,0 +1,11 @@
import Numeric.LinearAlgebra
a :: Matrix I
a = (2><2)
[1,2
,0,1]
main = do
print $ a^4
putStrLn "power of zero: "
print $ a^0