I think I found a quite serious mis-implementation of GDML matrices. Luckily, this does not affect all use cases (that is why we never have seen this in our optical use case)
see this short notebook example, in which I would expect a different result:
from pyg4ometry import gdml, geant4
import numpy as np
mv = gdml.MatrixFromVectors([1, 2, 3], [100, 200, 300], "testmatrix", reg)
[Expression : matrix_expr_idx0_val_testmatrix = expr_matrix_expr_idx0_val_testmatrix : 1*eV,
Expression : matrix_expr_idx1_val_testmatrix = expr_matrix_expr_idx1_val_testmatrix : 100,
Expression : matrix_expr_idx2_val_testmatrix = expr_matrix_expr_idx2_val_testmatrix : 2*eV,
Expression : matrix_expr_idx3_val_testmatrix = expr_matrix_expr_idx3_val_testmatrix : 200,
Expression : matrix_expr_idx4_val_testmatrix = expr_matrix_expr_idx4_val_testmatrix : 3*eV,
Expression : matrix_expr_idx5_val_testmatrix = expr_matrix_expr_idx5_val_testmatrix : 300]
--> this has the right order
array([[9.99999566e-07, 1.00000000e+02, 1.99999913e-06],
[2.00000000e+02, 2.99999870e-06, 3.00000000e+02]])
--> this does not have the right structure at all? It is just the values array arbitrarily folded in half?
mv.eval().reshape(-1).reshape(3, 2)
array([[9.99999566e-07, 1.00000000e+02],
[1.99999913e-06, 2.00000000e+02],
[2.99999870e-06, 3.00000000e+02]])
--> this would be the right result, with the two columns in GDML organized in columns of the evaled matrix?
this is not just the transposition of the "wrong" matrix above, but a complete re-ordering of all values. (if eval() returns a matrix like this, or the transposed value, could still be discussed; especially for 1D "matrices")
I think I found a quite serious mis-implementation of GDML matrices. Luckily, this does not affect all use cases (that is why we never have seen this in our optical use case)
see this short notebook example, in which I would expect a different result:
--> this has the right order
--> this does not have the right structure at all? It is just the
valuesarray arbitrarily folded in half?--> this would be the right result, with the two columns in GDML organized in columns of the evaled matrix?
this is not just the transposition of the "wrong" matrix above, but a complete re-ordering of all values. (if
eval()returns a matrix like this, or the transposed value, could still be discussed; especially for 1D "matrices")