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
vdotg_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

   vdotg_c ( Vector dot product, general dimension ) 

   SpiceDouble vdotg_c ( ConstSpiceDouble   * v1,
                         ConstSpiceDouble   * v2,
                         SpiceInt             ndim )

Abstract

   Compute the dot product of two vectors of arbitrary dimension.

Required_Reading

   None.

Keywords

   VECTOR


Brief_I/O

   VARIABLE  I/O  DESCRIPTION
   --------  ---  --------------------------------------------------
   v1         I   First vector in the dot product.
   v2         I   Second vector in the dot product.
   ndim       I   Dimension of `v1' and `v2'.

   The function returns the value of the dot product of `v1' and `v2'.

Detailed_Input

   v1,
   v2          are two arbitrary double precision n-dimensional
               vectors.

   ndim        is the dimension of `v1' and `v2'.

Detailed_Output

   The function returns the value of the dot product (inner product)
   of `v1' and `v2':

      < v1, v2 >

Parameters

   None.

Exceptions

   Error free.

Files

   None.

Particulars

   vdotg_c calculates the dot product of `v1' and `v2' by a simple
   application of the definition:

                  ndim-1
                 .------
                  \
      vdotg_c  =   )  v1[i] * v2[i]
                  /
                 '------
                    i=0

   No error checking is performed to prevent or recover from numeric
   overflow.

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) Suppose that you have a set of double precision n-dimensional
      vectors. Check if they are orthogonal to the Z-axis in
      n-dimensional space.


      Example code begins here.


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

      int main( )
      {

         /.
         Local parameters.
         ./
         #define NDIM         4
         #define SETSIZ       5

         /.
         Local variables.
         ./
         SpiceInt             i;

         /.
         Define the vector set.
         ./
         SpiceDouble          v1     [SETSIZ][NDIM] = {
                                   { 1.0,  0.0,  0.0, 0.0 },
                                   { 0.0,  1.0,  0.0, 3.0 },
                                   { 0.0,  0.0, -6.0, 0.0 },
                                   {10.0,  0.0, -1.0, 0.0 },
                                   { 0.0,  0.0,  0.0, 1.0 } };

         SpiceDouble          z      [NDIM] = { 0.0,  0.0,  1.0, 0.0 };

         /.
         Check the orthogonality with respect to `z' of each
         vector in `v1'.
         ./
         for ( i = 0; i < SETSIZ; i++ )
         {

            printf( "\n" );
            printf( "Input vector (V1):  %5.1f %5.1f %5.1f %5.1f\n",
                              v1[i][0], v1[i][1], v1[i][2], v1[i][3] );

            if ( vdotg_c ( v1[i], z, NDIM ) == 0.0 )
            {
               printf( "V1 and Z are orthogonal.\n" );
            }
            else
            {
               printf( "V1 and Z are NOT orthogonal.\n" );
            }

         }

         return ( 0 );
      }


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


      Input vector (V1):    1.0   0.0   0.0   0.0
      V1 and Z are orthogonal.

      Input vector (V1):    0.0   1.0   0.0   3.0
      V1 and Z are orthogonal.

      Input vector (V1):    0.0   0.0  -6.0   0.0
      V1 and Z are NOT orthogonal.

      Input vector (V1):   10.0   0.0  -1.0   0.0
      V1 and Z are NOT orthogonal.

      Input vector (V1):    0.0   0.0   0.0   1.0
      V1 and Z are orthogonal.

Restrictions

   1)  The user is responsible for determining that the vectors `v1'
       and `v2' are not so large as to cause numeric overflow. In
       most cases this will not present a problem.

Literature_References

   None.

Author_and_Institution

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

Version

   -CSPICE Version 1.2.0, 13-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added complete
       code example. Improved -Particulars section.

       Removed check for "ndim" being positive in order to replicate
       behavior of SPICELIB equivalent routine.

   -CSPICE Version 1.1.0, 22-OCT-1998 (NJB)

       Made input vectors const. Converted check-in style to discovery.

   -CSPICE Version 1.0.0, 31-MAR-1998 (EDW) (WMO)

Index_Entries

   dot product of n-dimensional vectors
Fri Dec 31 18:41:14 2021