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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:29:27+00:00 2026-06-08T00:29:27+00:00

I need to take a large array of doubles, and process it in chunks

  • 0

I need to take a large array of doubles, and process it in chunks using a processor intensive function.

My original array is extremely large, about 200MB of doubles of signal data.

I need to take it in chunks of 5000 doubles each, process those with some very processor intensive math using a function that returns a single double. Each of those functions results is needed to create an ordered array that is used later.

I think this would be optimal for parallelism using PLINQ, but I am not quite sure how to go about doing it.

The naive implementation that I wrote looks like this :

        var processedList = new List<double>();

        var chunk = new List<double>;
        foreach (var rawSample in drop.RawSamples)
        {
            chunk.Add(rawSample);

            if (chunk.Count == 5000)
            {
                // Do long processing here
                processedList.Add(LongProcessingFunction(chunk));

                chunk.Clear();
            }
        }

        // Do something later with the list of processed values.....

So, where do I start with PLINQ? I need to be able to do the long, intensive function using all the cores of the processor.

I see there is a Take(n) function for IEnumerable….. Can I use this?

Can I use AsParallel here?

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-08T00:29:30+00:00Added an answer on June 8, 2026 at 12:29 am

    First, if you’re dealing with this amount of data, you should avoid processing it element by element, if you can. In your code, you could do that by iterating integers in 5000 increments and using something like Array.Copy().

    Or, even better, don’t do any copying at all, let LongProcessingFunction accept an array (or IList<T>, or IReadOnlyList<T>, if you’re on .Net 4.5; but using an interface does have some overhead) and an offset into that array.

    If you then want to make your code parallel, you can use ParallelEnumerable.Range() with AsOrdered() (which is necessary to have the results in the correct order) and Select():

    double[] result = ParallelEnumerable.Range(0, drop.RawSamples.Length / chunkSize)
        .AsOrdered()
        .Select(i => LongProcessingFunction(drop.RawSamples, i * chunkSize))
        .ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to take a large file, with lines such as: member: cn=user0001,ou=people And
Using PHP I need I will have an array of tag name => tag
I have an algorithm which currently allocates a very large array of doubles, which
I need to perform some calculations a large list of numbers. Do array.array or
I'm writing some pretty CPU-intensive, concurrent numerical code that will process large amounts of
I need to update a large number of facebook adgroups using the Graph API.
Background: I have a large 2D array of integers that I need to load
I am writing a very process-intensive function in PHP that needs to be as
I'm planning of developing a large website, Which I need to take some security
Need to take a SELECT drop down list options and find if any of

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.