matrix_foldl/3¶
matrix_foldl(Pred, A, V0, VF)*
matrix_foldl(Pred, A, V0, VF)* 5B Apply Pred(A, B,V1,V2,Index) to every element of matrixes A, B, where Index ranges over all entries in the matric.
Apply Pred(A,V1,V2,Index) to every element of matrix A, where Index ranges over all entries in the array.
As an example, to sum all elements of a numeric matrix: ```
add(A, S0, S, B) :- matrix_get( A, I, V), S is S0+V. sum_matrix(A,S) :- matrix_foldl(add,A,0,S). ?- X <== [[1.2,0.9,5],[0.1,0.2,0.3]], sum_matrix(X,S).
As an example, to compute the absolute error betwern numeric matrix: ```
add_d(A,B, S0, S, [I]) :- V is A[I]-B[I], S is S0+abs(V).
sum_d_matrix(A,B,S) :- matrix_foldl(add_d,A,B,0,S).
?- X <== [[1.2,0.9,5],[0.1,0.2,0.3]], sum_d_matrix(X,S).