Sparse multidimensional data representation

I am working on a heart modeling tool that uses 4-dimensional data, i.e. several (3-30) variables in places in three-dimensional space.

Now I am adding some geometry to the fabric that will leave more than 2/3 of the points in the containing 3D field outside the fabric to simulate, so I need a way to efficiently store active points, not others.

Basically, I need to be able to:

  • Iterate over all active points in a restricted 3D field (an iterator, maybe?)
  • Having access to one point, find its orthogonal neighbors (x, y, z) +/- 1.

This is probably more than one question! My main problem is how to efficiently represent sparse data.

I use C.

+3
source share
3 answers

How often do you add fabric and how long can it take?

One simple solution is a linked list + hash with pointers from one to the other.

Value:

  • Save a linked list containing all the relevant points and their data
  • Save the hash to easily get to this data: key = coordinates, data = pointer to a linked list.

The implementation of the operations will be:
Add a field: Go to the fully-connected list and take only the relevant elements in the list of work-

related Iterations: Go to the list associated with the work,
Find neighbors: Look for each of the neighbors in the hash.

:
: O (n), Iterate O (1) , O (1) (- ).

+5

, POSIX mmap():

float (*a)[500][500];

a = mmap(0, (size_t)500 * sizeof a[0], PROT_READ | PROT_WRITE,
    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

if (a && (void *)a != MAP_FAILED)
{
    /* a is now 500 x 500 x 500 sparse array of floats */

[x] [y] [z] , . .

MAP_ANONYMOUS, /dev/zero.

, ( ) .

+2

-, , , . , " ", " , " " , ".

, . 3D- , . , isTissue, , . , . () NULL .

, at (i, j), ii = i/blockside, jj = j/blocksize, (ii, jj), , . NULL, . , (i mod blocksize, j mod blocksize) , (i, j) . isTissue, , "" .

, , , , , . , , , , -. , , .

, , ( ) , , , , , isTissue .

, , , "" , "" , , . , , " " ( ), .

An experienced reader will probably find out the similarities between this and the ways of laying out data for parallel computing; if you have a really strong simulation, you can easily distribute the blocks across several nodes, and you just need to make the node cross-connect for cross-block computing. For this kind of application, it may be useful for you to make nested block levels where you have meta blocks (for translating a node) containing smaller blocks (for geometry).

+1
source

Source: https://habr.com/ru/post/1714953/


All Articles