Menu

#74 N-Dimensional table lookup

open
5
2020-01-29
2020-01-29
Jim Monte
No

There are 2-dimensional and 3-dimensional table lookup code models. A general N-dimensional version would be desirable. The attached solution has one, supporting any number of dimensions limited only by available address space. For a 64-bit address space, that range is from 1 up to about 58. The solution consists of a core N-dimensional multilinear interpolator, a standalone test program, and projects to make it into a code model. To avoid file duplication and possible divergence, there are some references to ngspice as it exists in branch beta_jdm. The changes that are required to the solution to reference the files in ngspice should be fairly clear. If desired, this code model could be added to the standard ngspice distribution.

The N-dimensional table lookup efficiently calculates the scaling factors and locates points where interpolation should be done without duplication of any partial products such as x (1-y). These issues becomes more significant when there are more dimensions.

Compared to table2D and table3D, the partial derivatives are computed in a simpler manner. However, they are guaranteed to be continuous, so convergence is likely to be acceptable, although it is not tested yet. Also unlike these, extrapolation is allowed with a warning. One final difference is that the N-dimensional lookup does not have the restrctive GPL licensing that table2D and table3D must have due to the functions used to calculate their derivatlves.

The first initialization could be slow for a very large data table. However, subsequent loads are much faster since it will cache the results in a binary file, validating the agreement with the original data file with an SHA-1 hash. The integrety of the binary data itself is confirmed with a second SHA-1 hash. The code model does the SHA-1 calculations internally.

The data file format is slightly different from the ones used by table2D and table3D supporting a free format along with comments. However, it can read the formats of table2D and table3D provided SPICE scale factors like MEG are not present.

1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.