Skip to content

Commit

Permalink
fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Nov 13, 2023
1 parent 494fb73 commit 23b856a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Diagrams/Core/Transform.hs
Expand Up @@ -6,10 +6,9 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-----------------------------------------------------------------------------
{-# OPTIONS_GHC -fno-warn-unused-imports #-}

-- |
-- Module : Diagrams.Core.Transform
-- Copyright : (c) 2011-2015 diagrams-core team (see LICENSE)
Expand Down Expand Up @@ -232,21 +231,20 @@ onBasis (Transformation (f :-: _) _ t) = (map f basis, t)

-- Remove the nth element from a list
remove :: Int -> [a] -> [a]
remove n xs = ys ++ tail zs
remove n xs = ys ++ zs
where
(ys, zs) = splitAt n xs
(ys, _ : zs) = splitAt n xs

-- Minor matrix of cofactore C(i,j)
-- Minor matrix of cofactor C(i,j)
minor :: Int -> Int -> [[a]] -> [[a]]
minor i j xs = remove j $ map (remove i) xs

-- The determinant of a square matrix represented as a list of lists
-- representing column vectors, that is [column].
det :: Num a => [[a]] -> a
det (a:[]) = head a
det m = sum [(-1)^i * (c1 !! i) * det (minor i 0 m) | i <- [0 .. (n-1)]]
det [a : _] = a
det m@(c1 : _) = sum [(-1) ^ i * (c1 !! i) * det (minor i 0 m) | i <- [0 .. (n - 1)]]
where
c1 = head m
n = length m

-- | Convert a vector v to a list of scalars.
Expand Down

0 comments on commit 23b856a

Please sign in to comment.