1.fortran����Դ��
2.用fortran软件编制程序,矩矩阵计算矩阵的阵源行列式。要求使用子程序进行模块化编程
3.在fortran中矩阵C是矩矩阵(3,6),矩阵B1,阵源反恐精英钓鱼源码B2,矩矩阵B3都是阵源app自动粘贴源码(3,2),我想让C的矩矩阵第1,2列取B1,3,阵源4列取B2,5,矩矩阵6列取B3
fortran����Դ��
参考代码:
program test
implicit none
integer :: arr(5,阵源3), arr_sum(5),itmp(3)
integer :: i,j,maxv_line(1)
print*, '输入一个5行3列整数矩阵'
do i = 1,5
read(*,*) arr(i,1:3)
arr_sum(i) = sum(arr(i,1:3))
end do
print*, '交换前的矩阵'
do i = 1,5
print*, arr(i,1:3), 'sum = ',sum(arr(i,:))
end do
maxv_line = maxloc(arr_sum)
itmp(:) = arr(maxv_line(1),:)
arr(maxv_line(1),:) = arr(1,:)
arr(1,:) = itmp(:)
print*, '交换后的矩阵'
do i = 1,5
print*, arr(i,1:3), 'sum = ',sum(arr(i,:))
end do
stop
end program
运行结果
输入
输入一个5行3列整数矩阵
1 2 3
2 3 0
3 8 1
0 1 3
5 1 2
输出
交换前的矩阵
1 2 3 sum = 6
2 3 0 sum = 5
3 8 1 sum = #和6交换
0 1 3 sum = 4
5 1 2 sum = 8
交换后的矩阵
3 8 1 sum =
2 3 0 sum = 5
1 2 3 sum = 6
0 1 3 sum = 4
5 1 2 sum = 8
用fortran软件编制程序,计算矩阵的矩矩阵行列式。要求使用子程序进行模块化编程
求矩阵行列式是阵源一个复杂的过程。有很多很多算法来做,矩矩阵vue_fullcalendar源码但是阵源各有适用性。有的矩矩阵不适合病态矩阵等等。
以下是chronium源码如何分析一个简单的全选主元高斯消去法。
摘自徐世良的《Fortran常用算法集》
Program Main
Implicit None
Real(8) :: rm(3,3) = reshape( (/1,2,4,5,7,3,,5,7/) , (/3,3/) )
Real(8) :: rDet
call BSDet( rm , 3 , rDet )
write(*,*) rDet
End Program Main
SUBROUTINE BSDET(A,N,DET)
DIMENSION A(N,N)
DOUBLE PRECISION A,DET,F,D,Q
F=1.0
DET=1.0
DO K=1,N-1
Q=0.0
DO I=K,N
DO J=K,N
IF (ABS(A(I,J)).GT.Q) THEN
Q=ABS(A(I,J))
IS=I
JS=J
END IF
CONTINUE
IF (Q+1.0.EQ.1.0) THEN
DET=0.0
RETURN
END IF
IF (IS.NE.K) THEN
F=-F
DO J=K,N
D=A(K,J)
A(K,J)=A(IS,J)
A(IS,J)=D
CONTINUE
END IF
IF (JS.NE.K) THEN
F=-F
DO I=K,N
D=A(I,JS)
A(I,JS)=A(I,K)
A(I,K)=D
CONTINUE
END IF
DET=DET*A(K,K)
DO I=K+1,N
D=A(I,K)/A(K,K)
DO J=K+1,N
A(I,J)=A(I,J)-D*A(K,J)
CONTINUE
CONTINUE
DET=F*DET*A(N,N)
RETURN
END
在fortran中矩阵C是(3,6),矩阵B1,B2,益智游戏app源码B3都是(3,2),我想让C的第1,2列取B1,3,4列取B2,5,6列取B3
① 代码{F}:program array_assignmentinteger, dimension (3, 6) :: c
integer, dimension (3, 2) :: b1, b2, b3
data b1/1,2,3,4,5,6/, b2/,,,,,/, b3/,,,,,/
c(:,1:2) = b1
c(:,3:4) = b2
c(:,5:6) = b3
do, i=1,3
write(*,'(6i5)') (c(i,j), j = 1, 6)
enddo
end program array_assignment
② 运行:
1 42 5
3 6
2024-12-22 15:59
2024-12-22 15:54
2024-12-22 15:45
2024-12-22 15:29
2024-12-22 15:25
2024-12-22 15:18