module Data.Tensor.TypeLevel.Axis
(dimension, next, prev, all, allFrom, others, fromVector)
where
import Data.Tensor.TypeLevel hiding (dimension)
import qualified Data.Tensor.TypeLevel as T (dimension)
import Prelude hiding (all)
dimension :: (Vector v) => Axis v -> Int
dimension axis = T.dimension $ compose (\axis' -> [axis, axis'])
next :: (Vector v) => Axis v -> Axis v
next axis = Axis $ (axisIndex axis + 1) `mod` dimension axis
prev :: (Vector v) => Axis v -> Axis v
prev axis = Axis $ (axisIndex axis 1) `mod` dimension axis
all :: (Vector v) => Axis v -> [Axis v]
all axis = let dim = dimension axis in
map head [[Axis i, axis] | i<-[0..dim1]]
allFrom :: (Vector v) => Axis v -> [Axis v]
allFrom axis = let dim = dimension axis in
map head [[Axis $ (axisIndex axis+i) `mod` dim, axis] | i<-[0..dim1]]
others :: (Vector v) => Axis v -> [Axis v]
others axis = let dim = dimension axis in
map head [[Axis $ (axisIndex axis+i) `mod` dim, axis] | i<-[1..dim1]]
fromVector :: (Vector v) => v a -> [Axis v]
fromVector x = let dim = T.dimension x in [Axis i | i<-[0..dim1]]