We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 34a57d1 commit dc55835Copy full SHA for dc55835
1 file changed
crates/zynml/examples/basic_tensor.zynml
@@ -0,0 +1,20 @@
1
+// ZynML Example: Basic Tensor Operations
2
+// Run with: zynml run examples/basic_tensor.zynml
3
+
4
+fn main() {
5
+ // Create tensors
6
+ let a = tensor([1.0, 2.0, 3.0])
7
+ let b = tensor([4.0, 5.0, 6.0])
8
9
+ // Test addition with + operator (trait dispatch to $Tensor$add)
10
+ let c = a + b
11
+ extern tensor_println(c) // Should print: [5.0, 7.0, 9.0]
12
13
+ // Test multiplication with * operator (trait dispatch to $Tensor$mul)
14
+ let d = a * b
15
+ extern tensor_println(d) // Should print: [4.0, 10.0, 18.0]
16
17
+ // Test subtraction
18
+ let e = b - a
19
+ extern tensor_println(e) // Should print: [3.0, 3.0, 3.0]
20
+}
0 commit comments