Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Arithmetic-Complex/OCaml/arithmetic-complex-1.ocaml
Normal file
13
Task/Arithmetic-Complex/OCaml/arithmetic-complex-1.ocaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
open Complex
|
||||
|
||||
let print_complex z =
|
||||
Printf.printf "%f + %f i\n" z.re z.im
|
||||
|
||||
let () =
|
||||
let a = { re = 1.0; im = 1.0 }
|
||||
and b = { re = 3.14159; im = 1.25 } in
|
||||
print_complex (add a b);
|
||||
print_complex (mul a b);
|
||||
print_complex (inv a);
|
||||
print_complex (neg a);
|
||||
print_complex (conj a)
|
||||
14
Task/Arithmetic-Complex/OCaml/arithmetic-complex-2.ocaml
Normal file
14
Task/Arithmetic-Complex/OCaml/arithmetic-complex-2.ocaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
let () =
|
||||
Complex.(
|
||||
let print txt z = Printf.printf "%s = %s\n" txt (to_string z) in
|
||||
let a = 1 + I
|
||||
and b = 3 + 7I in
|
||||
print "a + b" (a + b);
|
||||
print "a - b" (a - b);
|
||||
print "a * b" (a * b);
|
||||
print "a / b" (a / b);
|
||||
print "-a" (- a);
|
||||
print "conj a" (conj a);
|
||||
print "a^b" (a**b);
|
||||
Printf.printf "norm a = %g\n" (float(abs a));
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue