symmetry-operations-symbols 0.0.1.0 → 0.0.1.1
raw patch · 7 files changed
+26/−19 lines, 7 filesdep ~base
Dependency ranges changed: base
Files
- README.md +3/−3
- src/Data/Matrix/SymmetryOperationsSymbols.hs +9/−2
- src/Data/Matrix/SymmetryOperationsSymbols/Common.hs +3/−3
- src/Data/Matrix/SymmetryOperationsSymbols/GlideOrReflectionCase.hs +2/−2
- src/Data/Matrix/SymmetryOperationsSymbols/RotInversionCase.hs +4/−4
- src/Data/Matrix/SymmetryOperationsSymbols/RotationCase.hs +2/−2
- symmetry-operations-symbols.cabal +3/−3
README.md view
@@ -7,8 +7,8 @@ Make new stack project and move to project directory. ```shell-% stack new symop_repl-% cd symop_repl+% stack new symopRepl+% cd symopRepl ``` Edit extra-deps part of stack.yaml like below.@@ -16,7 +16,7 @@ ``` extra-deps: - matrix-as-xyz-0.1.1.1-- symmetry-operations-symbols-0.0.1.0+- symmetry-operations-symbols-0.0.1.1 ``` Then start repl.
src/Data/Matrix/SymmetryOperationsSymbols.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE FlexibleInstances #-}+ {-| Module : SymmetryOperationsSymbols Copyright : (c) Jun Narumi, 2018@@ -44,6 +46,11 @@ -- for doctest import Data.Matrix.AsXYZ +import qualified Control.Monad.Fail as Fail++instance Fail.MonadFail (Either String) where+ fail = Left+ -- | Derivation of geometric representation of symmetry operations from given matrix of symmetry operations -- -- jpn) 与えられた対称操作の行列から、対称操作の幾何的表現を導出@@ -63,14 +70,14 @@ -- -- jpn) 与えられた対称操作の行列から、対称操作の幾何的表現を導出 ---fromMatrix' :: (Monad m, Integral a) => Matrix (Ratio a) -> m String+fromMatrix' :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m String fromMatrix' m = showSymmetryOperation <$> fromMatrix'' m -- | Derivation of geometric representation of symmetry operations from given matrix of symmetry operations -- -- jpn) 与えられた対称操作の行列から、対称操作の幾何的表現を導出 ---fromMatrix'' :: (Monad m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a)+fromMatrix'' :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a) fromMatrix'' m -- (i) | rotPart m == identity 3 = unitMatrixCase m
src/Data/Matrix/SymmetryOperationsSymbols/Common.hs view
@@ -142,7 +142,7 @@ type MatrixLookupRecord a = ((Symbol,Sense,Matrix (Ratio a)),TransformedCoordinate) -lookupMatrixM :: Monad m => Integral a => String -> [MatrixLookupRecord a] -> SymbolSenseVectorOrientation -> m TransformedCoordinate+lookupMatrixM :: (Monad m, MonadFail m) => Integral a => String -> [MatrixLookupRecord a] -> SymbolSenseVectorOrientation -> m TransformedCoordinate lookupMatrixM reason dataTable (sy,se,_,el) = case lookupSSVO (primeSymbol sy, se, el) dataTable of Nothing -> fail reason@@ -151,10 +151,10 @@ lookupSSVO :: (Integral a) => (Symbol,String,String) -> [MatrixLookupRecord a] -> Maybe TransformedCoordinate lookupSSVO (sym, sen, axis) d = lookup (sym, sen, rotPart . fromXYZ'' $ axis) d -properMatrixW :: Monad m => SymbolSenseVectorOrientation -> m TransformedCoordinate+properMatrixW :: (Monad m, MonadFail m) => SymbolSenseVectorOrientation -> m TransformedCoordinate properMatrixW = lookupMatrixM "matrix W not found (proper)." (fromTbl properTbl) -hexagonalMatrixW :: Monad m => SymbolSenseVectorOrientation -> m TransformedCoordinate+hexagonalMatrixW :: (Monad m, MonadFail m) => SymbolSenseVectorOrientation -> m TransformedCoordinate hexagonalMatrixW = lookupMatrixM "matrix W not found (hexagonal)." (fromTbl hexagonalTbl) fromTbl :: (Integral a) => [Tbl] -> [MatrixLookupRecord a]
src/Data/Matrix/SymmetryOperationsSymbols/GlideOrReflectionCase.hs view
@@ -28,7 +28,7 @@ import qualified Data.Matrix.SymmetryOperationsSymbols.SymmetryOperation as S -- | Case (ii) (c) W corresponds to a (glide) reflection-glideOrReflectionCase :: (Monad m, Integral a) => Matrix (Ratio a) -> m (S.SymmetryOperation a)+glideOrReflectionCase :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m (S.SymmetryOperation a) glideOrReflectionCase m = arrange m <$> solvingEquation m arrange :: Integral a => Matrix (Ratio a) -> [Ratio a] -> S.SymmetryOperation a@@ -74,7 +74,7 @@ solvingEquation'' :: Integral a => Matrix (Ratio a) -> Maybe [Ratio a] solvingEquation'' mat = adjustAnswerOnPlane mat . toList =<< solvingEquation' mat -solvingEquation :: (Monad m, Integral a) => Matrix (Ratio a) -> m [Ratio a]+solvingEquation :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m [Ratio a] solvingEquation mat = case solvingEquation'' mat of Nothing -> fail "<GlideOrReflection> when calculate equation solve." Just a -> return a
src/Data/Matrix/SymmetryOperationsSymbols/RotInversionCase.hs view
@@ -27,10 +27,10 @@ import Data.Matrix.SymmetryOperationsSymbols.SymmetryOperation -- | Case (ii) (b) W corresponds to an n-fold rotation-rotInversionCase :: (Monad m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a)+rotInversionCase :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a) rotInversionCase m = arrange m <$> calc m -calc :: (Monad m, Integral a) => Matrix (Ratio a) -> m ([Ratio a], Matrix (Ratio a)) +calc :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m ([Ratio a], Matrix (Ratio a)) calc m = (,) <$> solvingEquation2 m <*> solvingEquation1 m arrange :: Integral a => Matrix (Ratio a) -> ([Ratio a], Matrix (Ratio a)) -> SymmetryOperation a@@ -74,7 +74,7 @@ wl mat = elementwise (+) (wg mat) (transPart mat) -- (ii) (a) solving equation (W,w)x = x-solvingEquation1 :: (Monad m, Integral a) => Matrix (Ratio a) -> m (Matrix (Ratio a))+solvingEquation1 :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m (Matrix (Ratio a)) solvingEquation1 mat = case solvingEquation1' mat of Nothing -> fail "<RotInv> when calculate equation (W,w)x = x" Just a -> return a@@ -89,7 +89,7 @@ pow2 m = multStd m m w2 = pow2 (rotPart mat) -solvingEquation2 :: (Monad m, Integral a) => Matrix (Ratio a) -> m [Ratio a]+solvingEquation2 :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m [Ratio a] solvingEquation2 mat = case result of Nothing -> fail "<RotInv> when calculate equation (W,w)^2 x = x." Just a -> return a
src/Data/Matrix/SymmetryOperationsSymbols/RotationCase.hs view
@@ -26,7 +26,7 @@ import Data.Matrix.SymmetryOperationsSymbols.SymmetryOperation -- | Case (ii) (a) W corresponds to a rotoinversion-nFoldRotationCase :: (Monad m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a)+nFoldRotationCase :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m (SymmetryOperation a) nFoldRotationCase m = arrange m <$> solvingEquation m arrange :: Integral a => Matrix (Ratio a) -> [Ratio a] -> SymmetryOperation a@@ -96,7 +96,7 @@ sol <- solvingEquation' mat adjustAnswerOnAxis mat (toList sol) -solvingEquation :: (Monad m, Integral a) => Matrix (Ratio a) -> m [Ratio a]+solvingEquation :: (Monad m, MonadFail m, Integral a) => Matrix (Ratio a) -> m [Ratio a] solvingEquation mat = case solvingEquation'' mat of Nothing -> fail "<Rot> when calculate equation." Just a -> return a
symmetry-operations-symbols.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 8170db758d9c19597a873ee575a9fbd3488934fea1490a2aa0bff05baeb67c03+-- hash: eeffc2b8d8d697ad118301d03222b4a08c17c39810fe01ee86e9abd9b3d67dbb name: symmetry-operations-symbols-version: 0.0.1.0+version: 0.0.1.1 description: Please see the README on GitHub at <https://github.com/narumij/symmetry-operations-symbols#readme> homepage: https://github.com/narumij/symmetry-operations-symbols#readme bug-reports: https://github.com/narumij/symmetry-operations-symbols/issues