3*1向量叉乘
subroutine vecprod(dvin1,dvin2,dvout)
implicit none
real(8), intent(in) :: dvin1(3), dvin2(3)
real(8), intent(out) :: dvout(3)
dvout(1)=dvin1(2)*dvin2(3)-dvin1(3)*dvin2(2)
dvout(2)=dvin1(3)*dvin2(1)-dvin1(1)*dvin2(3)
dvout(3)=dvin1(1)*dvin2(2)-dvin1(2)*dvin2(1)
return
end subroutine vecprod
3*1向量点乘
subroutine dotprod(dvin1,dvin2,dvout)
implicit none
real(8), intent(in) :: dvin1(3), dvin2(3)
real(8), intent(out) :: dvout(3)
dvout = dvin1(1)*dvin2(1)+dvin1(2)*dvin2(2)+dvin1(3)*dvin2(3)
dvout = abs(dvout)
return
end subroutine dotprod
3*3矩阵的行列式的值
subroutine deter3x3(dmin,d)
implicit none
real(8), intent(in) :: dmin(3,3)
real(8), intent(out) :: d
d = 0.
d = dmin(1,1)*dmin(2,2)*dmin(3,3) +
+ dmin(1,2)*dmin(2,3)*dmin(3,1) +
+ dmin(2,1)*dmin(3,2)*dmin(1,3) -
+ dmin(1,3)*dmin(2,2)*dmin(3,1) -
+ dmin(1,1)*dmin(2,3)*dmin(3,2) -
+ dmin(1,2)*dmin(2,1)*dmin(3,3)
return
end subroutine deter3x3
2*2矩阵的行列式的值
subroutine deter2x2(dmin,d)
implicit none
real(8), intent(in) :: dmin(2,2)
real(8), intent(out) :: d
d=0.
d=dmin(1,1)*dmin(2,2)-dmin(1,2)*dmin(2,1)
return
end subroutine deter2x2
3*3的矩阵相乘
subroutine mmult(dm1,dm2,dm)
implicit none
real(8), intent(in) :: dm1(3,3), dm2(3,3)
real(8), intent(out) :: dm(3,3)
integer :: i, j, k
real(8) :: x
do i=1,3
do j=1,3
x=0.0
do k=1,3
x=x+dm1(i,k)*dm2(k,j)
end do
dm(i,j)=x
end do
end do
return
end subroutine mmult