-
- Notifications
You must be signed in to change notification settings - Fork 359
Split-op in Haskell #357
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
leios merged 13 commits into algorithm-archivists:master from jiegillet:haskell-split-op Sep 28, 2018
Merged
Split-op in Haskell #357
Changes from all commits
Commits
Show all changes
13 commits Select commit Hold shift + click to select a range
14ef77e
Added split-op in Haskell.
jiegillet 0417e66
Changed contributors? Not sure
jiegillet de4efb3
merge conflicts
jiegillet d3db55a
Included code to chapter
jiegillet 5f65836
Update all julia code to V1.0 (#389)
leios 844fe44
Verlet integration in Fortran90 (#364)
depate 6b79ffe
Euclidean's algorithm in Fortran90 (#369)
depate 8d8ffe4
merging to other computer
jiegillet c8ba5a6
Cleaned up code
jiegillet c0a8f7b
Undid change to CONTTRIBUTORS.md
jiegillet 98d0dba
Moved gnuplot script to own folder and updated instructions to use it
jiegillet 2a4fee6
Removed old plot script
jiegillet 18bba42
Changed import lines
jiegillet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -65,5 +65,4 @@ Trashtalk | |
Cyrus Burt | ||
<br> | ||
Patrik Tesarik | ||
<br> | ||
| ||
<br> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -138,7 +138,7 @@ | |
}, | ||
{ | ||
"lang": "f90", | ||
"name": "Fortran" | ||
"name": "Fortran90" | ||
} | ||
] | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
INTEGER FUNCTION euclid_sub(a, b) | ||
IMPLICIT NONE | ||
INTEGER, INTENT(INOUT) :: a, b | ||
| ||
a = ABS(a) | ||
b = ABS(b) | ||
| ||
DO WHILE (a /= b) | ||
| ||
IF (a > b) THEN | ||
a = a - b | ||
ELSE | ||
b = b - a | ||
END IF | ||
END DO | ||
| ||
euclid_sub = a | ||
| ||
END FUNCTION euclid_sub | ||
| ||
INTEGER FUNCTION euclid_mod(a, b) | ||
IMPLICIT NONE | ||
INTEGER, INTENT(INOUT) :: a, b | ||
INTEGER :: temp | ||
| ||
DO WHILE (b > 0) | ||
temp = b | ||
b = MODULO(a,b) | ||
a = temp | ||
END DO | ||
| ||
euclid_mod = a | ||
| ||
END FUNCTION euclid_mod | ||
| ||
PROGRAM euclidean | ||
| ||
IMPLICIT NONE | ||
INTEGER :: a, b, euclid_sub, euclid_mod | ||
| ||
a = 24 | ||
b = 27 | ||
WRITE(*,*) 'Subtraction method: GCD is: ', euclid_sub(a, b) | ||
| ||
a = 24 | ||
b = 27 | ||
WRITE(*,*) 'Modulus method: GCD is: ', euclid_mod(a, b) | ||
| ||
END PROGRAM euclidean |
60 changes: 60 additions & 0 deletions 60 contents/euclidean_algorithm/code/fortran/interactive_euclidean.f90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
INTEGER FUNCTION euclid_sub(a, b) | ||
IMPLICIT NONE | ||
INTEGER, INTENT(INOUT) :: a, b | ||
| ||
| ||
a = ABS(a) | ||
b = ABS(b) | ||
| ||
DO WHILE (a /= b) | ||
| ||
IF (a > b) THEN | ||
a = a - b | ||
ELSE | ||
b = b - a | ||
END IF | ||
END DO | ||
| ||
euclid_sub = a | ||
END FUNCTION euclid_sub | ||
| ||
INTEGER FUNCTION euclid_mod(a, b) | ||
IMPLICIT NONE | ||
INTEGER, INTENT(INOUT) :: a, b | ||
INTEGER :: temp | ||
| ||
| ||
DO WHILE (b > 0) | ||
temp = b | ||
b = MODULO(a,b) | ||
a = temp | ||
END DO | ||
| ||
euclid_mod = a | ||
| ||
END FUNCTION euclid_mod | ||
| ||
PROGRAM euclidean | ||
| ||
IMPLICIT NONE | ||
INTEGER :: a, b, euclid_sub, euclid_mod, temp_a, temp_b, ioerror | ||
| ||
DO | ||
WRITE(*,*) 'Calculate greatest common divisor. Give two integers:' | ||
READ(*, '(i10)', iostat=ioerror) temp_a, temp_b | ||
| ||
IF (ioerror == 0) THEN | ||
EXIT | ||
END IF | ||
| ||
WRITE(*,*) 'Entered numbers are not integers. Try again.' | ||
END DO | ||
| ||
a = temp_a | ||
b = temp_b | ||
WRITE(*,*) 'Subtraction method: GCD is: ', euclid_sub(a, b) | ||
| ||
a = temp_a | ||
b = temp_b | ||
WRITE(*,*) 'Modulus method: GCD is: ', euclid_mod(a, b) | ||
END PROGRAM euclidean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Data.Array.CArray | ||
import Data.Complex | ||
import Math.FFT (dft, idft) -- Binding to fftw | ||
| ||
type Vector = CArray Int (Complex Double) | ||
| ||
calculateEnergy :: Double -> Vector -> Vector -> Vector -> Double | ||
calculateEnergy dx kin pot wfc = (* dx) . sum . map realPart $ elems total | ||
where | ||
total = liftArray2 (+) kineticE potentialE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, | ||
potentialE = wfcConj .* pot .* wfc | ||
kineticE = wfcConj .* idft (kin .* dft wfc) | ||
wfcConj = liftArray conjugate wfc | ||
a .* b = liftArray2 (*) a b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions 24 contents/split-operator_method/code/gnuplot/plot_output.plt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# use like: gnuplot -e "folder='/path/to/data/directory'" plot_output.plt | ||
| ||
set terminal gif animate delay 10 | ||
set output folder.'/wavefunction.gif' | ||
| ||
set key off | ||
| ||
set xrange [-10:10] | ||
set yrange [0:1] | ||
set y2range [0:50] | ||
| ||
set ytics nomirror autofreq tc lt 1 | ||
set ylabel 'Psi(x)' tc lt 1 | ||
| ||
set y2tics nomirror autofreq tc lt 2 | ||
set y2label 'V(x)' tc lt 2 | ||
| ||
list = system('ls '.folder.'/output*.dat') | ||
| ||
do for [file in list] { | ||
plot file u 1:2 smooth csplines, \ | ||
file u 1:3 smooth csplines axes x1y2 | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require special build instructions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing the Haskell package is nothing special if I recall correctly, installing
fftw3
is more involved, but you'd need to do that anyway.