Message: Preferred N-D array in Geant4 Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Preferred N-D array in Geant4 

Forum: Biasing and Scoring
Date: 07 Jul, 2016
From: Jan Pipek <Jan Pipek>

Hello,

[...no exact forum match, scoring matches only partially...]

A couple of times, I had to use a 3D matrix (or 2D, or, in general, an ND-one) of different quantities (for voxel parameters, for field maps, for scoring). Sometimes the matrix item was a G4double, sometimes a G4ThreeVector, but in principle, it can be any other type. In Python world, I would immediately use numpy arrays and would not think a single second.

However, when I tried to find a recommended (or at least frequently used) approach to work with N-D data in Geant4 source code (or perhaps CLHEP), I haven't found any. Different components (e.g. scoring meshes, physics tables, ...) use different approaches and many methods repeat the same (index = i*stride[0]*stride[1] + j*stride[0] + k) access to some internal vector again and again (not that it would not be effective, it's only non-DRY). There is an undocumented likely candidate (g4tools/.../array) but it also seems to be specific for the g4tools functionality.

So my question is...

Is there a generic n-dimensional array/matrix class (ideally templated, accepting any type, efficiently in-lining access) and if not, shouldn't there be? There are many implementations in external libraries (like multi_array in boost, libdynd, ...) and it's not that difficult to write one's own (in fact, an implementation is even described in Stroustrup's C++ book) but perhaps such tool should be a standard part of Geant4/CLHEP for anyone to use without custom coding and external dependencies, like e.g. G4ThreeVector or G4RotationMatrix are?

Or is it just that I was not looking carefully? Or that there really is no need? I am sorry, if this is the case :-)

Regards,
Jan

P.S. Once such standard representation exists, more tools (like interpolation, arithmetic operations, geometry-related stuff for 2D/3D case, ...) can be implemented upon it, which, I believe, would save a lot of time for everybody.

P.P.S. If there is such interest, I can contribute with some code.

 Add Message Add Message
to: "Preferred N-D array in Geant4"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews