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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:15:10+00:00 2026-06-11T15:15:10+00:00

My problem is here. I have four 3-dimensional tables which are a sort of

  • 0

My problem is here.
I have four 3-dimensional tables which are a sort of look up tables ( 32x32x32 ) where I have to retrieve values in real time and very quickly in c++.
My main goal is computational time as a very large amount of operations have to be made, and good programming practice is secondary for this, as I’m less worried about code maintaining.
What is the best solution on the majority of personal computer to achieve this?
I’ve thought of storing the data on global variables and put them in a separate file and using them through declarations like “extern const float first[32][32][32];” or loading a vector from a file.
But the latter, I suppose, would be slower because data have to accessed through one more pointer.
Any other solution?

I made a search on the web, but this confused me more as I read different truths.
For example this two websites don’t seem to suggest the same thing (if I understand correctly): site1 , site2

  • 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-11T15:15:11+00:00Added an answer on June 11, 2026 at 3:15 pm

    Accessing data in a multidimensional array

    float data[32][32][32];
    data[i][j][k];
    

    is exactly equivalent to accessing a flattened array

    float data[32768];
    data[i * 1024 + j * 32 + k];
    

    There is no extra pointer involved, just arithmetic on the array indexes.

    In terms of performance, an extern const float [32][32][32] will offer the compiler opportunities for whole program optimisation as it will have full access to the data and how you are using it.

    Loading data from a file into a dynamic-sized vector<vector<vector<float>>> would result in multiple pointer indirections to access data elements; given that you know the size of the data, loading it into a static float[32][32][32] would be more efficient.

    For data where the extents are unknown at compile time, a good option would be to use Boost.MultiArray:

    typedef boost::multi_array<float, 3> array_type;
    array_type A(boost::extents[32][32][32]);
    
    A[i][j][k] = 5.0f;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem here im trying to upload a file first time it
I have a four dimensional array for which I have a static set of
Here is where I am at right now. I have four tables: task, project,
Can't understand what is a problem here: I have got main.cpp file where I
I'm not really sure if there is a single problem here or I have
Interesting problem I have here, usually I just round up/down respectively for my needs
I have a homework problem here I've been working on; here is the description:
I have a problem here. My Zend_Forms do not render in view script. Via
I have an interesting problem here I've been trying to solve for the last
I have a problem here I can't solve. I have a database of houses

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.