Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:03:26+00:00 2026-06-08T05:03:26+00:00

I am not clear on what should be the best way to implement sincos().

  • 0

I am not clear on what should be the best way to implement sincos(). I’ve looked up everywhere but it seems the consensus is simply that it is better than doing separate computation of sin and cos. Below is essentially what I have in my kernel for using sincos. However, when I clock it against just doing sin and cos separately it comes out slower. I think it has to do with how I’m using my cPtr and sPtr. Is there a better way?

int idx = blockIdx.x * blockDim.x + threadIdx.x;

if (idx < dataSize)
{
    idx += lower;
    double f = ((double) idx) * deltaF;
    double cosValue;
    double sinValue;
    double *sPtr = &sinValue;
    double *cPtr = &cosValue;
    sincos(twopit * f, sPtr, cPtr);

    d_re[idx - lower] = cosValue;
    d_im[idx - lower] = - sinValue;

    //d_re[idx - lower] = cos(twopit * f);
    //d_im[idx - lower] = - sin(twopit * f);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:03:28+00:00Added an answer on June 8, 2026 at 5:03 am

    The pointers are redundant – you can get rid of them, e.g.

    double cosValue;
    double sinValue;
    sincos(twopit * f, &sinValue, &cosValue);
    

    but I’m not sure this will have much effect on performance (worth a try though).

    Also consider using float rather than double where precision requirements permit, and use the corresponding single precision functions (sincosf in this case).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting with django. It is not quite clear to me, how should
I'm wondering if $(document).resize() should make sense or not? The problem is that when
It's clear that you should be using exceptions to handle errors in your app.
Not clear on some fundamental syntax here. define-key accepts a set of inputs, one
It's not clear, to me anyway, if a UIView is automatically released from its
It's not clear to me if the Eclipse plugin completely replaces the need to
I am not clear on the actual difference between these two styles of class
I'm not clear on the status of XHTML - v1.0 versus v1.1. Can someone
I am not clear from the documentation - when I indicate a cell width
Sorry if question is not clear. My vocabulary for terminology is bad. Anyways I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.