Skip to content

Added Thomas Algorithm in Haskell #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2018

Conversation

jiegillet
Copy link
Member

Also corrects minor typo in the chapter.

That's a short one. @lulucca12 I think this one will be more to your liking.

@leios that chapter is a little weak on the explanation of the algorithm. In particular, I don't get "In particular, we need to find an optimal scale factor for each row and use that.". Also you write down the formula for the forward step, but you don't explicit the back substitution (sure, it's similar to the gaussian elimination but the result is so simple...). I know that you have many things to do. Would you be OK with me fleshing it out a bit? (In another PR this time!!)

@jiegillet jiegillet added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Aug 1, 2018
@leios
Copy link
Member

leios commented Aug 1, 2018

@jiegillet yeah, please feel free to update the text here (in a separate PR). This one could definitely use some help.

@lulucca12
Copy link
Contributor

Couldn't you separate the forward and back functions? On the other languages, they are in different blocks of code. And why Data.Ratio, I do not really know what it does but it doesn't make sense for me.

@jiegillet
Copy link
Member Author

Data.Ratio is not part of the algorithm, it's just part of the test in main. Ratio Int is a type that keeps track of fractional numbers with Ints and reduces them. For example if you compute 4/8 as a Double, you will get 0.5 but as Ratio Int it will be 1 % 2 (where the % is the fraction sign). It's really neat. This way, after the algorithm we get a result in fractions and not as real numbers. But it's not necessary, if you ommit the :: [Ration Int] everything will be treated as Double. Polymorphism for the win :)

forward and back are not separated? They are defined separately inside ofthomas. They don't really make sense outside of that function.

@lulucca12
Copy link
Contributor

Cool way to represent fractions, I didn't think of that. And in other programming languages forward and back are different 'for loops' for example and here they are all bounded to the same function. But I think it makes more sense on the way that you did. I've seen that the functions that combine

tail . scanl

and

init . scanr

don't exist like

let scanl2 f xs = tail $ scanl f 0 xs
let scanr2 f xs = init $ scanr f 0 xs

in Data.List because they could shorten your code.

I wouldn't like defining them here, it would be unnecessary.

@jiegillet
Copy link
Member Author

jiegillet commented Aug 2, 2018

I'm glad you like my code ^^
Could you add a review so we can merge it?

EDIT: I'm sorry, I thought you could actually review code, but it's seems its not the case (yet).

Copy link
Member

@leios leios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems readable and lulucca seems to be alright with the notation, so I'll approve it.

@jiegillet jiegillet merged commit 43437da into algorithm-archivists:master Aug 3, 2018
@jiegillet jiegillet deleted the thomas-haskell branch August 4, 2018 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants