[Swift-commit] r8106 - SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Tue Aug 12 11:59:45 CDT 2014
Author: wozniak
Date: 2014-08-12 11:59:45 -0500 (Tue, 12 Aug 2014)
New Revision: 8106
Added:
SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift
Log:
Adding numpy.swift
Added: SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift
===================================================================
--- SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift (rev 0)
+++ SwiftTutorials/ATPESC_2014-08-14/swift-t/examples/04-py/numpy.swift 2014-08-12 16:59:45 UTC (rev 8106)
@@ -0,0 +1,22 @@
+
+// Numpy/Swift library
+
+global const string numpy = "from numpy import *\n\n";
+
+typedef matrix string;
+
+(matrix A) eye(int n)
+{
+ string command = sprintf("repr(eye(%i))", n);
+ string code = numpy+command;
+ matrix t = python(code);
+ A = replace_all(t, "\n", "", 0);
+}
+
+(matrix R) add(matrix A1, matrix A2)
+{
+ string command = sprintf("repr(%s+%s)", A1, A2);
+ string code = numpy+command;
+ matrix t = python(code);
+ R = replace_all(t, "\n", "", 0);
+}
More information about the Swift-commit
mailing list