-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathProgram.cs
More file actions
33 lines (30 loc) · 1.16 KB
/
Program.cs
File metadata and controls
33 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using ArrayFire;
using System;
namespace HelloWorld__CSharp_
{
class Program
{
static void Main(string[] args)
{
Device.SetBackend(Backend.DEFAULT);
Device.PrintInfo();
var arr1 = Data.RandNormal<float>(3, 3);
var arr2 = Data.RandNormal<float>(3, 3);
var arr3 = arr1 + arr2;
var arr4 = Matrix.Multiply(arr1, arr2);
var arr5 = Arith.Sin(arr1) + Arith.Cos(arr2);
Util.Print(arr1, "arr1");
Util.Print(arr2, "arr2");
Util.Print(arr3, "arr1 + arr2");
Util.Print(arr4, "arr1 * arr2 (matrix product)");
Util.Print(arr5, "Sin(arr1) + Cos(arr2)");
// new! indexing:
Util.Print(arr1[Util.Span, 0], "arr1's first column");
Util.Print(arr1.Cols(0, 0), "arr1's first row (again)");
var corner = arr1[Util.Seq(0, 1), Util.Seq(0, 1)];
Util.Print(corner, "arr1's top-left 2x2 corner");
arr2[Util.Seq(1, 2), Util.Seq(1, 2)] = corner;
Util.Print(arr2, "arr2 with botton-right 2x2 corner ovewritten with the previous result");
}
}
}