Table of contents
CSPICE_VSCLG multiplies a scalar and a double precision vector of
arbitrary dimension.
Given:
s a double precision scalar.
help, s
DOUBLE = Scalar
v1 a double precision n-dimensional vector.
help, v1
DOUBLE = Array[N]
the call:
cspice_vsclg, s, v1, vout
returns:
vout a double precision n-dimensional vector containing the product
of the scalar with the vector `v1'.
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 a sets of scalar double precision values and use them
to scale a given n-dimensional vector.
Example code begins here.
PRO vsclg_ex1
;;
;; Local parameters.
;;
SETSIZ = 3L
;;
;; Define the set of scalars and the input vector.
;;
s = [3.D0, 0.D0, -1.D0]
v1 = [1.D0, 2.D0, -3.D0, 4.D0]
print, format='(A,4F6.1)', 'Input vector : ', v1
print
;;
;; Calculate product of each scalar and `v1'.
;;
for i=0L, SETSIZ-1L do begin
cspice_vsclg, s[i], v1, vout
print, format='(A,F6.1)', 'Scale factor : ', s[i]
print, format='(A,4F6.1)', 'Output vector: ', vout
print
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Input vector : 1.0 2.0 -3.0 4.0
Scale factor : 3.0
Output vector: 3.0 6.0 -9.0 12.0
Scale factor : 0.0
Output vector: 0.0 0.0 -0.0 0.0
Scale factor : -1.0
Output vector: -1.0 -2.0 3.0 -4.0
For each value of the index `i' from 0 to ndim-1, this function
performs the following multiplication
vout[i] = s * v1[i];
No error checking is performed to guard against numeric overflow
or underflow. `vout' may overwrite `v1'.
Native IDL code to calculate the same vector result:
vout = s * v1
The IDL functionality also accepts arbitrary sized N vectors.
1) If any of the input arguments, `s' or `v1', is undefined, an
error is signaled by the IDL error handling system.
2) If any of the input arguments, `s' or `v1', 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 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 `s' are reasonable and will not cause overflow.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.2, 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.
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.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
n-dimensional vector scaling
|