I've been busy, but finally found time to release a small utility in Cincom Smalltalk public store: it's a package named MatFileReader.
The package is capable of importing data from the .mat files produced by Matlab, into Visualworks. Nothing spectacular, but it may be useful for scientific applications. Usage is fairly simple, just do-it:
(MatFileReader on: 'foobar.mat' asFilename readStream) decode.
I had developped the package around 2005, but it was messy and full of personnal dependencies. The dependencis are now reduced to the BinaryStream, RawArray and MultipleDimensionArray packages.
- RawArray are collections holding bits of data efficiently in space - bits are translated into/from Smalltalk objects with at: and at:put: operations like a ByteArray or a WordArray.
- BinaryStream is just a Stream wrapper with convenient messages for reading chunks of binary data, especially into RawArray.
- MultipleDimensionArray is just a SequenceableCollection wrapper which let the single dimension raw storage be viewed with multiple dimensions. The layout is that of FORTRAN and Matlab, column-wise (first index varies first).
The package would be more useful if data were imported into some application specific classes (like Smallapack for example), but for that one just have to either subclass MatFileReader, or post-process with a tree visitor.
License is M.I.T.
When I'll have time, I'll also handle the export to mat-file, and try to port into Squeak/Pharo. Such package could be useful for Polymath (https://github.com/PolyMathOrg/PolyMath).
No comments:
Post a Comment