I'm looking to create some sort of datastructure in Python (I will make it into a class) that is to describe certain mathematical objects.
Requirements
I want to make a class to create objects such as curves, surfaces, hypersurfaces, and the like. In essence that means, I will have at least 1 variable (up to N variables) as a "basis". The combination of the values here, will map to 1 unique value for each combination. I will give an example, as I believe that simplifies things and I'm not specifically experienced in the development of data structures.
Say I have some information on how much the fuel consumption of a certain car is, and I make that dependent on the speed it is going. In that case I will have a 1-dimensional basis, and a 1-dimensional value. For each speed, I will have 1 unique number for the fuel consumption. Hence you should be able to see this as a curve (imagine x-axis: speed, y-axis: fuel consumption). Each of these will be expressed in a certain unit (I have a separate unit class that I can use to define these). Ofcourse, in this case I want to be able to retrieve the fuel consumption for each speed. Now, we can make it more complex. We can add a second variable to the object: the age of the car (note that we're still talking about the same car). As the car grows older, it could be that the fuel consumption for a certain speed can change. In this way, we have a 2-dimensional basis and (still) a 1-dimensional value. The 2-dimensional basis consists of the following units: Speed and Age. You can now visualize this as a surface. I want ofcourse, to be able to retrieve the fuel consumption for a unique combination of age and speed (that I know exists), but for example I also want to be able to retrieve all the combinations at a certain age. For example, if I retrieve the data from when the car was 1 year old, I want to be able to get all the speeds I have stored along with their consumption. Even more, this should return a curve object as described above. As such, I want to make a datastructure that can handle this multi-dimensional indexing rather flawlessly in a general manner. (I want to be able to define the amount of dimensions, and how they are expressed, when making an object. This is important, because I want to be able to switch the units of each object, for example translate the object from km/h to m/h.) Lastly, the combinations must not always be the same. For example: when the car was 1 years old maybe I took the measurements at 50km/h and 100km/h, but when the car was 5 years old I only took the measurements at 75km/h. As such, every value is uniquely identified by the combination of the values in the basis, but there must a certain amount of freedom in which combinations are in there.
Note: the description is just an arbitrary example.
Analysis
In first instance, I was thinking about something like a multi-dimensional grid, but then you would in certain times have a very sparse object, which is not ideal (due to the last requirement). When more taking a look at a dictionary with multi-valued keys, the second requirement of extracting data based only on the value of 1 of the keys becomes more complex.
In C++ I guess this would be more straightforward, but at the moment I'm looking into how I can implement something like this in Python...
Thanks in advance!
scipy.sparse? Google "python sparse matrix" and you'll find various solutions.