.t.
Computes the transpose of a matrix.
Operator Return Value
Matrix containing the transpose of A. (Output)
Required Operand
A — Matrix for which the transpose is to be computed. This is a real, double, complex, double complex, or one of the computational sparse matrix derived types, c_hbc_sparse or z_hbc_sparse. (Input).
FORTRAN 90 Interface
.t. A
Description
Computes the transpose of matrix A. The operation may be read transpose, and the results are the mathematical objects in a precision and data type that matches the operand. Since this is a unary operation, it has higher Fortran 90 precedence than any other intrinsic unary array operation.
.t. can be used with either dense or sparse matrices.
Examples
Dense Matrix Example (operator_ex07.f90)
use linear_operators
implicit none
! This is the equivalent of Example 3 (using operators) for LIN_SOL_SELF.
integer tries
integer, parameter :: m=8, n=4, k=2
integer ipivots(n+1)
real(kind(1d0)) :: one=1.0d0, err
real(kind(1d0)) a(n,n), b(n,1), c(m,n), x(n,1), &
e(n), ATEMP(n,n)
type(d_options) :: iopti(4)
! Generate a random rectangular matrix.
C = rand(C)
! Generate a random right hand side for use in the inverse
! iteration.
b = rand(b)
! Compute the positive definite matrix.
A = C .tx. C; A = (A+.t.A)/2
! Obtain just the eigenvalues.
E = EIG(A)
! Use packaged option to reset the value of a small diagonal.
iopti(4) = 0
iopti(1) = d_options(d_lin_sol_self_set_small,&
epsilon(one)*abs(E(1)))
! Use packaged option to save the factorization.
iopti(2) = d_lin_sol_self_save_factors
! Suppress error messages and stopping due to singularity
! of the matrix, which is expected.
iopti(3) = d_lin_sol_self_no_sing_mess
ATEMP = A
! Compute A-eigenvalue*I as the coefficient matrix.
! Use eigenvalue number k.
A = A - e(k)*EYE(n)
do tries=1,2
call lin_sol_self(A, b, x, &
pivots=ipivots, iopt=iopti)
! When code is re-entered, the already computed factorization
! is used.
iopti(4) = d_lin_sol_self_solve_A
! Reset right-hand side in the direction of the eigenvector.
B = UNIT(x)
end do
! Normalize the eigenvector.
x = UNIT(x)
! Check the results.
b=ATEMP .x. x
err = dot_product(x(1:n,1), b(1:n,1)) - e(k)
! If any result is not accurate, quit with no printing.
if (abs(err) <= sqrt(epsilon(one))*E(1)) then
write (*,*) 'Example 3 for LIN_SOL_SELF (operators) is correct.'
end if
end
use wrrrn_int
use linear_operators
type (s_sparse) S
type (s_hbc_sparse) H, HT
integer, parameter :: N=3
real (kind(1.e0)) X(3,3), XT(3,3)
real (kind(1.e0)) err
S = s_entry (1, 1, 2.0)
S = s_entry (1, 3, 1.0)
S = s_entry (2, 2, 4.0)
S = s_entry (3, 3, 6.0)
H = S ! sparse
X = H ! dense equivalent of H
HT = .t. H
XT = HT ! dense equivalent of HT
call wrrrn ( 'H', X)
call wrrrn ( 'H Transpose', XT)
! Check the results.
err = norm(XT - (.t. X))
if (err <= sqrt(epsilon(one))) then
write (*,*) 'Sparse example for .t. operator is correct.'
end if
end
Output
H
1 2 3
1 2.000 0.000 1.000
2 0.000 4.000 0.000
3 0.000 0.000 6.000
H Transpose
1 2 3
1 2.000 0.000 0.000
2 0.000 4.000 0.000
3 1.000 0.000 6.000
Sparse example for .t. operator is correct.