About the matrix.pl module

Hi everybody

I am new in this forum and resuming the programming with SWI-Prolog after many years …
I am developing an application with small animation over the output in the screen. However, this data structure is a list of lists, such:
[
[+,-,+,-,-,-,+,-,-,-,+,-,-,-,+,-,-,-,+]
[|, ,|, , , ,|, , , ,|, , , ,|, , , ,|]
[|, , , ,|, , , ,|, , , ,|, , , ,|, ,|]
[+,-,-,-,+,-,-,-,+,-,-,-,+,-,-,-,+,-,+]
]
in the blank spaces I need to create some edges, meaning, for instance,
point 2 is connect 3 and so on.

This task should be tremendous facilitated if this structure had been a matrix (2D).
Once that each edges can be in horizontal or vertical alignment.

Searching for a module or predicate to do it, I found the matrix.pl
https://www.swi-prolog.org/pack/file_details/matrix/prolog/matrix.pl?show=src
with all most predicates for matrix manipulation.
So I tried to install such package, using:

?- pack_install(matrix).
% Contacting server at XXXX://www.swi-prolog.org/pack/query …
ERROR: url `‘XXX://www.swi-prolog.org/pack/query’’ does not exist (status(500,Internal Server Error))
ERROR: In:
ERROR: [18] throw(error(existence_error(url,‘XXX://www.swi-prolog.org/pack/query’),context(_1360,…)))

effectively the
:- module(matrix,
[ matrix_write/1, …

brings all the predicates for matrices.

Well, someone could some details on this module?
How to use? Where is the latest version of this module?
How to install? an example?
Effectively in this case, the matrix uses should be very appropriate …

Thanks in advance

I’m using: SWI-Prolog version ???
Welcome to SWI-Prolog (threaded, 64 bits, version 8.0.1)

I want the code to:
wishing to use matrix instead of lists

But what I’m getting is:
I can’t install this module

My code looks like this:
reported above

% your code here

Welcome back :slight_smile:

www.swi-prolog.org moved to HTTPS, which breaks the old pack installer. Update to 8.0.3 or 8.1.8 and the pack_install should work again. Alternatively, download the pack file by hand and run pack_install with the file as argument.

It’s sometimes possible to do matrices in pure Prolog. E.g., https://link.springer.com/chapter/10.1007/978-3-642-58274-5_10 (behind a paywall).
I can’t give you much more detail, because I’ve never needed to do this.
I recall that someone (Richard O’Keefe?) did a Prolog FFT implementation that was speed competitive with a C implementation, but I couldn’t find the details. Perhaps search in comp.lang.prolog will find it, if that’s technique is useful to you.

Hi Claudio,
you can find documentation on matrix.pl at

https://www.swi-prolog.org/pack/file_details/matrix/prolog/matrix.pl

I also suggest to look at pack ffimatrix

https://www.swi-prolog.org/pack/list?p=ffimatrix

that uses well established C libraries for matrix algebra

doc at

https://www.swi-prolog.org/pack/file_details/ffimatrix/prolog/ffimatrix.pl

Fabrizio

Jan

I did the upgrade to 8.1.5
… Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.5) …

I did the sequence to install packages:
?- use_module(library(prolog_pack)).
true.

?- pack_list_installed.
% There are no extra packages installed.
% Please visit htXXXXtp://www.swi-prolog.org/pack/list.
true.

?- pack_list(’’).
% Contacting server at htXXXXtp://www.swi-prolog.org/pack/query …
ERROR: url 'htXXXXtps://www.swi-prolog.org/pack/query'' does not exist (status(500,Internal Server Error)) ........................... and I tried ?- pack_install(ffimatrix). % Contacting server at XXXXX://www.swi-prolog.org/pack/query ... ERROR: url‘httpXXXXXs://www.swi-prolog.org/pack/query’’ does not exist (status(500,Internal Server Error))
ERROR: In:

Unfortunately, nothing … :sleepy::sleepy:

What are the steps to install manually the matrix.pl and ffimatrix.pl?

As Fabricio wrote below, some predicates that I am interested are in
ffimatrix.pl, such transform a list of lists in a matrix,
and the reversal operation.

I tried to install packages very stable such:
?- pack_install(list_util).
% Contacting server at XXXXX://www.swi-prolog.org/pack/query …
ERROR: url `‘XXXXX://www.swi-prolog.org/pack/query’’ does not exist (status(500,Internal Server Error))

Is there something wrong with my swipl? Permissions? I tried as root … and I using the Linux Manjaro …

Is there a manual installation?
Something like to put in the package directly in
/usr/lib/swipl/library
and rerun some command to be recognized?

thanks once …

Claudio

Yes Fabrizio

the ffmatrix is more useful than matrix.pl … but I have being troubles with the installation.
I am using the Manjaro Linux … not UBUNTU …
please see my discussion with Jan …

I tried to use ffimatrix.pl directly in a directory … but it needs other files

If you could give some tips to install it … thanks in advance

Claudio

Thanks

I will check these codes …
but if SWI-PROLOG has some packs to do it directly … we need to improve them

claudio

You need version 8.1.8 (development) or 8.0.3 (stable).

Thanks Jan …
I had some improvements … except by the ffimatrix.pl
but I will do this upgrade

claudio