Add all the A tasks
This commit is contained in:
parent
2dd7375f96
commit
051504d65b
1608 changed files with 18584 additions and 0 deletions
9
Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f
Normal file
9
Task/Arithmetic-Complex/Fortran/arithmetic-complex-1.f
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
program cdemo
|
||||
complex :: a = (5,3), b = (0.5, 6.0) ! complex initializer
|
||||
complex :: absum, abprod, aneg, ainv
|
||||
|
||||
absum = a + b
|
||||
abprod = a * b
|
||||
aneg = -a
|
||||
ainv = 1.0 / a
|
||||
end program cdemo
|
||||
28
Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f
Normal file
28
Task/Arithmetic-Complex/Fortran/arithmetic-complex-2.f
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
program cdemo2
|
||||
complex :: a = (5,3), b = (0.5, 6) ! complex initializer
|
||||
real, parameter :: pi = 3.141592653589793 ! The constant "pi"
|
||||
complex, parameter :: i = (0, 1) ! the imaginary unit "i" (sqrt(-1))
|
||||
complex :: abdiff, abquot, abpow, aconj, p2cart, newc
|
||||
real :: areal, aimag, anorm, rho = 10, theta = pi / 3.0, x = 2.3, y = 3.0
|
||||
integer, parameter :: n = 50
|
||||
integer :: j
|
||||
complex, dimension(0:n-1) :: unit_circle
|
||||
|
||||
abdiff = a - b
|
||||
abquot = a / b
|
||||
abpow = a ** b
|
||||
areal = real(a) ! Real part
|
||||
aimag = imag(a) ! Imaginary part
|
||||
newc = cmplx(x,y) ! Creating a complex on the fly from two reals intrinsically
|
||||
! (initializer only works in declarations)
|
||||
newc = x + y*i ! Creating a complex on the fly from two reals arithmetically
|
||||
anorm = abs(a) ! Complex norm (or "modulus" or "absolute value")
|
||||
! (use CABS before Fortran 90)
|
||||
aconj = conjg(a) ! Complex conjugate (same as real(a) - i*imag(a))
|
||||
p2cart = rho * exp(i * theta) ! Euler's polar complex notation to cartesian complex notation
|
||||
! conversion (use CEXP before Fortran 90)
|
||||
|
||||
! The following creates an array of N evenly spaced points around the complex unit circle
|
||||
! useful for FFT calculations, among other things
|
||||
unit_circle = exp(2*i*pi/n * (/ (j, j=0, n-1) /) )
|
||||
end program cdemo2
|
||||
Loading…
Add table
Add a link
Reference in a new issue