/src/vzerog.c

https://github.com/mattbornski/spice · C · 193 lines · 16 code · 64 blank · 113 comment · 3 complexity · c3ff68b90ea1e762caf00e75ccf3246a MD5 · raw file

  1. /* vzerog.f -- translated by f2c (version 19980913).
  2. You must link the resulting object file with the libraries:
  3. -lf2c -lm (in that order)
  4. */
  5. #include "f2c.h"
  6. /* $Procedure VZEROG ( Is a vector the zero vector?---general dim. ) */
  7. logical vzerog_(doublereal *v, integer *ndim)
  8. {
  9. /* System generated locals */
  10. integer i__1;
  11. logical ret_val;
  12. /* Local variables */
  13. integer i__;
  14. /* $ Abstract */
  15. /* Indicate whether a general-dimensional vector is the zero vector. */
  16. /* $ Disclaimer */
  17. /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
  18. /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
  19. /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
  20. /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
  21. /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
  22. /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
  23. /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
  24. /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
  25. /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
  26. /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
  27. /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
  28. /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
  29. /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
  30. /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
  31. /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
  32. /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
  33. /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
  34. /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
  35. /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
  36. /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
  37. /* $ Required_Reading */
  38. /* None. */
  39. /* $ Keywords */
  40. /* MATH */
  41. /* VECTOR */
  42. /* $ Declarations */
  43. /* $ Brief_I/O */
  44. /* Variable I/O Description */
  45. /* -------- --- -------------------------------------------------- */
  46. /* V I Vector to be tested. */
  47. /* NDIM I Dimension of V. */
  48. /* The function returns the value .TRUE. if and only if V is the */
  49. /* zero vector. */
  50. /* $ Detailed_Input */
  51. /* V, */
  52. /* NDIM are, respectively, a vector and its dimension. */
  53. /* $ Detailed_Output */
  54. /* The function returns the value .TRUE. if and only if V is the */
  55. /* zero vector. */
  56. /* $ Parameters */
  57. /* None. */
  58. /* $ Exceptions */
  59. /* Error free. */
  60. /* 1) When NDIM is non-positive, this function returns the value */
  61. /* .FALSE. (A vector of non-positive dimension cannot be the */
  62. /* zero vector.) */
  63. /* $ Files */
  64. /* None. */
  65. /* $ Particulars */
  66. /* This function has the same truth value as the logical expression */
  67. /* VNORMG ( V, NDIM ) .EQ. 0.D0 */
  68. /* Replacing the above expression by */
  69. /* VZEROG ( V, NDIM ) */
  70. /* has several advantages: the latter expresses the test more */
  71. /* clearly, looks better, and doesn't go through the work of scaling, */
  72. /* squaring, taking a square root, and re-scaling (all of which */
  73. /* VNORMG must do) just to find out that a vector is non-zero. */
  74. /* A related function is VZERO, which accepts three-dimensional */
  75. /* vectors. */
  76. /* $ Examples */
  77. /* 1) When testing whether a vector is the zero vector, one */
  78. /* normally constructs tests like */
  79. /* IF ( VNORMG ( V, NDIM ) .EQ. 0.D0 ) THEN */
  80. /* . */
  81. /* . */
  82. /* . */
  83. /* These can be replaced with the code */
  84. /* IF ( VZEROG ( V, NDIM ) ) THEN */
  85. /* . */
  86. /* . */
  87. /* . */
  88. /* 2) Make sure that a `unit' quaternion is non-zero before */
  89. /* converting it to a rotation matrix. */
  90. /* IF ( VZEROG ( Q, 4 ) ) THEN */
  91. /* [ handle error ] */
  92. /* ELSE */
  93. /* CALL VHATG ( Q, 4, Q ) */
  94. /* CALL Q2M ( Q, M ) */
  95. /* . */
  96. /* . */
  97. /* . */
  98. /* $ Restrictions */
  99. /* None. */
  100. /* $ Literature_References */
  101. /* None. */
  102. /* $ Author_and_Institution */
  103. /* N.J. Bachman (JPL) */
  104. /* I.M. Underwood (JPL) */
  105. /* $ Version */
  106. /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
  107. /* Comment section for permuted index source lines was added */
  108. /* following the header. */
  109. /* - SPICELIB Version 1.0.0, 18-JUL-1990 (NJB) (IMU) */
  110. /* -& */
  111. /* $ Index_Entries */
  112. /* test whether an n-dimensional vector is the zero vector */
  113. /* -& */
  114. /* Local variables */
  115. /* Leave as soon as we find a non-zero component. If we get through */
  116. /* the loop, we have a zero vector, as long as the vector's dimension */
  117. /* is valid. */
  118. i__1 = *ndim;
  119. for (i__ = 1; i__ <= i__1; ++i__) {
  120. if (v[i__ - 1] != 0.) {
  121. ret_val = FALSE_;
  122. return ret_val;
  123. }
  124. }
  125. /* We have a zero vector if and only if the vector's dimension is at */
  126. /* least 1. */
  127. ret_val = *ndim >= 1;
  128. return ret_val;
  129. } /* vzerog_ */