The practical use of N-dimensional arrays, where (N> 3)

I have been programming for the past 8 years, and now I'm just wondering if there is a practical use of an N-dimensional array, where N> 3.I can only visualize a data structure that is less than or equal to 3 dimensions. If a program uses more than three dimensions? Are there any practical uses for an ND array that exceeds 3D? If so, write some examples.

+5
source share
4 answers

The only worthy example that I remember was in the 1982 text Oh! Pascal! , which gives you some idea of ​​how rare he was in my experience.

An example is a storage system in which jeans can be indexed.

 inventory[sex][size][length][color][fit] = number_received

which is only a little far-fetched. You won't have a problem with a database structured this way, but it looks funny like code.

+2
source

Take almost anything from physics, where there are common tensors, for example, general relativity, computational chemistry, quantum physics.

http://en.wikipedia.org/wiki/Tensor#Applications

A rank 4 tensor is common, for example.

http://www.oonumerics.org/FTensor/FTensor.pdf

http://mpqc.svn.sourceforge.net/viewvc/mpqc/trunk/mpqc/src/lib/chemistry/qc/lmp2/lmp2.cc?revision=9342&view=markup&pathrev=9492

333     double
334     LMP2::compute_ecorr_lmp2()
335     {
336     Timer tim("ecorr");
337     
338     sma2::Index r("r"), s("s");
339     sma2::Array<0> ecorr;
340     double ecorr_lmp2 = 0.0;
341     for (my_occ_pairs_t::const_iterator iter = my_occ_pairs_.begin();
342     iter != my_occ_pairs_.end();
343     iter++) {
344     sma2::Index i(iter->first-nfzc_);
345     sma2::Index j(iter->second-nfzc_);
346     if (j.value() > i.value()) continue;
347     double f;
348     if (i.value() != j.value()) f = 2.0;
349     else f = 1.0;
350     ecorr.zero();
351     ecorr() += f * 2.0 * K_2occ_(i,j,r,s) * T_local_(i,j,r,s);
352     ecorr() -= f * K_2occ_(i,j,s,r) * T_local_(i,j,r,s);
353     ecorr_lmp2 += ecorr.value();
354     }
355     
356     msg_->sum(ecorr_lmp2);
357     
358     return ecorr_lmp2;
359     } 
+3

... 3 + 1 = 4 :)

+2

An array containing all the dungeons in Ultima III will logically be a 4-dimensional array. Each dungeon is a three-dimensional grid of cells, and they are the same size.

+2
source

All Articles