[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxaxp::vmsnotes

Title:VAX and Alpha VMS
Notice:This is a new VMSnotes, please read note 2.1
Moderator:VAXAXP::BERNARDO
Created:Wed Jan 22 1997
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:703
Total number of notes:3722

260.0. "MTH$DSINCOS problems" by CSC32::E_VAETH (Suffering from temporary brain cramp, stay tuned) Thu Feb 27 1997 22:43

    A customer is reporting a problem with the MTH$DSINCOS routine on
    OpenVMS Alpha.  He says it does not work.  I gave him the d_float's are
    not supported on Alpha, how they are converted to g_float etc...  I
    also reference him the the [OpenVMS AXP V6.1/RN] Chapter 5 Programming
    Release Notes: 5.29.2 Compatibility Between the VAX and AXP Mathematics
    Libraries where the DPML routines are recommneded.  However, I want to
    make sure that there isn't a problem that should be looked at.
    
    He wrote it up so nicely, I'll just include his stuff here.
    
    Thanks,
    
    Elin
    
The routine MTH$DSINCOS on an Alpha running either VMS 6.2 or VMS 7.0 has
a serious bug.  It appears to not produce any output values at all, but
overwrites the input value.  The corresponding routine for G-float numbers,
MTH$GSINCOS, works fine.  Below is a short program that computes and displays
the sine and cosine of angles between 0 and 90 degrees.  When compiled with
no options, the second and third arguments appear to be the correct sine and
cosine of the first argument.  When compiled with the /FLOAT=D_FLOAT option,
the first argument appears to be the sine of the second, while the third
argument is ignored.  The results are also appended below.

Owen Saxton
[email protected]

-----------------------------------------------------------------------------

#include stdio
#include stdlib
#include math

#if __D_FLOAT
  #define sincos Mth$Dsincos
#else
  #define sincos Mth$Gsincos
#endif

void main()
{
  void sincos(double *, double *, double *);

  long j;
  double a, b, c, s, degr1;

  degr1 = asin(1.0) / 90.0;
  printf("Deg  Radians       Arg1 (rad)    Arg2 (sin)    Arg3 (cos)\n");
  for (j = 0; j <= 90; j += 5) {
    s = c = b = a = j * degr1;
    sincos(&b, &s, &c);
    printf("%3d  %le  %le  %le  %le\n", j, a, b, s, c);
  }

  exit(0);
}

-----------------------------------------------------------------------------

MCCA1$ cc test_sincos
MCCA1$ link test_sincos
MCCA1$ r test_sincos
Deg  Radians       Arg1 (rad)    Arg2 (sin)    Arg3 (cos)
  0  0.000000e+00  0.000000e+00  0.000000e+00  1.000000e+00
  5  8.726646e-02  8.726646e-02  8.715574e-02  9.961947e-01
 10  1.745329e-01  1.745329e-01  1.736482e-01  9.848078e-01
 15  2.617994e-01  2.617994e-01  2.588190e-01  9.659258e-01
 20  3.490659e-01  3.490659e-01  3.420201e-01  9.396926e-01
 25  4.363323e-01  4.363323e-01  4.226183e-01  9.063078e-01
 30  5.235988e-01  5.235988e-01  5.000000e-01  8.660254e-01
 35  6.108652e-01  6.108652e-01  5.735764e-01  8.191520e-01
 40  6.981317e-01  6.981317e-01  6.427876e-01  7.660444e-01
 45  7.853982e-01  7.853982e-01  7.071068e-01  7.071068e-01
 50  8.726646e-01  8.726646e-01  7.660444e-01  6.427876e-01
 55  9.599311e-01  9.599311e-01  8.191520e-01  5.735764e-01
 60  1.047198e+00  1.047198e+00  8.660254e-01  5.000000e-01
 65  1.134464e+00  1.134464e+00  9.063078e-01  4.226183e-01
 70  1.221730e+00  1.221730e+00  9.396926e-01  3.420201e-01
 75  1.308997e+00  1.308997e+00  9.659258e-01  2.588190e-01
 80  1.396263e+00  1.396263e+00  9.848078e-01  1.736482e-01
 85  1.483530e+00  1.483530e+00  9.961947e-01  8.715574e-02
 90  1.570796e+00  1.570796e+00  1.000000e+00  6.123234e-17

MCCA1$ cc test_sincos/float=d_float
MCCA1$ link test_sincos
MCCA1$ r test_sincos
Deg  Radians       Arg1 (rad)    Arg2 (sin)    Arg3 (cos)
  0  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
  5  8.726646e-02  8.715574e-02  8.726646e-02  8.726646e-02
 10  1.745329e-01  1.736482e-01  1.745329e-01  1.745329e-01
 15  2.617994e-01  2.588190e-01  2.617994e-01  2.617994e-01
 20  3.490659e-01  3.420201e-01  3.490659e-01  3.490659e-01
 25  4.363323e-01  4.226183e-01  4.363323e-01  4.363323e-01
 30  5.235988e-01  5.000000e-01  5.235988e-01  5.235988e-01
 35  6.108652e-01  5.735764e-01  6.108652e-01  6.108652e-01
 40  6.981317e-01  6.427876e-01  6.981317e-01  6.981317e-01
 45  7.853982e-01  7.071068e-01  7.853982e-01  7.853982e-01
 50  8.726646e-01  7.660444e-01  8.726646e-01  8.726646e-01
 55  9.599311e-01  8.191520e-01  9.599311e-01  9.599311e-01
 60  1.047198e+00  8.660254e-01  1.047198e+00  1.047198e+00
 65  1.134464e+00  9.063078e-01  1.134464e+00  1.134464e+00
 70  1.221730e+00  9.396926e-01  1.221730e+00  1.221730e+00
 75  1.308997e+00  9.659258e-01  1.308997e+00  1.308997e+00
 80  1.396263e+00  9.848078e-01  1.396263e+00  1.396263e+00
 85  1.483530e+00  9.961947e-01  1.483530e+00  1.483530e+00
 90  1.570796e+00  1.000000e+00  1.570796e+00  1.570796e+00
    
T.RTitleUserPersonal
Name
DateLines
260.1Please IPMT ThisXDELTA::HOFFMANSteve, OpenVMS EngineeringFri Feb 28 1997 09:417
: However, I want to make sure that there isn't a problem that should
: be looked at.
: He wrote it up so nicely, I'll just include his stuff here.

   Remember to a copy of the report in the QAR (or IPMT), too.
    
260.2QUARK::LIONELFree advice is worth every centFri Feb 28 1997 10:0910
Well, it's not terribly surprising since this routine isn't used by native
Alpha compilers.  It's a VAX routine that is provided in the Alpha math
library.  The Alpha routine is MATH$SINCOS_G - there is no SINCOS_D because
it's not necessary.  The arguments are loaded in to registers F0 and F1 and
the result comes back with the SIN in F0 and the COS in F1.  This is not easy
to declare in C.

Do report this.

				Steve
260.3RTL::ARNOLDThe Math Library GroupFri Feb 28 1997 11:4936
    The customer should read and heed the following two paragraphs in
    section 1.2 ("Data Types") in the Digital Portable Mathematics Library
    documentation.

         "In addition to the data types mentioned in Table 1-1, DPML also
         provides routines that return two values of the same
         floating-point type, for example, two S_TYPE values or two G_TYPE
         values. In the discussion that follows, these pairs of
         floating-point data type values are referred to as F_COMPLEX (see
         Table 1-2).  This document uses F_COMPLEX to indicate that a given
         routine returns two different values of the same floating-point
         data type.

         "The mechanism for returning two floating-point values from DPML
         routines varies from platform to platform. However, on OpenVMS AXP
         systems, F_COMPLEX data is returned in consecutive floating-point
         registers and is accessible only through high-level languages,
         like Fortran, that specifically allow access to them."

    In other words, routines whose return type is F_COMPLEX, such as
    MTH$DSINCOS, are (usually) accessible only by code generated by
    compilers which understand the calling conventions and result return
    mechanisms used by these routines.

    Compile the following with /G_FLOAT and /NOG_FLOAT and compare the
    machine language listings to see what the compiler does.


	# include <math.h>
	double sin_plus_cos( double x ) { return sin( x ) + cos( x ) ; }


    This shows that, as Steve said in .2, native Alpha compilers don't call
    MTH$DSINCOS.  That routine is in fact a jacket around a call to
    MATH$SINCOS_G providing semantics similar to those of the the OpenVMS
    VAX routine.
260.4IPMT on it's way and THANKS! for the helpCSC32::E_VAETHSuffering from temporary brain cramp, stay tunedFri Feb 28 1997 12:160
260.5QUARK::LIONELFree advice is worth every centFri Feb 28 1997 12:338
Re: .3

On VAX, MTH$DSINCOS does return its results in the 2nd and 3rd argument, the
return type is not COMPLEX.  (On VAX, you couldn't return a D-Complex
result in two 32-bit registers.)  The DPML (Alpha) MATH$SINCOS_G equivalent
has only one interface which returns its result in F0 and F1.

					Steve