1 /*
2 
3 -Procedure vlcomg_c ( Vector linear combination, general dimension )
4 
5 -Abstract
6 
7    Compute a vector linear combination of two double precision
8    vectors of arbitrary dimension.
9 
10 -Disclaimer
11 
12    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
13    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
14    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
15    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
16    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
17    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
18    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
19    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
20    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
21    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
22 
23    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
24    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
25    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
26    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
27    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
28    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
29 
30    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
31    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
32    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
33    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
34 
35 -Required_Reading
36 
37    None.
38 
39 -Keywords
40 
41    VECTOR
42 
43 */
44 
45    #include "SpiceUsr.h"
46    #undef   vlcomg_c
47 
vlcomg_c(SpiceInt n,SpiceDouble a,ConstSpiceDouble * v1,SpiceDouble b,ConstSpiceDouble * v2,SpiceDouble * sum)48    void vlcomg_c ( SpiceInt            n,
49                    SpiceDouble         a,
50                    ConstSpiceDouble *  v1,
51                    SpiceDouble         b,
52                    ConstSpiceDouble *  v2,
53                    SpiceDouble      *  sum )
54 
55 /*
56 
57 -Brief_I/O
58 
59     VARIABLE  I/O  DESCRIPTION
60     --------  ---  --------------------------------------------------
61     n          I   Dimension of vector space
62     a          I   Coefficient of v1
63     v1         I   Vector in n-space
64     b          I   Coefficient of v2
65     v2         I   Vector in n-space
66     sum        O   Linear Vector Combination a*v1 + b*v2
67 
68 -Detailed_Input
69 
70     n   This variable contains the dimension of the v1, v2 and sum.
71     a   This double precision variable multiplies v1.
72     v1  This is an arbitrary, double precision n-dimensional vector.
73     b   This double precision variable multiplies v2.
74     v2  This is an arbitrary, double precision n-dimensional vector.
75 
76 -Detailed_Output
77 
78     sum   is an arbitrary, double precision n-dimensional vector
79           which contains the linear combination a*v1 + b*v2.
80 
81 -Parameters
82 
83     None.
84 
85 -Particulars
86 
87     For each index from 1 to n, this routine implements in C
88     code the expression:
89 
90     sum[i] = a*v1[i] + b*v2[i]
91 
92     No error checking is performed to guard against numeric overflow.
93 
94 -Examples
95 
96     We can easily use this routine to perform vector projections
97     to 2-planes in n-space.  Let x be an arbitray n-vector
98     and let u and v be orthonormal n-vectors spanning the plane
99     of interest.  The projection of x onto this 2-plane, projuv can
100     be obtained by the following code fragment.
101 
102        vlcomg_c ( n, vdot_c(x,u,n), u, vdot_c(x,v,n), v, projuv );
103 
104 -Restrictions
105 
106     No error checking is performed to guard against numeric overflow
107     or underflow.  The user is responsible for insuring that the
108     input values are reasonable.
109 
110 -Exceptions
111 
112    Error free.
113 
114 -Files
115 
116     None
117 
118 -Author_and_Institution
119 
120     W.L. Taber      (JPL)
121 
122 -Literature_References
123 
124     None
125 
126 -Version
127 
128    -CSPICE Version 1.0.0, 30-JUN-1999
129 
130 -Index_Entries
131 
132    linear combination of two n-dimensional vectors
133 
134 -&
135 */
136 
137 { /* Begin vlcomg_c */
138 
139    /*
140    Local variables
141    */
142    SpiceInt       i;
143 
144 
145    /* A simple loop to do the work. */
146    for ( i = 0; i < n; i++ )
147       {
148       sum[i] = a*v1[i] + b*v2[i];
149       }
150 
151 
152 } /* End vlcomg_c */
153