TrilIndx
Returns the indices of lower triangle part of a matrix.
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION TrilIndx(m, n, diagNo) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: m
!! number of rows
INTEGER(I4B), OPTIONAL, INTENT(IN) :: n
!! number of columns, default = m
INTEGER(I4B), OPTIONAL, INTENT(IN) :: diagNo
!! diagonal number, default = 0
!! diagNo>0 means super diagonal
!! diagNo<0 means subdiagonal
INTEGER(I4B), ALLOCATABLE :: ans(:, :)
!! ans(:,1) contains the row indices
!! ans(:,2) contains the col indices
END FUNCTION TrilIndx
END INTERFACE
program main
use easifemBase
implicit none
INTEGER(I4B), ALLOCATABLE :: indx(:,:)
CALL Display(TrilIndx(m=3,n=3,diagNo=0), "(3,3) diagNo=0, = " )
CALL Display(TrilIndx(m=3,n=3,diagNo=1), "(3,3) diagNo=1, = " )
CALL Display(TrilIndx(m=3,n=3,diagNo=2), "(3,3) diagNo=2, = " )
CALL Display(TrilIndx(m=3,n=3,diagNo=-1), "(3,3) diagNo=-1, = " )
CALL Display(TrilIndx(m=3,n=3,diagNo=-2), "(3,3) diagNo=-2, = " )
See results
(3,3) diagNo=0, =
------------------
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=1, =
------------------
1 2
2 3
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=2, =
------------------
1 3
1 2
2 3
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=-1, =
-------------------
2 1
3 2
3 1
(3,3) diagNo=-2, =
-------------------
3 1
end program main
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION TrilIndx(A, diagNo) RESULT(ans)
CLASS(*), INTENT(IN) :: A(:, :)
INTEGER(I4B), OPTIONAL, INTENT(IN) :: diagNo
!! diagonal number, default = 0
!! diagNo>0 means super diagonal
!! diagNo<0 means subdiagonal
INTEGER(I4B), ALLOCATABLE :: ans(:, :)
!! ans(:,1) contains the row indices
!! ans(:,2) contains the col indices
END FUNCTION TrilIndx
END INTERFACE
program main
use easifemBase
implicit none
INTEGER(I4B), ALLOCATABLE :: indx(:,:)
REAL( DFP ) :: amat(3,3)
CALL Display(TrilIndx(amat,diagNo=0), "(3,3) diagNo=0, = " )
CALL Display(TrilIndx(amat,diagNo=1), "(3,3) diagNo=1, = " )
CALL Display(TrilIndx(amat,diagNo=2), "(3,3) diagNo=2, = " )
CALL Display(TrilIndx(amat,diagNo=-1), "(3,3) diagNo=-1, = " )
CALL Display(TrilIndx(amat,diagNo=-2), "(3,3) diagNo=-2, = " )
See results
(3,3) diagNo=0, =
------------------
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=1, =
------------------
1 2
2 3
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=2, =
------------------
1 3
1 2
2 3
1 1
2 2
3 3
2 1
3 2
3 1
(3,3) diagNo=-1, =
-------------------
2 1
3 2
3 1
(3,3) diagNo=-2, =
-------------------
3 1
end program main