Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "mtx"

Title:Working with data matrices
Rating:Not rated. Create the first rating!
Latest version:0.6
SHA1 sum:97061488c3a0d33d130d76c53d2a608b6af280af
Author:Nicos Angelopoulos http://stoics.org.uk/~nicos
Maintainer:Nicos Angelopoulos http://stoics.org.uk/~nicos
Packager:Nicos Angelopoulos http://stoics.org.uk/~nicos
Home page:http://stoics.org.uk/~nicos/sware/mtx
Download URL:http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-*.tgz
Requires:lib

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.14e6ffb6c525b23da0afd4979e01e9f710878faef6http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.1.tgz
0.2435472cf52b89a46f922becf03a32cc625e27feb5http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.2.tgz
0.32ff4ec3d5e0dc8551a34e2d56b8aea425962314f1http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.3.tgz
0.4b97324f1b0d8367bf28fff310f228e114c5b818717http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.4.tgz
0.535f781f0f901f862200559e0050206fa51423dbf10http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.5.tgz
0.697061488c3a0d33d130d76c53d2a608b6af280af19http://stoics.org.uk/~nicos/sware/packs/mtx/mtx-0.6.tgz

mtx: Working with data matrices

This is an SWI-Prolog pack for working with data matrices, taking off from where library(csv) ends.
The library will hopefully grow to become auseful tool for logic programming based data science.

Install via SWI's package manager:

?- pack_install(mtx).  % it will install pack(lib) if not present in your system
?- use_module(library(lib)).
?- lib(mtx).
?- mtx(data(mtcars),MtCars).
Mtcars = [row(mpg, cyl, disp, hp, ....

Input/Output:

At the very least library(mtx) can be viewed as an addition/enhancement io of matrices to files via mtx/2. The library can interrogate the data/ subdirectory of all installed packs for csv files using alias data.

?- mtx( data(mtcars), Mtcars ).
Mtcars = [row(mpg, cyl, disp, hp, ....

Where mtcars.csv is in some pack's data directory.

?- mtx_data( mtcars, Mtcars ).
Mtx = [row(mpg, cyl, disp, hp, ....)|...]

Where mtcars.csv is in pack(mtx) data subdirectory.

mtx/2 works both as input and output.

If the 2nd argument is ground, mtx/2 with output the 2nd argument to the file pointed by the 1st. Else, the 1st argument is taken as the input file or matrix, and the 2nd argument is the same matrix in standard form.

?- tmp_file( mtc, TmpF ), mtx( pack('mtx/data/mtcars'), Mtc ), mtx( TmpF, Mtc ).
TmpF = '/tmp/pl_mtc_14092_0',
Mtc = [row(mpg, cyl,

The first call to mtx/2 above, inputs the test csv mtcars.csv, to Mtc (instantiated to list of rows). The second call, outputs Mtc to the temporary file TmpF.

mtx/3 provides a couple of options on top of csv_read_file/3 and csv_write_file/3.

sep(Sep)
is short for separator, that also understands comma, tab and space (see mtx_sep/2).
match(Match)
is short for match_arity(Match)
?- mtx( data(mtcars), Mtcars, sep(comma) ).
Mtcars = [row(mpg, cyl, disp, hp, ....)|...]

Good places to start:

materials

web-page: http://stoics.org.uk/~nicos/sware/mtx doc: http://stoics.org.uk/~nicos/sware/mtx/doc/html/mtx.html source: http://stoics.org.uk/~nicos/sware/packs/mtx/ github: https://github.com/nicos-angelopoulos/mtx

licence: MIT

Nicos Angelopoulos http://stoics.org.uk/~nicos April 2018

Contents of pack "mtx"

Pack contains 81 files holding a total of 301K bytes.