开发者

Practical use of N-Dimensional Arrays,where (N>3)

开发者 https://www.devze.com 2023-01-15 07:04 出处:网络
I have been programming for the last 8 years and now I was just wondering that if there is a开发者_Go百科nypractical use of N-Dimensional array,where N>3.I can only visualize of a data structure that

I have been programming for the last 8 years and now I was just wondering that if there is a开发者_Go百科ny practical use of N-Dimensional array,where N>3.I can only visualize of a data structure that is less than or equal to 3 dimensions.Has any one used more than 3 dimensions in any program?Are there any practical uses of a N-D array which is beyond 3d?If so please post some samples.


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

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

Tensor with rank 4 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     } 


The only decent example I recall was in the 1982 text Oh! Pascal! which gives you some idea of how rare it has been in my experience.

The example was a stock-keeping system where jeans could be indexed by

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

which is only slightly contrived. You'd have no problem with a database structured in such a way but it does look funny as code.


The most obvious example is a list of voxel spaces ... 3 + 1 = 4 dimensions :)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消