rsspice/generated/spicelib/
vadd.rs

1//
2// GENERATED FILE
3//
4
5use super::*;
6use crate::SpiceContext;
7use f2rust_std::*;
8
9/// Vector addition, 3 dimensional
10///
11/// Add two double precision 3-dimensional vectors.
12///
13/// # Brief I/O
14///
15/// ```text
16///  VARIABLE  I/O  DESCRIPTION
17///  --------  ---  --------------------------------------------------
18///  V1         I   First vector to be added.
19///  V2         I   Second vector to be added.
20///  VOUT       O   Sum vector, V1 + V2.
21/// ```
22///
23/// # Detailed Input
24///
25/// ```text
26///  V1,
27///  V2       are two arbitrary double precision 3-dimensional
28///           vectors.
29/// ```
30///
31/// # Detailed Output
32///
33/// ```text
34///  VOUT     is the double precision 3-dimensional vector sum of V1
35///           and V2.
36/// ```
37///
38/// # Exceptions
39///
40/// ```text
41///  Error free.
42/// ```
43///
44/// # Particulars
45///
46/// ```text
47///  This routine simply performs addition between components of V1
48///  and V2. No checking is performed to determine whether floating
49///  point overflow has occurred.
50/// ```
51///
52/// # Examples
53///
54/// ```text
55///  The numerical results shown for this example may differ across
56///  platforms. The results depend on the SPICE kernels used as
57///  input, the compiler and supporting libraries, and the machine
58///  specific arithmetic implementation.
59///
60///  1) Define two sets of 3-dimensional vectors and compute the sum
61///     of each vector in first set with the corresponding vector in
62///     the second set.
63///
64///
65///     Example code begins here.
66///
67///
68///           PROGRAM VADD_EX1
69///           IMPLICIT NONE
70///
71///     C
72///     C     Local parameters.
73///     C
74///           INTEGER               SETSIZ
75///           PARAMETER           ( SETSIZ = 2 )
76///
77///     C
78///     C     Local variables.
79///     C
80///           DOUBLE PRECISION      SETA ( 3, SETSIZ )
81///           DOUBLE PRECISION      SETB ( 3, SETSIZ )
82///           DOUBLE PRECISION      VOUT ( 3 )
83///
84///           INTEGER               I
85///           INTEGER               J
86///
87///     C
88///     C     Define the two vector sets.
89///     C
90///           DATA                  SETA / 1.D0,  2.D0,  3.D0,
91///          .                             1.D-7, 1.D23, 1.D-9  /
92///
93///           DATA                  SETB / 4.D0,  5.D0,   6.D0,
94///          .                             1.D24, 1.D23,  0.D0  /
95///
96///     C
97///     C     Calculate the sum of each pair of vectors
98///     C
99///           DO I=1, SETSIZ
100///
101///              CALL VADD ( SETA(1,I), SETB(1,I), VOUT )
102///
103///              WRITE(*,'(A,3E11.2)') 'Vector A  : ',
104///          .                        ( SETA(J,I), J=1,3 )
105///              WRITE(*,'(A,3E11.2)') 'Vector B  : ',
106///          .                        ( SETB(J,I), J=1,3 )
107///              WRITE(*,'(A,3E11.2)') 'Sum vector: ', VOUT
108///              WRITE(*,*) ' '
109///
110///           END DO
111///
112///           END
113///
114///
115///     When this program was executed on a Mac/Intel/gfortran/64-bit
116///     platform, the output was:
117///
118///
119///     Vector A  :    0.10E+01   0.20E+01   0.30E+01
120///     Vector B  :    0.40E+01   0.50E+01   0.60E+01
121///     Sum vector:    0.50E+01   0.70E+01   0.90E+01
122///
123///     Vector A  :    0.10E-06   0.10E+24   0.10E-08
124///     Vector B  :    0.10E+25   0.10E+24   0.00E+00
125///     Sum vector:    0.10E+25   0.20E+24   0.10E-08
126/// ```
127///
128/// # Restrictions
129///
130/// ```text
131///  1)  The user is required to determine that the magnitude each
132///      component of the vectors is within the appropriate range so as
133///      not to cause floating point overflow.
134/// ```
135///
136/// # Author and Institution
137///
138/// ```text
139///  N.J. Bachman       (JPL)
140///  J. Diaz del Rio    (ODC Space)
141///  W.M. Owen          (JPL)
142///  W.L. Taber         (JPL)
143/// ```
144///
145/// # Version
146///
147/// ```text
148/// -    SPICELIB Version 1.1.0, 06-JUL-2021 (JDR)
149///
150///         Added IMPLICIT NONE statement.
151///
152///         Edited the header to comply with NAIF standard. Added complete
153///         code example based on existing example.
154///
155/// -    SPICELIB Version 1.0.2, 22-APR-2010 (NJB)
156///
157///         Header correction: assertions that the output
158///         can overwrite the input have been removed.
159///
160/// -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
161///
162///         Comment section for permuted index source lines was added
163///         following the header.
164///
165/// -    SPICELIB Version 1.0.0, 31-JAN-1990 (WMO)
166/// ```
167pub fn vadd(v1: &[f64; 3], v2: &[f64; 3], vout: &mut [f64; 3]) {
168    VADD(v1, v2, vout);
169}
170
171//$Procedure VADD ( Vector addition, 3 dimensional )
172pub fn VADD(V1: &[f64], V2: &[f64], VOUT: &mut [f64]) {
173    let V1 = DummyArray::new(V1, 1..=3);
174    let V2 = DummyArray::new(V2, 1..=3);
175    let mut VOUT = DummyArrayMut::new(VOUT, 1..=3);
176
177    VOUT[1] = (V1[1] + V2[1]);
178    VOUT[2] = (V1[2] + V2[2]);
179    VOUT[3] = (V1[3] + V2[3]);
180}