Module Vector
Jan Burse, created Oct 15. 2018
/**
* This module provides vectors of element columns. A vector is a
* compound with varying number of elements which can be constants
* or symbolic expressions. An element can be accessed by the
* predicate []/3. The first element has the index one. The arity
* of the vector can be queried by the predicate len/2. Vectors can
* be created by the two special forms [_ | _] and {_ | _} introduced
* in the module element.
*
* Examples:
* ?- X is [A,B,C], Y is len(X).
* X is [A,B,C],
* Y = 3
* ?- X is [A,B,C], Z is X[2].
* X is [A,B,C],
* Z is B
*
* The predicate sum/2, min/2 and max/2 can be used to compute the sum,
* minimum or maximum of the elements of a vector. Further aggregate
* functions are currently not provided. This module further provides
* some rudimentary arithmetic such as sign change, addition and subtraction.
* Other operations such as scalar product or transposing are currently
* not provided. Error handling is rudimentary.
*
* The vector based consing returns a matrix. The consing does currently
* not check that the second argument is a proper list and that all
* elements of the list are vectors. The intention here is to use the
* consing to only create homogenous matrixes of vectors. The reader
* interested in the methods of the matrix should browse into the
* module matrix.
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies GmbH makes no warranties
* regarding the provided information. XLOG Technologies GmbH assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies GmbH.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies GmbH. If the company was not the originator of some
* excerpts, XLOG Technologies GmbH has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies GmbH.
*/
/***********************************************************/
/* Array Builder & Access */
/***********************************************************/
* .(X, Y, Z):
* The predicate succeeds in Z with the consing of X and Y.
*/
% .(+Vector, +List, -Matrice)
* X[Y, Z]:
* The predicate succeeds in Z with the Y-the element
* of the vector X.
*/
% +Vector [+Integer, -Element]
* len(X, Y):
* The predicate succeeds in Y with the number of elements
* in the vector X.
*/
% len(+Vector, -Integer)
* sum(X, Y):
* The predicate succeeds in Y with the sum of elements
* in the vector X.
*/
% sum(+Vector, -Internal)
% sys_sum_vector(+List, +Internal, -Internal)
* min(X, Y):
* The predicate succeeds in Y with the minimum of the
* elements in the vector X.
*/
% min(+Vector, -Internal)
% sys_min_vector(+List, +Internal, -Internal)
* max(X, Y):
* The predicate succeeds in Y with the maximum of the
* elements in the vector X.
*/
% max(+Vector, -Internal)
% sys_max_vector(+List, +Internal, -Internal)
/***********************************************************/
/* Basic Arithmetic */
/***********************************************************/
* -(X, Y):
* The predicate succeeds in Y with the sign changed vector X.
*/
% -(+Vector, -Vector)
* +(X, Y, Z):
* The predicate succeeds in Z with the sum of the vector X and
* the vector Y.
*/
% +(+Vector, +Internal, -Vector)
* -(X, Y, Z):
* The predicate succeeds in Z with the vector X subtracted
* by the vector Y.
*/
% -(+Vector, +Internal, -Vector)
/***********************************************************/
/* CAS BindCount[] Hook */
/***********************************************************/
* sys_printable_value(F, G):
* The predicate succeeds in G with a custom form of F. The
* predicate should be extended for custom forms.
*/
% sys_printable_value(+Term, -Term)
:- public residue
:sys_printable_value
/2.
% sys_portray_vector(+List, -List)
/*********************************************************************/
/* Generic Hook */
/*********************************************************************/
* X is E:
* The predicate succeeds in evaluating E by using polymorphism.
*/
% is(-Internal, +Expr)
Comments