MGARD icon indicating copy to clipboard operation
MGARD copied to clipboard

constructor of "TensorMeshHierarchy" cannot take a non-const dimension value as the input parameter

Open lwan86 opened this issue 4 years ago • 1 comments

I need to read a variable from a bp file and then compress it. The dimension of that variable cannot be known until we read it. However, the input parameter "shape" of the constructor of "TensorMeshHierarchy" needs to be an "std::array", which requires const dimension. Why do we have to use the "std::array" here?

lwan86 avatar Jun 16 '21 15:06 lwan86

The underlying problem is that TensorMeshHierarchy is templated on the dimension N. I don't quite remember the original rationale for making N a template parameter rather than a normal data member; maybe it had something to do with the original API, or maybe I was just trying to make development easier by avoiding problems caused by mismatched dimensions. I don't see any reason we can't make N a data member, change all the std::arrays to std::vectors, etc. It would require changing the API, though, so it won't happen quickly. In the meantime, maybe you can use a switch statement like we do here.

Will we have the same problem with the datatype? Is the precision of the variable known before it's read?

ben-e-whitney avatar Jul 12 '21 16:07 ben-e-whitney