.xi.

   more...

   more...
Computes the product of a matrix or vector and the inverse of a matrix.
Operator Return Value
Matrix containing the product of A and B-1. (Output)
Required Operands
A — Right operand matrix or vector. This is an array of rank 1, 2, or 3. It may be real, double, complex, or double complex. (Input)
B — Left operand matrix. This is an array of rank 2 or 3. It may be real, double, complex, double complex, or one of the computational sparse matrix derived types, ?_hbc_sparse. (Input)
Optional Variables, Reserved Names
This operator uses the routines LIN_SOL_GEN or LIN_SOL_LSQ (See Chapter 1, “Linear Systems” ).
The option and derived type names are given in the following tables:
Option Names for .xi.
Option Value
Use_lin_sol_gen_only
1
Use_lin_sol_lsq_only
2
xi_options_for_lin_sol_gen
3
xi_options_for_lin_sol_lsq
4
Skip_error_processing
5
Name of Unallocated Option Array to Use for Setting Options
Use
Derived Type
?_xinv_options(:)
Use when setting options for calls hereafter.
?_options
?_xinv_options_once(:)
Use when setting options for next call only.
?_options
For a description on how to use these options, see Matrix Optional Data Changes. See LIN_SOL_GEN and LIN_SOL_LSQ in Chapter 1, “Linear Systems” for the specific options for these routines.
FORTRAN 90 Interface
A .xi. B
Description
Computes the product of matrix A and the inverse of matrix B, for square non-singular matrices or the corresponding Moore-Penrose generalized inverse matrix for singular square matrices or rectangular matrices. The operation may be read times generalized inverse. The results are in a precision and data type that matches the most accurate or complex operand.
.xi. can be used with either dense or sparse matrices. It is MPI capable for dense matrices only.
Examples
Dense Matrix Example
 
use linear_operators
implicit none
 
integer, parameter :: n=32
real(kind(1e0)) :: one=1.0e0, err
real(kind(1e0)), dimension(n,n) :: A, b, x
 
! Generate random matrices for A and b:
A = rand(A); b=rand(b)
 
! Compute the solution matrix of xA = b.
x = b .xi. A
 
! Check the results.
err = norm(b - (x .x. A))/(norm(A)*norm(x)+norm(b))
if (err <= sqrt(epsilon(one))) &
write (*,*) 'Example for .xi. operator is correct.'
end
Sparse Matrix Example
 
use wrrrn_int
use linear_operators
 
type (s_sparse) S
type (s_hbc_sparse) H
integer, parameter :: N=3
real (kind(1.e0)) x(N,N), y(N,N), a(N,N)
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
A = rand(A)
Y = A .xi. H
call wrrrn ( 'A', A)
call wrrrn ( 'H', X)
call wrrrn ( 'A .xi. H', y)
 
! Check the results.
err = norm(y - (A .xi. X))
if (err <= sqrt(epsilon(one))) then
write (*,*) 'Sparse example for .xi. operator is correct.'
end if
 
end
Output
 
A
1 2 3
1 0.5926 0.5015 0.5368
2 0.4001 0.9529 0.6988
3 0.0412 0.0633 0.3821
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
A .xi. H
1 2 3
1 0.2963 0.1254 0.0401
2 0.2001 0.2382 0.0831
3 0.0206 0.0158 0.0602
Sparse example for .xi. operator is correct.
Parallel Example
 
use linear_operators
use mpi_setup_int
implicit none
 
! This is the equivalent of Parallel Example 1 for .xi., with box data types
! and functions.
 
integer, parameter :: n=32, nr=4
real(kind(1e0)) :: one=1e0
real(kind(1e0)), dimension(n,n,nr) :: A, b, x, err(nr)
 
! Setup for MPI.
MP_NPROCS=MP_SETUP()
! Generate random matrices for A and b:
A = rand(A); b=rand(b)
 
! Compute the box solution matrix of xA = b.
x = b .xi. A
 
! Check the results.
err = norm(b - (x .x. A))/(norm(A)*norm(x)+norm(b))
if (ALL(err <= sqrt(epsilon(one))) .and. MP_RANK == 0) &
write (*,*) 'Parallel Example 1 is correct.'
 
! See to any error messages and quit MPI.
MP_NPROCS=MP_SETUP('Final')
end