Designing a matrix library for D

Mason McGill via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 24 00:01:13 PDT 2014


On Tuesday, 24 June 2014 at 04:36:04 UTC, ed wrote:
> On Monday, 23 June 2014 at 21:08:03 UTC, Mason McGill wrote:
> [snip]
>>
>> Concepts:
>>  InputGrid: anything with a size (size_t[n]) and n-dimensional 
>> opIndex.
>>  OutputGrid: anything with a size (size_t[n]) and 
>> n-dimensional opIndexAssign.
> [snip]
>>
>> Cheers,
>> Mason
>
> I don't think 'Grid' is not a good name for the type. The term 
> Grid is generally used to refer to any sort of grid; regular, 
> semiregular, irregular, unstructured, curvilinear etc. etc. 
> grids.

When you're talking about sampling on a grid, warping can either 
be thought of as warping the grid, or warping the function to be 
sampled. My library happens to work in terms of the second 
approach, so it is (pedantically) consistent. I see your point, 
though.

> They are all very different in their use and internal 
> representations. Often a grid will have support for metadata at 
> each point (GIS etc.) whereas a matrix will not.
>
> I think the word Matrix is a better fit, because that is what 
> they these types are.

Not quite. "Matrix" connotes 2-dimensional tensors (in the linear 
algebra sense). The library I'm developing at work is for 
manipulating multidimensional arrays, which don't have the same 
semantics people expect from matrices (representing linear 
operators). However, the name "Array" already refers to at least 
3 data structures in D, so it was out. I picked "Grid" because 
the library is for processing data sampled regularly on 
n-dimensional grids (mostly vision). With my library, you could 
represent complex data in a GIS via a grid of structures, or 
multiple grids ("layers").

If you're not convinced, I intend to release my work under a 
liberal license, so feel free to download it and find/replace 
"Grid" -> "Matrix" :)

Also, check out this other option if you haven't already:
http://denis-sh.bitbucket.org/unstandard/unstd.multidimarray.html


More information about the Digitalmars-d mailing list