Skip to content

Use [#]\n instead of [#] for human readable output #873

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contents/verlet_integration/code/asm-x64/verlet.s
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
zero: .double 0.0
two: .double 2.0
half: .double 0.5
verlet_fmt: .string "[#] Time for Verlet integration is:\n%lf\n"
stormer_fmt: .string "[#] Time for Stormer Verlet Integration is:\n%lf\n[#] Velocity for Stormer Verlet Integration is:\n%lf\n"
velocity_fmt: .string "[#] Time for Velocity Verlet Integration is:\n%lf\n[#] Velocity for Velocity Verlet Integration is:\n%lf\n"
verlet_fmt: .string "[#]\nTime for Verlet integration is:\n%lf\n"
stormer_fmt: .string "[#]\nTime for Stormer Verlet Integration is:\n%lf\n[#]\nVelocity for Stormer Verlet Integration is:\n%lf\n"
velocity_fmt: .string "[#]\nTime for Velocity Verlet Integration is:\n%lf\n[#]\nVelocity for Velocity Verlet Integration is:\n%lf\n"
pos: .double 5.0
acc: .double -10.0
dt: .double 0.01
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/c++/verlet.cpp
Original file line number Diff line number Diff line change
@@ -64,19 +64,19 @@ int main() {
// each of these functions.

double time = verlet(5.0, -10, 0.01);
std::cout << "[#] Time for Verlet integration is:\n" \
std::cout << "[#]\nTime for Verlet integration is:\n" \
<< time << std::endl;

timestep timestep_sv = stormer_verlet(5.0, -10, 0.01);
std::cout << "[#] Time for Stormer Verlet integration is:\n" \
std::cout << "[#]\nTime for Stormer Verlet integration is:\n" \
<< timestep_sv.time << std::endl;
std::cout << "[#] Velocity for Stormer Verlet integration is:\n" \
std::cout << "[#]\nVelocity for Stormer Verlet integration is:\n" \
<< timestep_sv.vel << std::endl;

timestep timestep_vv = velocity_verlet(5.0, -10, 0.01);
std::cout << "[#] Time for velocity Verlet integration is:\n" \
std::cout << "[#]\nTime for velocity Verlet integration is:\n" \
<< timestep_vv.time << std::endl;
std::cout << "[#] Velocity for velocity Verlet integration is:\n" \
std::cout << "[#]\nVelocity for velocity Verlet integration is:\n" \
<< timestep_vv.vel << std::endl;

return 0;
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/c/verlet.c
Original file line number Diff line number Diff line change
@@ -46,19 +46,19 @@ int main() {
double time, vel;

verlet(&time, 5.0, -10, 0.01);
printf("[#] Time for Verlet integration is:\n");
printf("[#]\nTime for Verlet integration is:\n");
printf("%lf\n", time);

stormer_verlet(&time, &vel, 5.0, -10, 0.01);
printf("[#] Time for Stormer Verlet integration is:\n");
printf("[#]\nTime for Stormer Verlet integration is:\n");
printf("%lf\n", time);
printf("[#] Velocity for Stormer Verlet integration is:\n");
printf("[#]\nVelocity for Stormer Verlet integration is:\n");
printf("%lf\n", vel);

velocity_verlet(&time, &vel, 5.0, -10, 0.01);
printf("[#] Time for velocity Verlet integration is:\n");
printf("[#]\nTime for velocity Verlet integration is:\n");
printf("%lf\n", time);
printf("[#] Velocity for Stormer Verlet integration is:\n");
printf("[#]\nVelocity for Stormer Verlet integration is:\n");
printf("%lf\n", vel);

return 0;
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/clisp/verlet.lisp
Original file line number Diff line number Diff line change
@@ -34,17 +34,17 @@
while (> p 0)
finally (return (list time vel))))

(format T "[#] Time for Verlet integration:~%")
(format T "[#]~%Time for Verlet integration:~%")
(format T "~d~%" (verlet 5 -10 0.01))

(defvar stormer-verlet-result (stormer-verlet 5 -10 0.01))
(format T "[#] Time for Stormer Verlet integration is:~%")
(format T "[#]~%Time for Stormer Verlet integration is:~%")
(format T "~d~%" (first stormer-verlet-result))
(format T "[#] Velocity for Stormer Verlet integration is:~%")
(format T "[#]~%Velocity for Stormer Verlet integration is:~%")
(format T "~d~%" (second stormer-verlet-result))

(defvar velocity-verlet-result (velocity-verlet 5 -10 0.01))
(format T "[#] Time for velocity Verlet integration is:~%")
(format T "[#]~%Time for velocity Verlet integration is:~%")
(format T "~d~%" (first velocity-verlet-result))
(format T "[#] Velocity for velocity Verlet integration is:~%")
(format T "[#]~%Velocity for velocity Verlet integration is:~%")
(format T "~d~%" (second velocity-verlet-result))
15 changes: 10 additions & 5 deletions contents/verlet_integration/code/fortran/verlet.f90
Original file line number Diff line number Diff line change
@@ -91,16 +91,19 @@ SUBROUTINE velocity_verlet(pos, acc, dt, time, vel)
! Verlet
CALL verlet(pos, acc, dt, time)

WRITE(*,*) '[#] Time for Verlet integration:'
WRITE(*,*) '[#]'
WRITE(*,*) 'Time for Verlet integration:'
WRITE(*,*) time

! stormer Verlet
pos = 5d0
CALL stormer_verlet(pos, acc, dt, time, vel)

WRITE(*,*) '[#] Time for Stormer Verlet integration:'
WRITE(*,*) '[#]'
WRITE(*,*) 'Time for Stormer Verlet integration:'
WRITE(*,*) time
WRITE(*,*) '[#] Velocity for Stormer Verlet integration:'
WRITE(*,*) '[#]'
WRITE(*,*) 'Velocity for Stormer Verlet integration:'
WRITE(*,*) vel


@@ -109,9 +112,11 @@ SUBROUTINE velocity_verlet(pos, acc, dt, time, vel)
pos = 5d0
CALL velocity_verlet(pos, acc, dt, time, vel)

WRITE(*,*) '[#] Time for velocity Verlet integration:'
WRITE(*,*) '[#]'
WRITE(*,*) 'Time for velocity Verlet integration:'
WRITE(*,*) time
WRITE(*,*) '[#] Velocity for velocity Verlet integration:'
WRITE(*,*) '[#]'
WRITE(*,*) 'Velocity for velocity Verlet integration:'
WRITE(*,*) vel

END PROGRAM verlet_integration
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/golang/verlet.go
Original file line number Diff line number Diff line change
@@ -43,18 +43,18 @@ func velocityVerlet(pos, acc, dt float64) (time, vel float64) {

func main() {
time := verlet(5., -10., .01)
fmt.Println("[#] Time for Verlet integration is:")
fmt.Println("[#]\nTime for Verlet integration is:")
fmt.Println(time)

time, vel := stormerVerlet(5., -10., .01)
fmt.Println("[#] Time for Stormer Verlet integration is:")
fmt.Println("[#]\nTime for Stormer Verlet integration is:")
fmt.Println(time)
fmt.Println("[#] Velocity for Stormer Verlet integration is:")
fmt.Println("[#]\nVelocity for Stormer Verlet integration is:")
fmt.Println(vel)

time, vel = velocityVerlet(5., -10., .01)
fmt.Println("[#] Time for velocity Verlet integration is:")
fmt.Println("[#]\nTime for velocity Verlet integration is:")
fmt.Println(time)
fmt.Println("[#] Velocity for velocity Verlet integration is:")
fmt.Println("[#]\nVelocity for velocity Verlet integration is:")
fmt.Println(vel)
}
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/haskell/verlet.hs
Original file line number Diff line number Diff line change
@@ -52,13 +52,13 @@ main = do
let (_, v, _, t) = last $ takeWhile aboveGround $ trajectory m freefall dt p0
in (show t, show v)

putStrLn "[#] Time for Verlet integration is:"
putStrLn "[#]\nTime for Verlet integration is:"
putStrLn $ fst $ timeVelocity verlet
putStrLn "[#] Time for Stormer Verlet integration is:"
putStrLn "[#]\nTime for Stormer Verlet integration is:"
putStrLn $ fst $ timeVelocity stormerVerlet
putStrLn "[#] Velocity for Stormer Verlet integration is:"
putStrLn "[#]\nVelocity for Stormer Verlet integration is:"
putStrLn $ snd $ timeVelocity stormerVerlet
putStrLn "[#] Time for velocity Verlet integration is:"
putStrLn "[#]\nTime for velocity Verlet integration is:"
putStrLn $ fst $ timeVelocity velocityVerlet
putStrLn "[#] Velocity for velocity Verlet integration is:"
putStrLn "[#]\nVelocity for velocity Verlet integration is:"
putStrLn $ snd $ timeVelocity velocityVerlet
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/java/Verlet.java
Original file line number Diff line number Diff line change
@@ -65,19 +65,19 @@ static VerletValues velocity_verlet(double pos, double acc, double dt) {
public static void main(String[] args) {

double verletTime = verlet(5.0, -10, 0.01);
System.out.println("[#] Time for Verlet integration is:");
System.out.println("[#]\nTime for Verlet integration is:");
System.out.println(verletTime);

VerletValues stormerVerlet = stormer_verlet(5.0, -10, 0.01);
System.out.println("[#] Time for Stormer Verlet integration is:");
System.out.println("[#]\nTime for Stormer Verlet integration is:");
System.out.println(stormerVerlet.time);
System.out.println("[#] Velocity for Stormer Verlet integration is:");
System.out.println("[#]\nVelocity for Stormer Verlet integration is:");
System.out.println(stormerVerlet.vel);

VerletValues velocityVerlet = velocity_verlet(5.0, -10, 0.01);
System.out.println("[#] Time for velocity Verlet integration is:");
System.out.println("[#]\nTime for velocity Verlet integration is:");
System.out.println(velocityVerlet.time);
System.out.println("[#] Velocity for velocity Verlet integration is:");
System.out.println("[#]\nVelocity for velocity Verlet integration is:");
System.out.println(velocityVerlet.vel);

}
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/javascript/verlet.js
Original file line number Diff line number Diff line change
@@ -45,17 +45,17 @@ function velocityVerlet(pos, acc, dt) {
}

const time = verlet(5, -10, 0.01);
console.log(`[#] Time for Verlet integration is:`);
console.log(`[#]\nTime for Verlet integration is:`);
console.log(`${time}`);

const stormer = stormerVerlet(5, -10, 0.01);
console.log(`[#] Time for Stormer Verlet integration is:`);
console.log(`[#]\nTime for Stormer Verlet integration is:`);
console.log(`${stormer.time}`);
console.log(`[#] Velocity for Stormer Verlet integration is:`);
console.log(`[#]\nVelocity for Stormer Verlet integration is:`);
console.log(`${stormer.vel}`);

const velocity = velocityVerlet(5, -10, 0.01);
console.log(`[#] Time for velocity Verlet integration is:`);
console.log(`[#]\nTime for velocity Verlet integration is:`);
console.log(`${velocity.time}`);
console.log(`[#] Velocity for velocity Verlet integration is:`);
console.log(`[#]\nVelocity for velocity Verlet integration is:`);
console.log(`${velocity.vel}`);
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/julia/verlet.jl
Original file line number Diff line number Diff line change
@@ -46,19 +46,19 @@ end

function main()
time = verlet(5.0, -10.0, 0.01);
println("[#] Time for Verlet integration is:")
println("[#]\nTime for Verlet integration is:")
println("$(time)")

time, vel = stormer_verlet(5.0, -10.0, 0.01);
println("[#] Time for Stormer Verlet integration is:")
println("[#]\nTime for Stormer Verlet integration is:")
println("$(time)")
println("[#] Velocity for Stormer Verlet integration is:")
println("[#]\nVelocity for Stormer Verlet integration is:")
println("$(vel)")

time, vel = velocity_verlet(5.0, -10.0, 0.01);
println("[#] Time for velocity Verlet integration is:")
println("[#]\nTime for velocity Verlet integration is:")
println("$(time)")
println("[#] Velocity for velocity Verlet integration is:")
println("[#]\nVelocity for velocity Verlet integration is:")
println("$(vel)")

end
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/kotlin/verlet.kt
Original file line number Diff line number Diff line change
@@ -43,18 +43,18 @@ fun velocityVerlet(_pos: Double, acc: Double, dt: Double): VerletValues {

fun main(args: Array<String>) {
val verletTime = verlet(5.0, -10.0, 0.01)
println("[#] Time for Verlet integration is:")
println("[#]\nTime for Verlet integration is:")
println("$verletTime")

val stormerVerlet = stormerVerlet(5.0, -10.0, 0.01)
println("[#] Time for Stormer Verlet integration is:")
println("[#]\nTime for Stormer Verlet integration is:")
println("${stormerVerlet.time}")
println("[#] Velocity for Stormer Verlet integration is:")
println("[#]\nVelocity for Stormer Verlet integration is:")
println("${stormerVerlet.vel}")

val velocityVerlet = velocityVerlet(5.0, -10.0, 0.01)
println("[#] Time for Velocity Verlet integration is:")
println("[#]\nTime for Velocity Verlet integration is:")
println("${velocityVerlet.time}")
println("[#] Velocity for Velocity Verlet integration is:")
println("[#]\nVelocity for Velocity Verlet integration is:")
println("${velocityVerlet.vel}")
}
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/nim/verlet.nim
Original file line number Diff line number Diff line change
@@ -46,17 +46,17 @@ func velocityVerlet(pos_in, acc, dt: float): (float, float) =

when isMainModule:
let timeV = verlet(5.0, -10.0, 0.01)
echo "[#] Time for Verlet integration is:"
echo "[#]\nTime for Verlet integration is:"
echo timeV

let (timeSV, velSV) = stormerVerlet(5.0, -10.0, 0.01)
echo "[#] Time for Stormer Verlet integration is:"
echo "[#]\nTime for Stormer Verlet integration is:"
echo timeSV
echo "[#] Velocity for Stormer Verlet integration is:"
echo "[#]\nVelocity for Stormer Verlet integration is:"
echo velSV

let (timeVV, velVV) = velocityVerlet(5.0, -10.0, 0.01)
echo "[#] Time for velocity Verlet integration is:"
echo "[#]\nTime for velocity Verlet integration is:"
echo timeVV
echo "[#] Velocity for velocity Verlet integration is:"
echo "[#]\nVelocity for velocity Verlet integration is:"
echo velVV
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/python/verlet.py
Original file line number Diff line number Diff line change
@@ -35,19 +35,19 @@ def velocity_verlet(pos, acc, dt):

def main():
time = verlet(5, -10, 0.01)
print("[#] Time for Verlet integration is:")
print("[#]\nTime for Verlet integration is:")
print("{:.10f}".format(time))

time, vel = stormer_verlet(5, -10, 0.01)
print("[#] Time for Stormer Verlet integration is:")
print("[#]\nTime for Stormer Verlet integration is:")
print("{:.10f}".format(time))
print("[#] Velocity for Stormer Verlet integration is:")
print("[#]\nVelocity for Stormer Verlet integration is:")
print("{:.10f}".format(vel))

time, vel = velocity_verlet(5, -10, 0.01)
print("[#] Time for velocity Verlet integration is:")
print("[#]\nTime for velocity Verlet integration is:")
print("{:.10f}".format(time))
print("[#] Velocity for velocity Verlet integration is:")
print("[#]\nVelocity for velocity Verlet integration is:")
print("{:.10f}".format(vel))


10 changes: 5 additions & 5 deletions contents/verlet_integration/code/ruby/verlet.rb
Original file line number Diff line number Diff line change
@@ -45,17 +45,17 @@ def velocity_verlet(pos, acc, dt)

end

puts "[#] Time for Verlet integration is:"
puts "[#]\nTime for Verlet integration is:"
p verlet(5.0, -10, 0.01)

time, vel = stormer_verlet(5.0, -10, 0.01)
puts "[#] Time for Stormer Verlet integration is:"
puts "[#]\nTime for Stormer Verlet integration is:"
p time
puts "[#] Velocity for Stormer Verlet integration is:"
puts "[#]\nVelocity for Stormer Verlet integration is:"
p vel

time, vel = velocity_verlet(5.0, -10, 0.01)
puts "[#] Time for velocity Verlet integration is:"
puts "[#]\nTime for velocity Verlet integration is:"
p time
puts "[#] Velocity for velocity Verlet integration is:"
puts "[#]\nVelocity for velocity Verlet integration is:"
p vel
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/rust/verlet.rs
Original file line number Diff line number Diff line change
@@ -49,16 +49,16 @@ fn main() {
let (time_sv, vel_sv) = stormer_verlet(5.0, -10.0, 0.01);
let (time_vv, vel_vv) = velocity_verlet(5.0, -10.0, 0.01);

println!("[#] Time for Verlet integration is:");
println!("[#]\nTime for Verlet integration is:");
println!("{}", time_v);

println!("[#] Time for Stormer Verlet integration is:");
println!("[#]\nTime for Stormer Verlet integration is:");
println!("{}", time_sv);
println!("[#] Velocity for Stormer Verlet integration is:");
println!("[#]\nVelocity for Stormer Verlet integration is:");
println!("{}", vel_sv);

println!("[#] Time for velocity Verlet integration is:");
println!("[#]\nTime for velocity Verlet integration is:");
println!("{}", time_vv);
println!("[#] Velocity for velocity Verlet integration is:");
println!("[#]\nVelocity for velocity Verlet integration is:");
println!("{}", vel_vv);
}
10 changes: 5 additions & 5 deletions contents/verlet_integration/code/swift/verlet.swift
Original file line number Diff line number Diff line change
@@ -50,19 +50,19 @@ func velocityVerlet(pos: Double, acc: Double, dt: Double) -> (time: Double, vel:

func main() {
let verletTime = verlet(pos: 5.0, acc: -10.0, dt: 0.01)
print("[#] Time for Verlet integration is:")
print("[#]\nTime for Verlet integration is:")
print("\(verletTime)")

let stormer = stormerVerlet(pos: 5.0, acc: -10.0, dt: 0.01);
print("[#] Time for Stormer Verlet integration is:")
print("[#]\nTime for Stormer Verlet integration is:")
print("\(stormer.time)")
print("[#] Velocity for Stormer Verlet integration is:")
print("[#]\nVelocity for Stormer Verlet integration is:")
print("\(stormer.vel)")

let velVerlet = velocityVerlet(pos: 5.0, acc: -10, dt: 0.01)
print("[#] Time for velocity Verlet integration is:")
print("[#]\nTime for velocity Verlet integration is:")
print("\(velVerlet.time)")
print("[#] Velocity for velocity Verlet integration is:")
print("[#]\nVelocity for velocity Verlet integration is:")
print("\(velVerlet.vel)")
}