]> hydra-www.ietfng.org Git - dyna2/commitdiff
matrix shape.
authortimv <tim.f.vieira@gmail.com>
Thu, 13 Dec 2012 18:46:48 +0000 (13:46 -0500)
committertimv <tim.f.vieira@gmail.com>
Thu, 13 Dec 2012 18:46:48 +0000 (13:46 -0500)
bin/prototype.py
bin/stdlib.py
examples/matrixops.dyna

index 4e97c45951800d1499211507d789bb9dc858ea12..bc45fcd0da44ce8f01333da19c2fcfeb6d7faccf 100644 (file)
@@ -299,7 +299,10 @@ function selectline(lineno) {
         print >> html, '<h2>Update plans</h2>'
 
         cmd = """ghc -isrc Dyna.Backend.Python -e 'processFile "%s"' """ % dynafile
-        assert 0 == os.system(cmd), 'command failed:\n\t' + cmd
+        if 0 != os.system(cmd):
+            print 'command failed:\n\t' + cmd
+            os.system('gnome-open %s 2>/dev/null >/dev/null' % html.name)
+            return
 
 #        print >> html, '<pre>'
 
@@ -340,9 +343,6 @@ function selectline(lineno) {
         print >> html, '</div>'
 
 
-    print
-    print 'wrote', html.name
-
     if argv.browser:
         os.system('gnome-open %s 2>/dev/null >/dev/null' % html.name)
 
index 46cb95fa0e1a79b70b5693ad1515bab070bb3fde..2b4726d257a280cae2c6e40fbd8b769e0da58a63 100644 (file)
@@ -36,7 +36,7 @@ def dump_charts(out=sys.stdout):
         print >> out, x
         print >> out, '====================================='
 
-        rows = [(pretty((x,idx)), idx, row, pretty(row[-1])) for idx, row in chart[x].data.items()]
+        rows = [(pretty((x,idx)), idx, row, pretty(row[-1])) for idx, row in chart[x].data.items() if row[-1] is not None]
         rows.sort()
 
         for p, _, _, v in rows:
index 9cf7d915b1d588309ab1d992db0eaef256b5b29c..288dd979e62385b5ae7eb288eb4992543871fd26 100644 (file)
@@ -1,11 +1,19 @@
 
 
-% A and B are names of matricies
-times(A, B, I, J)    += m(A, I, K) * m(B, K, J).
-times(A, B, C, I, L) += m(A, I, K) * m(B, K, J) * m(C, J, L).
+% A and B are names of matrices
+times(A, B, I, J) += m(A, I, K) * m(B, K, J) whenever product(A,B).
+
+m(P, I, J) += shape(A, R, C),
+              shape(B, C, D),
+              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(X, *rows(X), *cols(X)).
+rows(X) max= m(X, R, _), R.
+cols(X) max= m(X, _, C), C.
 
-% matrix "c" is the product of matricies "a" and "b"
-m(c, I, J) += times(a, b, I, J).
 
 % matrix "a" = [ 1 0 ;
 %                0 1 ]
@@ -14,9 +22,14 @@ m(a, 1, 2) += 0 .
 m(a, 2, 1) += 0 .
 m(a, 2, 2) += 1.
 
-% matrix "b" = [ 3 0 ;
-%                0 2 ]
+% matrix "b" = [ 3 0 ;
+%                0 2 ]
 m(b, 1, 1) += 3.
 m(b, 1, 2) += 0 .
+m(b, 1, 3) += 1 .
 m(b, 2, 1) += 0 .
 m(b, 2, 2) += 2.
+m(b, 2, 3) += 0 .
+
+% matrix "c" is the product of matricies "a" and "b"
+product(a,b) += &c