From: timv Date: Mon, 17 Dec 2012 20:47:30 +0000 (-0500) Subject: using "pair-valued" shape as suggested by Jason in 12/14 Dyna meeting. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=0e3eaba1ed65e75f2278c53ac48aac1f59da1f00;p=dyna2 using "pair-valued" shape as suggested by Jason in 12/14 Dyna meeting. --- 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.