.i.

 


   more...


   more...

Computes the inverse matrix.

Operator Return Value

Matrix containing the inverse of A. (Output)

Required Operand

A — Matrix for which the inverse is to be computed. This is an array of rank 2 or 3. It may be real, double, complex, double complex. (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 .i.

Option Value

Use_lin_sol_gen_only

1

Use_lin_sol_lsq_only

2

I_options_for_lin_sol_gen

3

I_options_for_lin_sol_lsq

4

Skip_error_processing

5

 

Name of Unallocated Option Array to Use for Setting Options

Use

Derived Type

?_inv_options(:)

Use when setting options for calls hereafter.

?_options

?_inv_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

.i. A

Description

Computes the inverse matrix for square non-singular matrices using LIN_SOL_GEN, or the Moore-Penrose generalized inverse matrix for singular square matrices or rectangular matrices using LIN_SOL_LSQ. The operation may be read inverse or generalized inverse, and the results are in a precision and data type that matches the operand.

This operator requires a single operand. Since this is a unary operation, it has higher Fortran 90 precedence than any other intrinsic array operation. 

Examples

Dense Matrix Example (operator_ex02.f90)

 

use linear_operators

implicit none

 

! This is the equivalent of Example 2 for LIN_SOL_GEN using operators

! and functions.

 

integer, parameter :: n=32

real(kind(1e0)) :: one=1e0, err, det_A, det_i

real(kind(1e0)), dimension(n,n) :: A, inv

 

! Generate a random matrix.

A = rand(A)

! Compute the matrix inverse and its determinant.

inv = .i.A; det_A = det(A)

! Compute the determinant for the inverse matrix.

det_i = det(inv)

! Check the quality of both left and right inverses.

err = (norm(EYE(n)-(A .x. inv))+norm(EYE(n)-(inv.x.A)))/cond(A)

if (err <= sqrt(epsilon(one)) .and. abs(det_A*det_i - one) <= &

sqrt(epsilon(one))) &

write (*,*) 'Example 2 for LIN_SOL_GEN (operators) is correct.'

end

Parallel Example (parallel_ex02.f90)

 

use linear_operators

use mpi_setup_int

 

implicit none

 

! This is the equivalent of Parallel Example 2 for .i. and det() with box

! data types, operators and functions.

 

integer, parameter :: n=32, nr=4

integer J

real(kind(1e0)) :: one=1e0

real(kind(1e0)), dimension(nr) :: err, det_A, det_i

real(kind(1e0)), dimension(n,n,nr) :: A, inv, R, S

 

! Setup for MPI.

MP_NPROCS=MP_SETUP()

! Generate a random matrix.

A = rand(A)

! Compute the matrix inverse and its determinant.

inv = .i.A; det_A = det(A)

! Compute the determinant for the inverse matrix.

det_i = det(inv)

! Check the quality of both left and right inverses.

DO J=1,nr; R(:,:,J)=EYE(N); END DO

 

S=R; R=R-(A .x. inv); S=S-(inv .x. A)

err = (norm(R)+norm(S))/cond(A)

if (ALL(err <= sqrt(epsilon(one)) .and. &

abs(det_A*det_i - one) <= sqrt(epsilon(one)))&

.and. MP_RANK == 0) &

write (*,*) 'Parallel Example 2 is correct.'

 

! See to any error messages and quit MPI.

MP_NPROCS=MP_SETUP('Final')

 

end