Table of contents
CSPICE_VLCOMG computes a vector linear combination of two double
precision vectors of arbitrary dimension.
Given:
a the double precision scalar variable that multiplies `v1'.
help, a
DOUBLE = Scalar
v1 an arbitrary, double precision n-dimensional vector.
help, v1
DOUBLE = Array[N]
b the double precision scalar variable that multiplies `v2'.
help, b
DOUBLE = Scalar
v2 an arbitrary, double precision n-dimensional vector.
help, v2
DOUBLE = Array[N]
the call:
cspice_vlcomg, a, v1, b, v2, sum
returns:
sum the double precision n-dimensional vector which
contains the linear combination
a * v1 + b * v2
help, sum
DOUBLE = Array[N]
None.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Perform the projection of a 4-dimensional vector into a
2-dimensional plane in 4-space.
Example code begins here.
PRO vlcomg_ex1
;;
;; Let `x' be an arbitrary NDIM-vector
;;
x = [ 4.D0, 35.D0, -5.D0, 7.D0 ]
;;
;; Let `u' and `v' be orthonormal NDIM-vectors spanning the
;; plane of interest.
;;
u = [ 0.D0, 0.D0, 1.D0, 0.D0 ]
v = [ sqrt(3.D0)/3.D0, -sqrt(3.D0)/3.D0, 0.D0, sqrt(3.D0)/3.D0 ]
;;
;; Compute the projection of `x' onto this 2-dimensional
;; plane in NDIM-space.
;;
cspice_vlcomg, cspice_vdotg( x, u ), u, cspice_vdotg( x, v ), v, puv
;;
;; Display the results.
;;
print, format='(A,4F6.1)', 'Input vector : ', x
print, format='(A,4F6.1)', 'Projection into 2-d plane: ', puv
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Input vector : 4.0 35.0 -5.0 7.0
Projection into 2-d plane: -8.0 8.0 -5.0 -8.0
The code reflects precisely the following mathematical expression
For each value of the index `i', from 0 to n-1, where `n' is the
dimension of `v1' and `v2':
sum[i] = a * v1[i] + b * v2[i]
No error checking is performed to guard against numeric overflow.
IDL native code to perform the same operation:
sum = a * v1 + b * v2
1) If any of the input arguments, `a', `v1', `b' or `v2', is
undefined, an error is signaled by the IDL error handling
system.
2) If any of the input arguments, `a', `v1', `b' or `v2', is not
of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
3) If the input vector arguments `v1' and `v2' do not have the
same dimension (N), an error is signaled by the Icy interface.
4) If the output argument `sum' is not a named variable, an error
is signaled by the Icy interface.
None.
1) No error checking is performed to guard against numeric
overflow or underflow. The user is responsible for insuring
that the input values are reasonable.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.3, 13-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code examples.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section. Moved the contents of the existing
-Examples section to -Particulars.
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.2, 13-JUN-2011 (EDW)
Edits to comply with NAIF standard for Icy headers.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
linear combination of two n-dimensional vectors
|