! ベクトルの外積の計算 program vector_crossprod implicit none real :: vectorA(3) ! 要素数 3 の実数型変数配列 (ベクトル A) integer, parameter :: nn = 3 ! 要素数を定数で定義 real :: vectorB(nn) ! 要素数 nn(=3) の実数型変数配列 (ベクトル B) real :: vectorC(nn) ! 要素数 nn(=3) の実数型変数配列 (ベクトル C) vectorA(1) = 1.1 ! 配列への値の代入 vectorA(2) = -2.2 vectorA(3) = 3.3 vectorB(1) = -1.3 ! 配列への値の代入 vectorB(2) = -2.5 vectorB(3) = 0.7 ! ベクトル A, B の外積の計算 vectorC(1) = vectorA(2) * vectorB(3) - vectorA(3) * vectorB(2) vectorC(2) = vectorA(3) * vectorB(1) - vectorA(1) * vectorB(3) vectorC(3) = vectorA(1) * vectorB(2) - vectorA(2) * vectorB(1) print *, "Cross product = (", vectorC(1), ",", vectorC(2), ",", vectorC(3), ")" end program vector_crossprod