* how to use sincos()?
@ 1995-08-08 4:00 Brian R. Hunt
1995-08-09 4:00 ` Dave Eklund
1995-08-09 4:00 ` Brian R. Hunt
0 siblings, 2 replies; 5+ messages in thread
From: Brian R. Hunt @ 1995-08-08 4:00 UTC (permalink / raw)
I see in the manual pages that DEC OSF1 (V1.3 or V3.0) has a sincos()
function which I presume is supposed to compute both the sine and
cosine of an angle in less time than it would take to call sin() and
cos() separately. However in all my attempts to use it it seems
functionally equivalent to sin(), except that it is omitted from
/usr/include/math.h. Fine, I can declare sincos() on my own, but how
do I extract the value of the cosine from it?
--
Brian R. Hunt
bhunt@ipst.umd.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to use sincos()?
1995-08-08 4:00 how to use sincos()? Brian R. Hunt
@ 1995-08-09 4:00 ` Dave Eklund
1995-08-09 4:00 ` Brian R. Hunt
1 sibling, 0 replies; 5+ messages in thread
From: Dave Eklund @ 1995-08-09 4:00 UTC (permalink / raw)
The sin value is returned in F0 and the cos value is returned in F1.
Dave Eklund
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to use sincos()?
1995-08-08 4:00 how to use sincos()? Brian R. Hunt
1995-08-09 4:00 ` Dave Eklund
@ 1995-08-09 4:00 ` Brian R. Hunt
1995-08-11 4:00 ` Dave Eklund
1 sibling, 1 reply; 5+ messages in thread
From: Brian R. Hunt @ 1995-08-09 4:00 UTC (permalink / raw)
bhunt@brians.umd.edu (Brian R. Hunt) writes:
>I see in the manual pages that DEC OSF1 (V1.3 or V3.0) has a sincos()
>function which I presume is supposed to compute both the sine and
>cosine of an angle in less time than it would take to call sin() and
>cos() separately. However in all my attempts to use it it seems
>functionally equivalent to sin(), except that it is omitted from
>/usr/include/math.h. Fine, I can declare sincos() on my own, but how
>do I extract the value of the cosine from it?
I neglected to mention, I'm programming in C. If it's unusable from
C, a rough idea of how to use it in some other language would be welcome.
--
Brian R. Hunt
bhunt@ipst.umd.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to use sincos()?
1995-08-09 4:00 ` Brian R. Hunt
@ 1995-08-11 4:00 ` Dave Eklund
1995-08-13 4:00 ` Dave Newbold
0 siblings, 1 reply; 5+ messages in thread
From: Dave Eklund @ 1995-08-11 4:00 UTC (permalink / raw)
I can only speak for DEC Fortran where you can get a call to
sincos out of a code fragment like:
do i=1,100
type *,sin(float(i)),cos(float(i))
enddo
end
The compiler recognizes the need for both the sin and cos values,
and generates code accordingly, picking up the values from the appropriate
registers. I believe that DEC C does the same thing with similar code.
Dave Eklund
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to use sincos()?
1995-08-11 4:00 ` Dave Eklund
@ 1995-08-13 4:00 ` Dave Newbold
0 siblings, 0 replies; 5+ messages in thread
From: Dave Newbold @ 1995-08-13 4:00 UTC (permalink / raw)
Hi,
According to the manpage, sincos has a type of 'double complex', and it mentions
that the routine can only be used by languages that support that type.
At a guess, this means that you can:
- Call it from fortran, which has a 'complex*16' type. You'll need to write
a C 'buffer' routine to pass the argument, as sincos wants its argument
passed by value, not by reference. Be careful of the function prototypes
in <math.h>, or you may get unwanted type conversion.
- The fortran docs state that the complex*16 type is stored as two
consecutive real*8. So define a simple structure to mimic the double_complex
type. Again, could be problems with prototypes in the header file.
As somebody mentioned, I think the compiler recognizes apt situations to use
sincos - make sure you make it 'obvious' that you are taking the cos, sin of
the same thing (use the same variable as an argument?).
_Dave_
------------------------------------------------------------------------------
The opinions expressed here are not necessarily those of any other person
object or organisation. So don't sue them.
dave.newbold@bristol.ac.uk / dmn@vsnhd1.cern.ch / newbold@vxcern.cern.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1995-08-13 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-08-08 4:00 how to use sincos()? Brian R. Hunt
1995-08-09 4:00 ` Dave Eklund
1995-08-09 4:00 ` Brian R. Hunt
1995-08-11 4:00 ` Dave Eklund
1995-08-13 4:00 ` Dave Newbold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox