Table of contents
CSPICE_VNORM computes the magnitude of a double precision 3-dimensional
vector.
Given:
v1 any double precision 3-dimensional vector.
help, v1
DOUBLE = Array[3]
the call:
vnorm = cspice_vnorm( v1 )
returns:
vnorm the magnitude of `v1' calculated in a numerically stable way.
help, vnorm
DOUBLE = Scalar
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 set of 3-dimensional vectors and compute the
magnitude of each vector within.
Example code begins here.
PRO vnorm_ex1
;;
;; Local parameters.
;;
SETSIZ = 3L
;;
;; Define a set of 3-dimensional vectors.
;;
v1 = [ [ 1.D0, 2.D0, 2.D0 ], $
[ 5.D0, 12.D0, 0.D0 ], $
[-5.D-17, 0.D0, 12.D-17] ]
;;
;; Calculate the magnitude of each vector
;;
for i=0L, SETSIZ-1L do begin
print, format='(A,3E10.2)', 'Input vector: ', v1[*,i]
print, format='(A,F24.20)', 'Magnitude : ', $
cspice_vnorm( v1[*,i] )
print
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Input vector: 1.00E+00 2.00E+00 2.00E+00
Magnitude : 3.00000000000000000000
Input vector: 5.00E+00 1.20E+01 0.00E+00
Magnitude : 13.00000000000000000000
Input vector: -5.00E-17 0.00E+00 1.20E-16
Magnitude : 0.00000000000000013000
cspice_vnorm takes care to avoid overflow while computing the norm of the
input vector `v1'. cspice_vnorm finds the component of `v1' whose magnitude
is the largest. Calling this magnitude `v1max', the norm is computed
using the formula:
|| 1 ||
cspice_vnorm = v1max * || ------- * v1 ||
|| v1max ||
where the notation ||x|| indicates the norm of the vector `x'.
Native IDL code to calculate the same scalar result:
vnorm = norm( v1 )
The IDL norm function accepts an arbitrary size N vector.
1) If the input argument `v1' is undefined, an error is signaled
by the IDL error handling system.
2) If the input argument `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.
None.
None.
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. 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 English error.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
norm of 3-dimensional vector
|