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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:22:24+00:00 2026-06-12T07:22:24+00:00

If I initialize x using thrust::device_vector<double> x(10) , is it possible to create a

  • 0

If I initialize x using thrust::device_vector<double> x(10), is it possible to create a device_vector y that spans x[2] through x[5]?

Note: I don’t want memory to be copied, which happens when I use something like thrust::device_vector<double> y(x.begin(), x.end()).

  • 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-12T07:22:25+00:00Added an answer on June 12, 2026 at 7:22 am

    The thrust device_vector only has allocation or copy constructors, so there isn’t a direct way to alias an existing vector or device pointer by constructing another device_vector. But as pointed out in comments, it really isn’t needed either. Thrust algorithms always work on iterators, and it is possible to use iterator arithmetic to achieve the same outcome. For example this, creates a new vector via copy construction:

    thrust::device_vector<double> x(10);
    thrust::device_vector<double> y(x.begin()+2, x.begin()+5);
    
    double val = thrust::reduce(y.begin(), y.end());
    

    whereas this returns the same answer without it:

    thrust::device_vector<double> x(10);
    
    double val = thrust::reduce(x.begin()+2, x.begin()+5);
    

    The result is the same in both cases, the second equivalent to creating an alias to a subset of the input vector.

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

Sidebar

Related Questions

Since C99 (and C++20), it's possible to initialize structs using this syntax: struct info
I'm trying to set up a class so that it's possible to initialize it
Recently I have been using thrust a lot. I have noticed that in order
Is it possible to force Ruby to call an initialize method when using YAML.load_file?
I am trying to initialize a struct using named attributes in a way that
I have a custom ServletContextListener that I am using to initialize and start up
So it's well known that you're supposed to call game's base.Initialize() before using the
Say I have a listbox lb, which I initialize using: lb.DataSource = wordList \\wordList
I have a 2-dimensional jagged array (though it's always rectangular), which I initialize using
When I try to initialize an object using the Object Initializer, ReSharper always inserts

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.