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_vzerog

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


Abstract


   CSPICE_VZEROG indicates whether an n-dimensional vector is the zero
   vector.

I/O


   Given:

      v        any double precision vector of arbitrary dimension.

               help, v
                  DOUBLE = Array[N]

   the call:

      vzerog = cspice_vzerog( v )

   returns:

      vzerog   the value True if and only if `v' is the zero vector.

               help, vzerog
                  BOOLEAN = Scalar

Parameters


   None.

Examples


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

   1) Given a set of n-dimensional vectors, check which ones are
      the zero vector.


      Example code begins here.


      PRO vzerog_ex1

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

         ;;
         ;; Define the vector set.
         ;;
         v      = [[0.D0,  0.D0,  0.D0,  2.D-7], [0.D0,  0.D0,  0.D0,  0.D0]]

         ;;
         ;; Check each n-dimensional vector within the set.
         ;;
         for i=0L, SETSIZ-1L do begin

            ;;
            ;; Check if the I'th vector is the zero vector.
            ;;
            print
            print, format='(A,4F11.7)', 'Input vector: ', v[*,i]

            if ( cspice_vzerog( v[*,i] ) ) then begin

               print, format='(A)', '   The zero vector.'

            endif else begin
               print, format='(A)', '   Not all elements of the vector' +    $
                                    ' are zero.'

            endelse

         endfor

      END


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


      Input vector:   0.0000000  0.0000000  0.0000000  0.0000002
         Not all elements of the vector are zero.

      Input vector:   0.0000000  0.0000000  0.0000000  0.0000000
         The zero vector.


   2) Define a unit quaternion and confirm that it is non-zero
      before converting it to a rotation matrix.


      Example code begins here.


      PRO vzerog_ex2

         ;;
         ;; Define a unit quaternion.
         ;;
         s = sqrt( 2.D0 ) / 2.D0

         q = [ s, 0.D0, 0.d0, -s ]

         print, format='(A,4F12.7)', 'Quaternion :', q

         ;;
         ;; Confirm that it is non-zero and
         ;;
         if ( cspice_vzerog( q ) ) then begin

            print, '   Quaternion is the zero vector.'

         endif else begin

            ;;
            ;; Confirm q satisfies ||q|| = 1.
            ;;
            print, format='(A,F12.7)', 'Norm       :', cspice_vnormg( q )

            ;;
            ;; Convert the quaternion to a matrix form.
            ;;
            cspice_q2m, q, m

            print, format='(A)', 'Matrix form:'
            print, format='(3F12.7)', m

         endelse

      END


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


      Quaternion :   0.7071068   0.0000000   0.0000000  -0.7071068
      Norm       :   1.0000000
      Matrix form:
         0.0000000   1.0000000   0.0000000
        -1.0000000   0.0000000  -0.0000000
        -0.0000000   0.0000000   1.0000000


Particulars


   This function has the same truth value as the logical expression

      ( cspice_vnormg( v )  eq  0.d0 )

   Replacing the above expression by

      cspice_vzerog ( v )

   has several advantages: the latter expresses the test more
   clearly, looks better, and doesn't go through the work of scaling,
   squaring, taking a square root, and re-scaling (all of which
   cspice_vnormg must do) just to find out that a vector is non-zero.

   A related function is cspice_vzero, which accepts three-dimensional
   vectors.

Exceptions


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

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

Files


   None.

Restrictions


   None.

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, 10-AUG-2021 (JDR)

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

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


   test whether an n-dimensional vector is the zero vector



Fri Dec 31 18:43:09 2021