Re: Matrices implementations



I think you are perfectly right about the need for C/C++ algorithms.
But this is contrary of my personal thoughts. That is, if I want Prolog to
be just a toplevel, I do not see fantistic advantages than using, lets say,
bash (or dos). So, it is in my expectation that Prolog systems could advance
in performance to reduce at the minumum the need of switching to C/C++. This
is, of course, just for relatively small projects.
Consider, as an example, a bioinformatic project to analyze sequences. Sure
we should avoid Prolog based algorithm to process the entire human genome!
But I think Prolog will be useful to spare time in writing programs which
deal with the "substance" of the problem...

Without opening a new thread, I want to introduce an example exercise, that
is "extract all substrings from a string, except the empty string". This in
Prolog can be done with such a predicate:

extract_substring(String, SubString) :-
atom_concat(S, _, String),
atom_concat(_, SubString, String),
SubString \= ''.

Now, I ask: Write down the same algorithm in C.

See you soon.
Cheers - /\/\


"A..L." <alewando@xxxxxxxxxxxx> ha scritto nel messaggio
news:9kb982dipj6v0nhdqn5258o90lrcpn0q7o@xxxxxxxxxx
On Mon, 5 Jun 2006 16:56:24 +0200, "Mauro DiNuzzo"
<picorna@xxxxxxxxx> wrote:

Well, I have implemented it by myself. However...
For "robust" I intend hardly tested under every point of view, especially
two (errors and performance):
a) Almost total absence of bugs;
b) Quite fast algorithms.
For "handling" I intend the following:
a) Represent matrices in a Prolog data structure (I think there are many
ways for this);
b) Manipulating matrix structures by means of Prolog predicates and/or
operators;
c) Perform some specific operations over matrices.
In particular, I implemented my own "square matrices" Prolog module in
which
square-Matrices are represented like a list of a list (e.g. 2-order
identity
is [[1,0],[0,1]]) and it is possible to perform some basic operations on
them, such as (i) transposing a matrix, (ii) extracting diagonal
elements,
(iii) calculate the inverse of a matrix, (iv) calculate the norm of a
matrix, (v) perform the product of a matrix and a vector-column, (vi)
etc...
Basically, I need square matrices support for an applications that deals
with bioinformatics, but I was unable to find a tested one. Of course, it
is
time-expensive to implement a complete library of predicates (e.g. for
the
calculation of eigenvalues/eigenvectors)

Well, "maipulating" matrices in Prolog is OK, but I wild never try
to implement numerical algorithms such as eigenvalues or inverse
calculation. Algorithms that are robust are not trivial, especially
if you want to solve problems that are larger than typical academic
examples. The only reasonable way for me is to implement predicates
for "handling", i.e. not much more than accessing values using
indexec, but delagate numerical computations to existing packages
written in, excuse me, C++ ot C... For the same reason we buy LP
solvers from ILOG or Dash but don't do this in-house.

A.L.


.



Relevant Pages

  • Re: String manipulation in Prolog
    ... > I'm exploring the use of Prolog in text/corpus processing. ... > can't find much in the way of string manipulation. ... > insert a substring into a string ...
    (comp.lang.prolog)
  • Re: An instance of Russells paradox?
    ... > Prolog is seriously not a good choice for that. ... Can all algorithms be enumerated, ... > only if you can formulate the enumeration algorithmically. ... > upon these finite arities, ...
    (sci.logic)
  • Re: An instance of Russells paradox?
    ... Prolog is seriously not a good choice for that. ... Can all algorithms be enumerated, ... only if you can formulate the enumeration algorithmically. ... upon these finite arities, it might ...
    (sci.logic)
  • Re: Problem
    ... > algorithms without pass by the list form. ... > Me, like a lot of people, when using prolog, I made an effort to skip ... Isn't findall Prolog for you? ...
    (comp.lang.prolog)
  • Re: Possible to register a foreign function dynamically?
    ... anything, it just returns the pointer to the actual string, so I don't ... Actually it can also come along during the lifetime of the predicate ... Prolog threads active. ... If above is how Python programmers would like to see it, ...
    (comp.lang.prolog)