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

  • Home
  • SEARCH
  • 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 9137075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:02:49+00:00 2026-06-17T09:02:49+00:00

By using CUDA Thrust’s inclusive scan with a max operator, I’m able to fill

  • 0

By using CUDA Thrust’s inclusive scan with a max operator, I’m able to fill missing values with the previous non-missing value (i.e. last non-missing value to the left).

But how to fill using next non-missing value (to the right)? Thus, for example, using 0 as my missing value marker:

                  Input: [0 1 0 0 4 0 6 0]
 Fill missing from left: [0 1 1 1 4 4 6 6]
Fill missing from right: [0 1 4 4 4 6 6 6]   <- want

(Note if the last element is missing then revert to filling final 0s from left.)

I’ve tried a inclusive scan in reverse, which yields [0 6 6 6 6 6 6 6] for max, not as desired.

Many thanks.

  • 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-17T09:02:50+00:00Added an answer on June 17, 2026 at 9:02 am

    The reason max() works on ascending values when scanning from left to right is that the current maximum value will always be higher than your 0 missing element, so it becomes the correct value for filling in the missing elements even though it has a “memory” coming all the way from the beginning.

    If you simply scan from right to left, max() no longer works, because you then have a descending range.

    So, it seems like you need to use rbegin() and rend() to scan from right to left and, in addition, use MAX_INT as your place-holder and min() as your operator.

    Input: [MAX_INT 1 MAX_INT MAX_INT 4 MAX_INT 6 MAX_INT]
    Fill missing from right: [1 1 4 4 4 6 6 MAX_INT]
    

    Then, you need to fudge things for your special cases on the left and right.

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

Sidebar

Related Questions

I'm trying to modify a simple dynamic vector in CUDA using the thrust library
I'm trying to build a trivial application using Thrust/CUDA 4.0 and get lots of
I'm trying to find the minimum number in a array using Thrust and CUDA.
Im looking at this implementation of DCT using cuda: http://www.cse.nd.edu/courses/cse60881/www/source_code/dct8x8/dct8x8_kernel1.cu The part in question
I am writing a massively parallel GPU application using CUDA. I have been optimizing
I'm using the CUDA .rules file which comes with the CUDA SDK for custom
I'm using a custom random number function rand48 in CUDA. The function does not
I am writing a CUDA kernel in which I'm using the string data type
I am using GeForce 8400M GS on Ubuntu 10.04 and I am learning CUDA
I am writing host code for a CUDA program, so I am stuck using

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.