GetTriu
This subroutine returns the upper triangle part of an int vector.
Interface
- ܀ Interface
- ️܀ Example 1
- Example 2
- ↢
MODULE PURE SUBROUTINE GetTriu(A, diagNo, lu)
INTEGER(Int8| Int16 | Int32 | Int64) | REAL(Real32| Real64), INTENT(IN) :: A(:, :)
INTEGER(I4B), OPTIONAL, INTENT(IN) :: diagNo
!! diagonal number, default = 0
REAL(REAL32), INTENT(OUT) :: lu(SIZE(A, 1), SIZE(A, 2))
END SUBROUTINE GetTriu
This example shows the use of GetTriu.
program main
use easifemBase
implicit none
Testing for Square matrix
REAL( Real32 ) :: A( 4, 4 ), lu(4, 4)
CALL RANDOM_NUMBER(A); A = A*10
CALl Display(MdEncode(A), "A = " // CHAR_LF // CHAR_LF)
See results
A =
7.9596 | 0.4582 | 9.668 | 3.2888 |
9.8813 | 8.812 | 8.1055 | 0.42248 |
2.7221 | 5.3213 | 8.3696 | 0.61326 |
5.3658 | 7.8775 | 4.4198 | 1.9634 |
CALL GetTriu(A=A, diagNo=0, lu=lu)
CALL Display(MdEncode(lu), "diagNo=0, = " // CHAR_LF // CHAR_LF )
See results
diagNo=0, =
7.9596 | 0.4582 | 9.668 | 3.2888 |
0 | 8.812 | 8.1055 | 0.42248 |
0 | 0 | 8.3696 | 0.61326 |
0 | 0 | 0 | 1.9634 |
CALL GetTriu(A=A, diagNo=1, lu=lu)
CALL Display(MdEncode(lu), "diagNo=1, = " // CHAR_LF // CHAR_LF)
See results
diagNo=1, =
0 | 0.4582 | 9.668 | 3.2888 |
0 | 0 | 8.1055 | 0.42248 |
0 | 0 | 0 | 0.61326 |
0 | 0 | 0 | 0 |
CALL GetTriu(A=A, diagNo=2, lu=lu)
CALL Display(MdEncode(lu), "diagNo=2, = " // CHAR_LF // CHAR_LF )
See results
diagNo=2, =
0 | 0 | 9.668 | 3.2888 |
0 | 0 | 0 | 0.42248 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
end program main
This example shows the use of GetTriu.
program main
use easifemBase
implicit none
Testing for Square matrix Let's get the upper triangular form above Subdiagonals.
REAL( Real32 ) :: A( 4, 4 ), lu(4,4)
CALL RANDOM_NUMBER(A); A = A*10
CALl Display(MdEncode(A), "A = " // CHAR_LF // CHAR_LF)
CALL GetTriu(A=A,diagNo=-1, lu=lu)
CALL Display(MdEncode(lu), "diagNo=-1, = " // CHAR_LF // CHAR_LF)
CALL GetTriu(A=A,diagNo=-2, lu=lu)
CALL Display(MdEncode(lu), "diagNo=-2, = " // CHAR_LF // CHAR_LF )
See results
A =
4.3601 | 7.6972 | 7.6983 | 2.2272 |
6.2194 | 1.4554 | 1.4307 | 9.2086 |
8.7748 | 4.4743 | 9.8157 | 7.9489 |
9.6914 | 8.4748 | 5.7968 | 1.1776 |
diagNo=-1, =
4.3601 | 7.6972 | 7.6983 | 2.2272 |
6.2194 | 1.4554 | 1.4307 | 9.2086 |
0 | 4.4743 | 9.8157 | 7.9489 |
0 | 0 | 5.7968 | 1.1776 |
diagNo=-2, =
4.3601 | 7.6972 | 7.6983 | 2.2272 |
6.2194 | 1.4554 | 1.4307 | 9.2086 |
8.7748 | 4.4743 | 9.8157 | 7.9489 |
0 | 8.4748 | 5.7968 | 1.1776 |
end program main