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 9149641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:30:17+00:00 2026-06-17T11:30:17+00:00

My flag for a missing value is 0, so from [0, A, B, 0,

  • 0

My flag for a missing value is 0, so from [0, A, B, 0, 0, C, 0] I want [0, A, B, B, B, C, C] (if no previous non-missing value exists, then just leave as 0).

I’m using the CUDA Thrust library, and was wondering if there’s a quick way of doing this without looping though each element.

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-17T11:30:18+00:00Added an answer on June 17, 2026 at 11:30 am

    seems work well.

    #include <thrust/device_vector.h>
    #include <thrust/scan.h>
    #include <iterator>
    
    template<class T>
    struct FillMissing
    {
        __host__ __device__ T operator()(const T& res, const T& dat)
        {
            return dat == T(0) ? res : dat;
        }
    };
    
    int main()
    {
        thrust::device_vector<double> vec(7);
        vec[1] = 2;
        vec[2] = 1;
        vec[5] = 3;
    
        thrust::inclusive_scan(
                vec.begin(), vec.end(),
                vec.begin(),
                FillMissing<double>());
    
        thrust::copy(
                vec.begin(), vec.end(),
                std::ostream_iterator<double>(std::cout, " "));
        std::cout << std::endl;
    }
    

    output:

    0 2 1 1 1 3 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a flag to prevent the CDHTMLDialog from use the IE history (back,
I'm sure I'm missing something, but I'm just trying to get an app widget
Hopefully a simple flag that I'm missing, I've got that svn diff -r 321:322
Using the -Xmx1G flag to provide a heap of one gigabyte, the following works
I run an apache-server and I need just one php_flag to differ from the
I have a table with the following columns: user_id, key, value, and flag. The
I'm using csvfix to sort a CSV file based on an integer (counter) value
Whenever I have to use a BOOL flag which maintains its value across multiple
Please do not flag this as a duplicate, I'm not asking about what is
I have a boolean flag :finished . Should I A: index({ finished: 1 })

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.