- Abstract
Normalize a double precision vector of arbitrary dimension and
return its magnitude.
- Required_Reading
None.
- Brief_I/O
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
v1 I Vector to be normalized.
ndim I Dimension of v1 (and also vout).
vout O Unit vector v1 / |v1|.
If v1 = 0, vout will also be zero.
vout can overwrite v1.
vmag O Magnitude of v1, that is, |v1|.
- Detailed_Input
v1 This variable may contain any vector of arbitrary
dimension, including the zero vector.
ndim This is the dimension of v1 and vout.
- Detailed_Output
vout This variable contains the unit vector in the direction
of v1. If v1 is the zero vector, then vout will also be
the zero vector.
vmag This is the magnitude of v1.
- Parameters
None.
- Particulars
unormg_c references a function called vnormg_c (which itself is
numerically stable) to calculate the norm of the input vector v1.
If the norm is equal to zero, then each component of the output
vector vout is set to zero. Otherwise, vout is calculated by
dividing v1 by the norm. No error detection or correction is
implemented.
- Examples
The following table shows how selected v1 implies vout and mag.
v1 ndim vout mag
-----------------------------------------------------------------
(5, 12) 2 (5/13, 12/13) 13
(1D-7, 2D-7, 2D-7) 3 (1/3, 2/3, 2/3) 3D-7
- Restrictions
No error checking is implemented in this subroutine to guard
against numeric overflow.
- Exceptions
1) If ndim is not physically realistic, greater than zero, a
BADDIMENSION error is flagged.
- Files
None.
- Author_and_Institution
W.M. Owen (JPL)
W.L. Taber (JPL)
E.D. Wright (JPL)
- Literature_References
None.
- Version
-CSPICE Version 1.1.0, 22-OCT-1998 (NJB)
Made input vector const. Converted check-in style to discovery.
-CSPICE Version 1.0.0, 31-MAR-1998 (EDW)
- Index_Entries
n-dimensional unit vector and norm
- Link to routine source