VF_cos2VD_cos2VE_cos2
VFx_cos2VDx_cos2VEx_cos2
VFr_cos2VDr_cos2VEr_cos2
VFrx_cos2VDrx_cos2VErx_cos2
FunctionSquare of the cosine function
Syntax C/C++#include <VFmath.h>
int VF_cos2( fVector Y, fVector X, ui size );
int VFx_cos2( fVector Y, fVector X, ui size, float A, float B, float C );
C++ VecObj#include <OptiVec.h>
int vector<T>::cos2( const vector<T>& X );
int vector<T>::x_cos2( const vector<T>& X, const T& A, const T& B, const T& C );
Pascal/Delphiuses VFmath;
function VF_cos2( Y, X:fVector; size:UIntSize ): IntBool;
function VFx_cos2( Y, X:fVector; size:UIntSize; A, B, C:Single ): IntBool;
CUDA function C/C++#include <cudaVFmath.h>
int cudaVF_cos2( fVector d_Y, fVector d_X, ui size );
int cudaVFx_cos2( fVector d_Y, fVector d_X, ui size, float A, float B, float C );
int cusdVFx_cos2( fVector d_Y, fVector d_X, ui size, float *d_A, float *d_B, float *d_C );
int VFcu_cos2( fVector h_Y, fVector h_X, ui size );
int VFxcu_cos2( fVector h_Y, fVector h_X, ui size, float A, float B, float C );
CUDA function Pascal/Delphiuses VFmath;
function cudaVF_cos2( d_Y, d_X:fVector; size:UIntSize ): IntBool;
function cudaVFx_cos2( d_Y, d_X:fVector; size:UIntSize; A, B, C:Single ): IntBool;
function cusdVFx_cos2( d_Y, d_X:fVector; size:UIntSize; d_A, d_B, d_C:PSingle ): IntBool;
function VFcu_cos2( h_Y, h_X:fVector; size:UIntSize ): IntBool;
function VFxcu_cos2( h_Y, h_X:fVector; size:UIntSize; A, B, C:Single ): IntBool;
Descriptionsimple versions: Yi = cos2( Xi )
expanded versions: Yi = C * cos2( A*Xi + B )

Calculating the squared trigonometric functions directly is faster and sometimes more accurate than first calculating the trigonometric function itself and squaring it afterwards.

If, on the other hand, one can be sure that all Xi are within a reasonable range one can employ the faster reduced-range versions with the prefixes VFr_ and VFrx_. The range requirements for the reduced-range versions are:
64-bit: |Xi| < 232 (roughly 4.2*109)
32-bit: |Xi| ≤ 2p).
The reduced-range versions are not available for CUDA.

Error handlingPrecision errors lead to a default result of 1.0 (as if the input were 0.0) and a non-zero return value, but are otherwise ignored; _matherr is not called.
OVERFLOW errors can only occur in the complex versions and lead to a result of ±HUGE_VAL.
Return valueFALSE (0), if no error occurred, otherwise TRUE (non-zero).
See alsoVF_cos,   VF_cosrpi,  cos

VectorLib Table of Contents  OptiVec home