4.8 psb_norm2 — 2-Norm of Vector
This function computes the 2-norm of a vector x.
If x is a real vector it computes 2-norm as:
else if x is a complex vector then it computes 2-norm as:
|nrm2 ||x ||Function |
|Short Precision Real||Short Precision Real ||psb_genrm2
|Long Precision Real ||Long Precision Real ||psb_genrm2
|Short Precision Real||Short Precision Complex||psb_genrm2
|Long Precision Real ||Long Precision Complex ||psb_genrm2
Table 8: Data types
psb_genrm2(x, desc_a, info [,global])
psb_norm2(x, desc_a, info [,global])
- the local portion of global dense matrix x.
Specified as: a rank one or two array or an object of type
psb_T_vect_type containing numbers of type specified in Table 8.
- contains data structures for communications.
Specified as: an object of type psb_desc_type.
- Specifies whether the computation should include the global reduction
across all processes.
Specified as: a logical scalar. Default: global=.true.
- is the 2-norm of vector x.
Scope: global unless the optional variable global=.false. has been
Specified as: a long precision real number.
- Error code.
An integer value; 0 means no error has been detected.
- The computation of a global result requires a global communication, which
entails a significant overhead. It may be necessary and/or advisable to compute
multiple norms at the same time; in this case, it is possible to improve the
runtime efficiency by using the following scheme:
vres(1) = psb_genrm2(x1,desc_a,info,global=.false.) vres(2) = psb_genrm2(x2,desc_a,info,global=.false.) vres(3) = psb_genrm2(x3,desc_a,info,global=.false.) call psb_nrm2(ctxt,vres(1:3))
In this way the global communication, which for small sizes is a latency-bound
operation, is invoked only once.