Minor changes to comments and to scale_polynomial
This commit is contained in:
parent
3471f6a328
commit
202f57ef9d
35
polimani.pl
35
polimani.pl
@ -13,33 +13,33 @@
|
||||
*
|
||||
* Hugo David Cordeiro Sales
|
||||
* up201704178@fc.up.pt
|
||||
*/
|
||||
*
|
||||
|
||||
/*********************************************
|
||||
*********************************************
|
||||
* Follows 'Coding guidelines for Prolog' *
|
||||
* https://doi.org/10.1017/S1471068411000391 *
|
||||
*********************************************/
|
||||
*********************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
Import the Constraint Logic Programming over Finite Domains lybrary
|
||||
Essentially, this library improves the way Prolog deals with integers,
|
||||
allowing more predicates to be reversible.
|
||||
For instance, number(N) is always false, which prevents the
|
||||
reversing of a predicate.
|
||||
*/
|
||||
/* Import the Constraint Logic Programming over Finite Domains lybrary
|
||||
* Essentially, this library improves the way Prolog deals with integers,
|
||||
* allowing more predicates to be reversible.
|
||||
* For instance, number(N) is always false, which prevents the
|
||||
* reversing of a predicate.
|
||||
*/
|
||||
:- use_module(library(clpfd)).
|
||||
|
||||
|
||||
/*******************************
|
||||
* USER INTERFACE *
|
||||
*******************************/
|
||||
|
||||
/*
|
||||
poly2list/2 transforms a list representing a polynomial (second
|
||||
argument) into a polynomial represented as an expression (first argu-
|
||||
ment) and vice-versa.
|
||||
*/
|
||||
poly2list(P, L) :-
|
||||
polynomial_to_list(P,L).
|
||||
polynomial_to_list(P, L).
|
||||
|
||||
/*
|
||||
simpolylist/2 simplifies a polynomial represented as a list into
|
||||
@ -56,7 +56,7 @@ simpoly(P, S) :-
|
||||
simplify_polynomial(P, S).
|
||||
|
||||
/*
|
||||
scalepoly/3 multiplies one polynomial as expression by a scalar
|
||||
scalepoly/3 multiplies a polynomial represented as an expression by a scalar
|
||||
resulting in a second polynomial. The two first arguments are assumed to
|
||||
be ground. The polynomial resulting from the sum is in simplified form.
|
||||
*/
|
||||
@ -71,6 +71,7 @@ scalepoly(P1, P2, S) :-
|
||||
addpoly(P1, P2, S) :-
|
||||
add_polynomial(P1, P2, S).
|
||||
|
||||
|
||||
/*******************************
|
||||
* BACKEND *
|
||||
*******************************/
|
||||
@ -474,14 +475,12 @@ append_two_atoms_with_star(V1, V2, R) :-
|
||||
scale_polynomial(P, C, S) :-
|
||||
polynomial_to_list(P, L),
|
||||
maplist(append_two_atoms_with_star(C), L, L2),
|
||||
list_to_polynomial(L2, S).
|
||||
%simplify_polynomial(S1, S).
|
||||
polynomial_to_list(S, L2),
|
||||
simplify_polynomial(S, S1),
|
||||
!.
|
||||
%% Tests:
|
||||
%% ?- scale_polynomial(3*x^2, 2, S).
|
||||
%@ S = 2*3*x^2.
|
||||
%@ S = 2*(3*x^2).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user