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
vnorm_c

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version
Index_Entries

Procedure

   vnorm_c ( Vector norm, 3 dimensions ) 

   SpiceDouble vnorm_c ( ConstSpiceDouble v1[3] )

Abstract

   Compute the magnitude of a double precision 3-dimensional
   vector.

Required_Reading

   None.

Keywords

   VECTOR


Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   v1         I   Vector whose magnitude is to be found.

   The function returns the magnitude of `v1'.

Detailed_Input

   v1          is any double precision 3-dimensional vector.

Detailed_Output

   The function returns the magnitude of `v1' calculated in a
   numerically stable way.

Parameters

   None.

Exceptions

   Error free.

Files

   None.

Particulars

   vnorm_c takes care to avoid overflow while computing the norm of the
   input vector `v1'. vnorm_c finds the component of `v1' whose magnitude
   is the largest. Calling this magnitude `v1max', the norm is computed
   using the formula:

                        ||    1         ||
      vnorm_c = v1max * || ------- * v1 ||
                        ||  v1max       ||

   where the notation ||x|| indicates the norm of the vector `x'.

Examples

   The numerical results shown for this example may differ across
   platforms. The results depend on the SPICE kernels used as
   input, the compiler and supporting libraries, and the machine
   specific arithmetic implementation.

   1) Define a set of 3-dimensional vectors and compute the
      magnitude of each vector within.


      Example code begins here.


      /.
         Program vnorm_ex1
      ./
      #include <stdio.h>
      #include "SpiceUsr.h"

      int main( )
      {

         /.
         Local parameters.
         ./
         #define SETSIZ       3

         /.
         Local variables.
         ./
         SpiceInt             i;

         /.
         Define a set of 3-dimensional vectors.
         ./
         SpiceDouble          v1     [SETSIZ][3] = {
                                   { 1.0,    2.0,  2.0   },
                                   { 5.0,   12.0,  0.0   },
                                   {-5.e-17, 0.0, 12.e-17}  };

         /.
         Calculate the magnitude of each vector
         ./
         for ( i = 0; i < SETSIZ; i++ )
         {

            printf( "Input vector:  %9.2e %9.2e %9.2e\n",
                                   v1[i][0], v1[i][1], v1[i][2] );
            printf( "Magnitude   :  %23.20f\n", vnorm_c ( v1[i] ) );
            printf( "\n" );

         }

         return ( 0 );
      }


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


      Input vector:   1.00e+00  2.00e+00  2.00e+00
      Magnitude   :   3.00000000000000000000

      Input vector:   5.00e+00  1.20e+01  0.00e+00
      Magnitude   :  13.00000000000000000000

      Input vector:  -5.00e-17  0.00e+00  1.20e-16
      Magnitude   :   0.00000000000000013000

Restrictions

   None.

Literature_References

   None.

Author_and_Institution

   N.J. Bachman        (JPL)
   J. Diaz del Rio     (ODC Space)
   W.M. Owen           (JPL)
   W.L. Taber          (JPL)
   E.D. Wright         (JPL)

Version

   -CSPICE Version 1.0.3, 05-JUL-2021 (JDR)

       Edited the header to comply with NAIF standard. Added complete
       code example based on existing example.

   -CSPICE Version 1.0.2, 16-JAN-2008 (EDW)

       Corrected typos in header titles:

       Detailed Input to -Detailed_Input
       Detailed Output to -Detailed_Output

   -CSPICE Version 1.0.1, 12-NOV-2006 (EDW)

       Added -Parameters section header.

   -CSPICE Version 1.0.0, 16-APR-1999 (NJB) (WMO) (WLT)

Index_Entries

   norm of 3-dimensional vector
Fri Dec 31 18:41:15 2021