From 0e3eaba1ed65e75f2278c53ac48aac1f59da1f00 Mon Sep 17 00:00:00 2001 From: timv Date: Mon, 17 Dec 2012 15:47:30 -0500 Subject: [PATCH] using "pair-valued" shape as suggested by Jason in 12/14 Dyna meeting. --- examples/matrixops.dyna | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/matrixops.dyna b/examples/matrixops.dyna index 288dd97..c2050ce 100644 --- a/examples/matrixops.dyna +++ b/examples/matrixops.dyna @@ -1,16 +1,20 @@ + + % A and B are names of matrices -times(A, B, I, J) += m(A, I, K) * m(B, K, J) whenever product(A,B). +times(A, B, I, J) += m(A, I, K) * m(B, K, J) whenever product(A,B). % use "?" -m(P, I, J) += shape(A, R, C), - shape(B, C, D), +m(P, I, J) += pair(R, C) is shape(A), + pair(C, D) is shape(B), P is product(A, B), times(A, B, I, J). -shape(P, R, C) :- P is product(A, B), shape(A, R, X), shape(B, X, C). +%shape(P, R, C) :- P is product(A, B), shape(A, R, X), shape(B, X, C). + +shape(A) += &pair(*rows(A), *cols(A)). -shape(X, *rows(X), *cols(X)). +%shape(X, *rows(X), *cols(X)). rows(X) max= m(X, R, _), R. cols(X) max= m(X, _, C), C. -- 2.50.1