Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cycles.Maxcy
- convIndivCycle :: (Integral a, Bits a) => [[a]] -> [a] -> [(Bool, a)]
- aVarList :: (Integral a, Bits a, Integral b, Bits b) => [[(Bool, a)]] -> a -> [b]
- bVarList :: (Integral a, Bits a) => [[(Bool, a)]] -> a -> [a]
- cVarList :: (Integral a, Bits a) => [a] -> [a] -> [a]
- dVarList :: (Integral a, Bits a) => [a] -> [a] -> [a]
- listToULL :: [Int] -> CULLong
- listToULLs :: [Int] -> [CULLong]
- listFirstAnd :: [[CULLong]] -> [[CULLong]] -> [[CULLong]] -> [[CULLong]]
- sndMap2 :: [[(a, b)]] -> [[b]]
- maxPositive :: (Ord a, Num a) => [a] -> a
- maxPositiveSnd :: (Num a, Ord b, Num b) => [(a, b)] -> (a, b)
- listsMaxPositive :: (Ord a, Num a) => [[a]] -> a
- tallyElem :: Eq a => [[a]] -> a -> Int
- aMostOftenElem :: [[(a, Int)]] -> Int
- switchInTupLists :: [[(a, Int)]] -> Int -> Int -> [[(a, Int)]]
- frontLoadTupLists :: [[(a, Int)]] -> [[(a, Int)]]
- trimCycleList :: [[(Bool, Int)]] -> [[(Bool, Int)]]
- addLLUs :: [[CULLong]] -> String
- generateMaxCyCode :: [[Int]] -> [[Int]] -> Int -> Int -> Int -> String -> (String, String)
- generateMaxCyCodeAtStart :: [[Int]] -> [[Int]] -> Int -> Int -> String -> (Int -> String, String)
- makeAsmCounter4 :: Int -> String
- makeAsmCounter2 :: Int -> String
- makeAsmCounter1 :: Int -> String
- makeAsmCounterN :: Int -> String
- makeAsmCounter :: Int -> String
- listFromULL :: CULLong -> String
- printULLs :: [[CULLong]] -> String
- sortBySnd :: Ord b => [(a, b)] -> [(a, b)]
Documentation
convIndivCycle :: (Integral a, Bits a) => [[a]] -> [a] -> [(Bool, a)]
elist
is edge list and vlist is cycle vertex list
aVarList :: (Integral a, Bits a, Integral b, Bits b) => [[(Bool, a)]] -> a -> [b]
aVarList is a[var][j]
listToULL
converts a length <= 64 list of 0,1 values into a single CULLong
listToULL :: Integral a => [a] -> CULLong
listToULL list = if length list > 64
then error "You want to use listToULLs for this (You're using listToULL)."
else foldl' (.|.) 0 (zipWith (x y -> if x == 0 then 0 else bit y) (padMod list 0 64) [0..])
listToULLs :: [Int] -> [CULLong]
listToULLs
converts a list of length > 64 to a list of CULLong
values
listToULLs :: Integral a => [a] -> [CULLong]
listFirstAnd :: [[CULLong]] -> [[CULLong]] -> [[CULLong]] -> [[CULLong]]
listFirstAnd
replaces a!!0 with b!!0 .&. c!!0
sndMap2 :: [[(a, b)]] -> [[b]]
This function maps snd to the second level of a list of lists
maxPositive :: (Ord a, Num a) => [a] -> a
This function gives the largest element of a list greater than '0', or zero if all the elements are negative
maxPositiveSnd :: (Num a, Ord b, Num b) => [(a, b)] -> (a, b)
This function gives the tuple in a list that has the greates positive snd element
listsMaxPositive :: (Ord a, Num a) => [[a]] -> a
This function gives the maxPositive for a list of lists
aMostOftenElem :: [[(a, Int)]] -> Int
This function finds some most commonly occuring snd element in a list of lists
switchInTupLists :: [[(a, Int)]] -> Int -> Int -> [[(a, Int)]]
This function takes a list of lists of tuples and switches all occurances of a
with b
and all occurances of b
with a
.
frontLoadTupLists :: [[(a, Int)]] -> [[(a, Int)]]
This function makes sure that '0' is a most often snd element in a list of lists
trimCycleList :: [[(Bool, Int)]] -> [[(Bool, Int)]]
This function deletes the cycles which will be nulled out by the first edge being zero, i.e. it deletes cycles made impossible by fixing the 0th edge forward. Additionally, this function re-frontloads the lists so that more maxcy orientations "may" be found more quickly, reducing the need to print cycles. (True, _) if edge is forward in cycle, blist[][] = 0 (is how it's shown to be forward)
generateMaxCyCode :: [[Int]] -> [[Int]] -> Int -> Int -> Int -> String -> (String, String)
This function is a version of generateMaxCyCodeAtStart
that is cross-compatible with the previous way of generating the C code to find the maximally cyclic orientations of a graph
generateMaxCyCodeAtStart :: [[Int]] -> [[Int]] -> Int -> Int -> String -> (Int -> String, String)
This function creates a function which may be mapped to a start value (to reduce overhead in splitting up the files) to produce C code. These C code files may be compiled to produce independent programs, able to be run in parallel or even on seperate machines with different architectures. Assuming variables are unlimited width for the purposes of explaining the logic: (1 is true, 0 is false) (i is the variable index, j is the digit index)
a[i][j] := is the ith edge in the jth cycle?
b[i][j] := is the ith edge backward in the jth cycle? (forward is [x,y] -> x<y )
c[i][j] := ~a[i][j] | ~b[i][j]
d[i][j] := ~a[i][j] | b[i][j]
A[i][j] := (up to and inc. the ith var/edge) is it still possible that this digraph has the jth cycle?
A[0][j] := 1 if j < number of cycles
y[i][j] := is ith edge backward? (so 0 is forward, 1 is backward)
A[i][j] := A[i-1][j] & (~y[j] | c[i][j]) & (y[j] | d[i][j]
makeAsmCounter4 :: Int -> String
This generates the inline assembly for the popcount of four 64-bit unsigned integers
makeAsmCounter2 :: Int -> String
This generates the inline assembly for the popcount of two 64-bit unsigned integers
makeAsmCounter1 :: Int -> String
This generates the inline assembly for the popcount of one 64-bit unsigned integer
makeAsmCounterN :: Int -> String
This generates the inline assembly for the popcount of arbitrarily many 64-bit unsigned integers
makeAsmCounter :: Int -> String
This generates the C code for a function utilizing inline assembly to find the total popcount of a length n
uint64_t buffer
listFromULL :: CULLong -> String
This makes a CULLong into a more or less readable string for debugging