Table of contents
CSPICE_VSUBG computes the difference between two double precision vectors
of arbitrary dimension.
Given:
v1 a double precision vector of arbitrary dimension which is the
minuend (i.e.
help, v1
DOUBLE = Array[N]
first or left-hand member) in the vector subtraction.
v2 a double precision vector of arbitrary dimension which is the
subtrahend (i.e.
help, v2
DOUBLE = Array[N]
second or right-hand member) in the vector subtraction.
the call:
cspice_vsubg, v1, v2, vout
returns:
vout a double precision vector containing the difference v1 - v2.
help, vout
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) Define two sets of n-dimensional vectors and compute the
difference from each vector in first set with the
corresponding vector in the second set.
Example code begins here.
PRO vsubg_ex1
;;
;; Local parameters.
;;
SETSIZ = 3L
;;
;; Define the two vector sets.
;;
v1 = [ [ 1.D0, 2.D0, 3.D0, 4.D0 ], $
[ 1.D0, 2.D0, 3.D0, 4.D0 ], $
[ 1.D0, 2.D0, 3.D0, 4.D0 ] ]
v2 = [ [ 1.D0, 1.D0, 1.D0, 1.D0 ], $
[-1.D0, -2.D0, -3.D0, -4.D0 ], $
[-1.D0, 2.D0, -3.D0, 4.D0 ] ]
;;
;; Calculate the difference between each pair of vectors
;;
for i=0L, SETSIZ-1L do begin
cspice_vsubg, v1[*,i], v2[*,i], vout
print, format='(A,4F6.1)', 'First vector : ', v1[*,i]
print, format='(A,4F6.1)', 'Second vector: ', v2[*,i]
print, format='(A,4F6.1)', 'Difference : ', vout
print
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
First vector : 1.0 2.0 3.0 4.0
Second vector: 1.0 1.0 1.0 1.0
Difference : 0.0 1.0 2.0 3.0
First vector : 1.0 2.0 3.0 4.0
Second vector: -1.0 -2.0 -3.0 -4.0
Difference : 2.0 4.0 6.0 8.0
First vector : 1.0 2.0 3.0 4.0
Second vector: -1.0 2.0 -3.0 4.0
Difference : 2.0 0.0 6.0 0.0
For each value of the index `i' from 0 to NDIM-1, where NDIM is the
dimension of `v1' and `v2', this procedure performs the following
subtraction:
vout[i] = v1[i] - v2[i]
No error checking is performed to guard against numeric overflow
or underflow.
Native IDL code to calculate the same vector result:
vout = v1 - v2
1) If any of the input arguments, `v1' or `v2', is undefined, an
error is signaled by the IDL error handling system.
2) If any of the input arguments, `v1' 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 `vout' 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. The programmer is thus required to insure that the
values in `v1' and `v2' are reasonable and will not cause
overflow. No error recovery or reporting scheme is
incorporated in this routine.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.4, 10-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code example.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section. Moved the existing contents of -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.3, 13-JUN-2011 (EDW)
Edits to comply with NAIF standard for Icy headers.
-Icy Version 1.0.2, 23-SEP-2008 (EDW)
Eliminated error in English.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
n-dimensional vector subtraction
|