Hcy2c-0.1.1.0: Generate C code for cycle algorithms

Safe HaskellNone
LanguageHaskell2010

Cycles.Maxcy

Synopsis

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]

bVarList :: (Integral a, Bits a) => [[(Bool, a)]] -> a -> [a]

bVarList is b[var][j]

cVarList :: (Integral a, Bits a) => [a] -> [a] -> [a]

This combines the aVarList and bVarList lists to give the combined cVarList | Note: (1-x) == ~x for x <- [0,1]

dVarList :: (Integral a, Bits a) => [a] -> [a] -> [a]

This combines the aVarList and bVarList lists to give the combined dVarList

listToULL :: [Int] -> CULLong

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

tallyElem :: Eq a => [[a]] -> a -> Int

This function counts the number of occurances of x in 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

printULLs :: [[CULLong]] -> String

This makes a [[CULLong]] into a more or less readable string for debugging

sortBySnd :: Ord b => [(a, b)] -> [(a, b)]

This sorts a list of tuples by the snd element