00001 program basic
00002 use arrayfire
00003 implicit none
00004
00005 real, dimension(3,3) :: a
00006 real, dimension(:,:), allocatable :: b
00007 type(array) M1, M2, tmp
00008
00009 a(1,:) = (/ 1, 0, 0 /)
00010 a(2,:) = (/ 0, 3, 0 /)
00011 a(3,:) = (/ 0, 0, 2 /)
00012
00013
00014 M1 = a
00015 write(*,*) "Showing the matrix after mem copy from host (M1)"
00016 call print(M1)
00017
00018
00019 M2 = randu(3,3, ty=f32)
00020 write(*,*) "Showing a randomly generated matrix (M2)"
00021 call print(M2)
00022
00023
00024 tmp = transpose(M2)
00025 call print(tmp, "Transpose of M2")
00026
00027
00028 tmp = M1 + M2
00029 call print(tmp, "M1 + M2")
00030
00031
00032 call print(-M2, "-M2")
00033
00034
00035 write(*,*) "Displaying sin(M2)**2 + cos(M2)**2"
00036 call print(sin(M2)**2.0 + cos(M2)**2.0)
00037
00038
00039
00040 write(*, *) "Matrix multiply: matmul(M1, M2)"
00041 call print(matmul(M1, M2))
00042
00043
00044 write(*, *) "Element wise multiplication: M1 * M2"
00045 call print(M1 * M2)
00046
00047
00048 tmp = min(M2)
00049 call print(tmp, "min(M2)")
00050
00051
00052 b = tmp
00053 write(*,*) "Showing min(M2) data back on host "
00054 write(*,*) b(:,:)
00055
00056 end program basic