Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_unormg

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_UNORMG normalizes a double precision vector of arbitrary dimension
   and returns its magnitude.

I/O


   Given:

      v1       an arbitrary double precision n-dimensional vector, including
               the zero vector.

               help, v1
                  DOUBLE = Array[N]

   the call:

      cspice_unormg, v1, vout, vmag

   returns:

      vout     the double precision n-dimensional unit vector in the direction
               of `v1'.

               help, vout
                  DOUBLE = Array[N]

               If `v1' is the zero vector, then `vout' will also be the zero
               vector.

      vmag     the magnitude of `v1'.

               help, vmag
                  DOUBLE = Scalar

Parameters


   None.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) Define a set of n-dimensional vectors and compute their
      corresponding unit vectors and magnitudes.


      Example code begins here.


      PRO unormg_ex1

         ;;
         ;; Local parameters.
         ;;
         SETSIZ =   2L

         ;;
         ;; Define the vector set.
         ;;
         v1     = [ [ 5.D0,   12.D0,  0.D0,  4.D0 ],                         $
                    [ 1.D-6,  2.D-6,  2.D-6, 0.D0 ] ]

         ;;
         ;; Calculate the unit vectors and magnitudes.
         ;;
         for i=0L, SETSIZ-1L do begin

            cspice_unormg, v1[*,i], vout, vmag

            print, format='(A,4F12.7)', 'Vector     :', v1[*,i]
            print, format='(A,4F12.7)', 'Unit vector:', vout
            print, format='(A,F12.7)',  'Magnitude  :', vmag
            print

         endfor

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Vector     :   5.0000000  12.0000000   0.0000000   4.0000000
      Unit vector:   0.3676073   0.8822575   0.0000000   0.2940858
      Magnitude  :  13.6014705

      Vector     :   0.0000010   0.0000020   0.0000020   0.0000000
      Unit vector:   0.3333333   0.6666667   0.6666667   0.0000000
      Magnitude  :   0.0000030


Particulars


   cspice_unormg references a function called cspice_vnormg (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.

   IDL native code to perform the same operation:

      vmag  =  norm(v1)
      vout  =  v1/vmag

   The native IDL functions also accept arbitrary sized vectors.

Exceptions


   1)  If the input argument `v1' is undefined, an error is signaled
       by the IDL error handling system.

   2)  If the input argument `v1' is not of the expected type, or it
       does not have the expected dimensions and size, an error is
       signaled by the Icy interface.

   3)  If any of the output arguments, `vout' or `vmag', is not a
       named variable, an error is signaled by the Icy interface.

Files


   None.

Restrictions


   1)  No error checking is implemented in this routine to guard
       against numeric overflow.

Required_Reading


   ICY.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.2, 27-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added complete
       code examples.

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections, and
       completed -Particulars section.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.1, 09-DEC-2005 (EDW)

       Added -Examples section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   n-dimensional unit vector and norm



Fri Dec 31 18:43:08 2021