with text_io; use text_io; with generic_real_arrays; with generic_complex_types; with generic_complex_arrays; with generic_complex_elementary_functions; with complex_io; with mathematical_constants; procedure test_gcef_plot is type real is digits 9; package real_arrays is new generic_real_arrays(real); use real_arrays; package complex_types is new generic_complex_types(real); use complex_types; package complex_arrays is new generic_complex_arrays (real, real_vector, real_matrix, complex); use complex_arrays; package cx_io is new complex_io (real, complex); use cx_io; package complex_elementary_functions is new generic_complex_elementary_functions(real, complex, imaginary); use complex_elementary_functions; argument_error : exception renames complex_types.argument_error; complex_one : complex := (1.0,0.0); complex_zero : complex := (0.0,0.0); complex_i : complex := (0.0,1.0); pi : real := mathematical_constants.pi+0.01; samples : constant := 33; K : array(integer(-samples)..samples) of real; P : COMPLEX_VECTOR ( 1..k'length*k'length); l1 : string(1..38) := " -Pi -P/2 -1 0 1 P/2 +Pi "; l2 : string(1..38) := " | | | | | | | "; l3 : string(1..38) := " | | | | | | | "; l4 : string(1..38) := "-----+---+---+---+---+---+---+--- +iPi"; l5 : string(1..38) := " | | | | | | | "; l6 : string(1..38) := "-----+---+---+---+---+---+---+-- +iP/2"; l7 : string(1..38) := " | | | | | | | "; l8 : string(1..38) := "-----+---+---+---+---+---+---+---- 1 "; l9 : string(1..38) := " | | | | | | | "; l10: string(1..38) := "-----+---+---+---+---+---+---+---- 0 "; l11: string(1..38) := " | | | | | | | "; l12: string(1..38) := "-----+---+---+---+---+---+---+---- -1 "; l13: string(1..38) := " | | | | | | | "; l14: string(1..38) := "-----+---+---+---+---+---+---+-- -iP/2"; l15: string(1..38) := " | | | | | | | "; l16: string(1..38) := "-----+---+---+---+---+---+---+--- -iPi"; l17: string(1..38) := " | | | | | | | "; l18: string(1..38) := " | | | | | | | "; procedure plot(name:string) is begin new_line; put_line(name); new_line; put_line(L1); put_line(L2); put_line(L3); put_line(L4); put_line(L5); put_line(L6); put_line(L7); put_line(L8); put_line(L9); put_line(L10); put_line(L11); put_line(L12); put_line(L13); put_line(L14); put_line(L15); put_line(L16); put_line(L17); put_line(L18); new_line; L3 (4..32):=" | | | | | | | "; L5 (4..32):=" | | | | | | | "; L7 (4..32):=" | | | | | | | "; L9 (4..32):=" | | | | | | | "; L11(4..32):=" | | | | | | | "; L13(4..32):=" | | | | | | | "; L15(4..32):=" | | | | | | | "; L17(4..32):=" | | | | | | | "; end plot; procedure draw ( z: complex) is x : real := RE(z); y : real := IM(z); begin if x > Pi then if y > Pi then L3 (32):='X'; elsif y > Pi/2.0 then L5 (32):='X'; elsif y > 1.01 then L7 (32):='X'; elsif y > 0.0 then L9 (32):='X'; elsif y < -Pi then L17(32):='X'; elsif y < -Pi/2.0 then L15(32):='X'; elsif y < -1.01 then L13(32):='X'; elsif y < 0.0 then L11(32):='X'; end if; elsif x > Pi/2.0 then if y > Pi then L3 (28):='X'; elsif y > Pi/2.0 then L5 (28):='X'; elsif y > 1.01 then L7 (28):='X'; elsif y > 0.0 then L9 (28):='X'; elsif y < -Pi then L17(28):='X'; elsif y < -Pi/2.0 then L15(28):='X'; elsif y < -1.01 then L13(28):='X'; elsif y < 0.0 then L11(28):='X'; end if; elsif x > 1.01 then if y > Pi then L3 (24):='X'; elsif y > Pi/2.0 then L5 (24):='X'; elsif y > 1.01 then L7 (24):='X'; elsif y > 0.0 then L9 (24):='X'; elsif y < -Pi then L17(24):='X'; elsif y < -Pi/2.0 then L15(24):='X'; elsif y < -1.01 then L13(24):='X'; elsif y < 0.0 then L11(24):='X'; end if; elsif x > 0.0 then if y > Pi then L3 (20):='X'; elsif y > Pi/2.0 then L5 (20):='X'; elsif y > 1.01 then L7 (20):='X'; elsif y > 0.0 then L9 (20):='X'; elsif y < -Pi then L17(20):='X'; elsif y < -Pi/2.0 then L15(20):='X'; elsif y < -1.01 then L13(20):='X'; elsif y < 0.0 then L11(20):='X'; end if; elsif x < -Pi then if y > Pi then L3 (04):='X'; elsif y > Pi/2.0 then L5 (04):='X'; elsif y > 1.01 then L7 (04):='X'; elsif y > 0.0 then L9 (04):='X'; elsif y < -Pi then L17(04):='X'; elsif y < -Pi/2.0 then L15(04):='X'; elsif y < -1.01 then L13(04):='X'; elsif y < 0.0 then L11(04):='X'; end if; elsif x < -Pi/2.0 then if y > Pi then L3 (08):='X'; elsif y > Pi/2.0 then L5 (08):='X'; elsif y > 1.01 then L7 (08):='X'; elsif y > 0.0 then L9 (08):='X'; elsif y < -Pi then L17(08):='X'; elsif y < -Pi/2.0 then L15(08):='X'; elsif y < -1.01 then L13(08):='X'; elsif y < 0.0 then L11(08):='X'; end if; elsif x < -1.01 then if y > Pi then L3 (12):='X'; elsif y > Pi/2.0 then L5 (12):='X'; elsif y > 1.01 then L7 (12):='X'; elsif y > 0.0 then L9 (12):='X'; elsif y < -Pi then L17(12):='X'; elsif y < -Pi/2.0 then L15(12):='X'; elsif y < -1.01 then L13(12):='X'; elsif y < 0.0 then L11(12):='X'; end if; elsif x < 0.0 then if y > Pi then L3 (16):='X'; elsif y > Pi/2.0 then L5 (16):='X'; elsif y > 1.01 then L7 (16):='X'; elsif y > 0.0 then L9 (16):='X'; elsif y < -Pi then L17(16):='X'; elsif y < -Pi/2.0 then L15(16):='X'; elsif y < -1.01 then L13(16):='X'; elsif y < 0.0 then L11(16):='X'; end if; end if; end draw; function "*"(z:complex;x:real) return complex is begin return compose_from_cartesian(RE(z)*x,IM(z)); end "*"; begin -- test at interesting points like (0,0) (1,0) (-1,0) (pi,0) (-pi,0) k(0) := 0.0; k(1) := 0.001; k(2) := 0.01; k(3) := 0.02; k(4) := 0.06; k(5) := 0.1; k(6) := 0.2; k(7) := 0.25; k(8) := 0.35; k(9) := 0.5; k(10) := 0.7071; k(11) := 0.785; k(12) := 0.786; k(13) := 0.97; k(14) := 0.999; k(15) := 1.0; k(16) := 1.001; k(17) := 1.1; k(18) := 1.01; k(19) := 1.25; k(20) := 1.35; k(21) := 1.41421; k(22) := 1.5; k(23) := 1.57079; k(24) := 2.0; k(25) := 2.2; k(26) := 2.4; k(27) := 2.71828; k(28) := 3.141; k(29) := 3.142; k(30) := 8.0; k(31) := 12.0; k(32) := 16.0; k(33) := 64.0; for i in 1..k'last loop k(-i) := -k(i); end loop; for i in k'range loop for j in k'range loop P((i-k'first)*k'length+(j-k'first)+1) := compose_from_cartesian(k(i),k(j)); end loop; end loop; for i in p'range loop begin -- put("sqrt"); put(p(i)); put(" = "); put(sqrt(p(i))); new_line; draw(sqrt(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("SQRT"); for i in p'range loop begin -- put("log"); put(p(i)); put(" = "); put(log(p(i))); new_line; draw(log(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("LOG"); for i in p'range loop begin -- put("exp"); put(p(i)); put(" = "); put(exp(p(i))); new_line; draw(exp(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("EXP"); for i in p'range loop begin -- put("sin"); put(p(i)); put(" = "); put(sin(p(i))); new_line; draw(sin(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("SIN"); for i in p'range loop begin -- put("cos"); put(p(i)); put(" = "); put(cos(p(i))); new_line; draw(cos(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("COS"); for i in p'range loop begin -- put("tan"); put(p(i)); put(" = "); put(tan(p(i))); new_line; draw(tan(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("TAN"); for i in p'range loop begin -- put("cot"); put(p(i)); put(" = "); put(cot(p(i))); new_line; draw(cot(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("COT"); for i in p'range loop begin -- put("arcsin"); put(p(i)); put(" = "); put(arcsin(p(i))); new_line; draw(arcsin(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCSIN"); for i in p'range loop begin -- put("arccos"); put(p(i)); put(" = "); put(arccos(p(i))); new_line; draw(arccos(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCCOS"); for i in p'range loop begin -- put("arctan"); put(p(i)); put(" = "); put(arctan(p(i))); new_line; draw(arctan(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCTAN"); for i in p'range loop begin -- put("arccot"); put(p(i)); put(" = "); put(arccot(p(i))); new_line; draw(arccot(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCCOT"); for i in p'range loop begin -- put("sinh"); put(p(i)); put(" = "); put(sinh(p(i))); new_line; draw(sinh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("SINH"); for i in p'range loop begin -- put("cosh"); put(p(i)); put(" = "); put(cosh(p(i))); new_line; draw(cosh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("COSH"); for i in p'range loop begin -- put("tanh"); put(p(i)); put(" = "); put(tanh(p(i))); new_line; draw(tanh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("TANH"); for i in p'range loop begin -- put("coth"); put(p(i)); put(" = "); put(coth(p(i))); new_line; draw(coth(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("COTH"); for i in p'range loop begin -- put("arcsinh"); put(p(i)); put(" = "); put(arcsinh(p(i))); new_line; draw(arcsinh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCSINH"); for i in p'range loop begin -- put("arccosh"); put(p(i)); put(" = "); put(arccosh(p(i))); new_line; draw(arccosh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCCOSH"); for i in p'range loop begin -- put("arctanh"); put(p(i)); put(" = "); put(arctanh(p(i))); new_line; draw(arctanh(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCTANH"); for i in p'range loop begin -- put("arccoth"); put(p(i)); put(" = "); put(arccoth(p(i))); new_line; draw(arccoth(p(i))); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("ARCCOTH"); for i in p'range loop begin -- put("**"); put(p(i)); put(" = "); put("**"(p(i),complex_one)); new_line; draw("**"(p(i),complex_one)); -- put("**"); put(p(i)); put(" = "); put("**"(p(i),complex_i)); new_line; draw("**"(p(i),complex_i)); -- put("**"); put(p(i)); put(" = "); put("**"(p(i),-complex_i)); new_line; draw("**"(p(i),-complex_i)); -- put("**"); put(p(i)); put(" = "); put("**"(p(i),-complex_one)); new_line; draw("**"(p(i),-complex_one)); exception when argument_error => put_line("argument error"); when constraint_error => put_line("constraint_error"); when others => put_line("other exception"); end; end loop; plot("**"); end test_gcef_plot;