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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:26:40+00:00 2026-05-12T20:26:40+00:00

My goal is to create an efficient structure to store the most relevant entries

  • 0

My goal is to create an efficient structure to store the most relevant entries of a matrix that would (in a world without memory limitations) be approximately 10^5 x 10^5 and filled with doubles. The matrix is symmetric, so it actually would contain only (10^10)/2 values.

I need to access entries many, many times in my simulation, so fast retrieval is critical.

To keep the structure manageable, I will delete members that are unlikely to be used. If the index is (int_x1, int_x2), I will often want to delete all pairs containing, e.g., x1.

What is the best structure or set of structures for this task? What is a good hash for two ints?

For portability, I would like to avoid Boost. I am currently using TR1’s unordered_map elsewhere in the program. I was thinking of using unordered_map again with the key pair, but I’m not sure how I would be able to delete entries efficiently this way, and I don’t know what a good hash function would look like.

I’m a beginning programmer, so please state the obvious.

  • 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-05-12T20:26:40+00:00Added an answer on May 12, 2026 at 8:26 pm

    If the data is going to be pretty sparse, you could use an array of hash tables.

    hash_map<int,double> matrix[] = new hash_map<int,double>[10000];
    for (int i = 0; i < 10000; i++) matrix[i] = new hash_map<int,double>();
    

    Then to look up a value (x,y), you index the array with x and look up y in the hash table.

    A few things to watch out for:

    • Deleting can get pretty expensive, as you have to iterate through a lot of the hash tables.
    • Total storage can grow as you delete/insert, you should trim() your hash_maps occasionally.
    • it should be easy to take advantage of symmetry.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My goal is to create a generic function that selects a value in a
I want to create an efficient circular buffer in python (with the goal of
My goal is to create a custom TextBlock control that has a new dependency
My goal is to create (or use existing) an InputStream implementation (say, MergeInputStream) that
My goal is to create a map of maps so that I can retrieve
My goal is to create a version of the app that will expire after
My goal is to create a validated IP address field that will be validated
My end goal is to create a firefox extension that inserts an HTML button
I'm busy writing a servlet that generates HTML code. The goal is to create
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do

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.