Skip to content

Commit 809b162

Browse files
kowalewskij9prady9
authored andcommitted
Added Integer C# example
1 parent 2dfae7c commit 809b162

File tree

4 files changed

+101
-2
lines changed

4 files changed

+101
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Examples/Unified/FSharp/obj/
1919
/test/ArrayFire.UnitTest/bin/Release/netcoreapp2.2
2020
/src/Wrapper/bin
2121
/packages/FSharp.Core.4.6.2
22+
/Examples/GettingStarted/Integer/CSharp/bin
23+
/Examples/GettingStarted/Integer/CSharp/obj

ArrayFire.sln

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.271
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29020.237
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{45CBAB24-008E-4178-A16A-9FBBE040CDBE}"
77
EndProject
@@ -23,6 +23,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArrayFire.UnitTest", "test\
2323
EndProject
2424
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AutoGenTool", "AutoGenTool\AutoGenTool.fsproj", "{C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}"
2525
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GettingStarted", "GettingStarted", "{FAAB6802-F422-4F69-B543-5A68A81245FD}"
27+
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Integer (CSharp)", "Examples\GettingStarted\Integer\CSharp\Integer (CSharp).csproj", "{CF93F274-DA85-4845-81DB-C719B95665DA}"
29+
EndProject
2630
Global
2731
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2832
Debug|Any CPU = Debug|Any CPU
@@ -85,6 +89,14 @@ Global
8589
{C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|Any CPU.ActiveCfg = Release|x64
8690
{C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|x64.ActiveCfg = Release|x64
8791
{C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|x64.Build.0 = Release|x64
92+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
94+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|x64.ActiveCfg = Debug|Any CPU
95+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|x64.Build.0 = Debug|Any CPU
96+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Release|Any CPU.Build.0 = Release|Any CPU
98+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Release|x64.ActiveCfg = Release|Any CPU
99+
{CF93F274-DA85-4845-81DB-C719B95665DA}.Release|x64.Build.0 = Release|Any CPU
88100
EndGlobalSection
89101
GlobalSection(SolutionProperties) = preSolution
90102
HideSolutionNode = FALSE
@@ -96,6 +108,8 @@ Global
96108
{40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7} = {3C7B8845-1E14-4C71-BBFE-979743D577F7}
97109
{A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3} = {0292AF78-CBCD-4005-9A62-3399F43F22BE}
98110
{E1B97271-6364-4D9E-972A-A65156674BF4} = {0292AF78-CBCD-4005-9A62-3399F43F22BE}
111+
{FAAB6802-F422-4F69-B543-5A68A81245FD} = {45CBAB24-008E-4178-A16A-9FBBE040CDBE}
112+
{CF93F274-DA85-4845-81DB-C719B95665DA} = {FAAB6802-F422-4F69-B543-5A68A81245FD}
99113
EndGlobalSection
100114
GlobalSection(ExtensibilityGlobals) = postSolution
101115
SolutionGuid = {E3A0DE14-88D3-4AEC-B6F6-97A6CA052C53}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.2</TargetFramework>
6+
<RootNamespace>GettingStarted__Integer__CSharp_</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\..\..\src\Wrapper\ArrayFire.csproj" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
using ArrayFire;
2+
using System;
3+
4+
namespace GettingStarted__Integer__CSharp_
5+
{
6+
/// <summary>
7+
/// port from getting_started\integer.cpp
8+
/// </summary>
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
Device.SetBackend(Backend.DEFAULT);
14+
Device.PrintInfo();
15+
Console.Write("\n=== ArrayFire signed(s32) / unsigned(u32) Integer Example ===\n");
16+
17+
int[,] h_A = new int[,]{ { 1, 2, 4 }, { -1, 2, 0 }, { 4, 2, 3 } };
18+
int[,] h_B = new int[,] { { 2, 3, -5 }, { 6, 0, 10 }, { -12, 0, 1 } };
19+
20+
ArrayFire.Array A = Data.CreateArray(h_A);
21+
ArrayFire.Array B = Data.CreateArray(h_B);
22+
23+
Console.Write("--\nSub-refencing and Sub-assignment\n");
24+
25+
Util.Print(A, "A");
26+
Util.Print(A.Rows(0, 0), "A's first row");
27+
Util.Print(A.Cols(0, 0), "A's first column");
28+
A[0, 0] = Data.CreateArray(new int[] { 100 });
29+
A[1, 2] = Data.CreateArray(new int[] { 100 });
30+
Util.Print(A, "A");
31+
Util.Print(B, "B");
32+
A[1, Util.Span] = B[2, Util.Span];
33+
Util.Print(A, "A");
34+
Util.Print(B, "B");
35+
36+
Console.Write("--Bit-wise operations\n");
37+
Util.Print(A & B, "A & B");
38+
Util.Print(A | B, "A | B");
39+
Util.Print(A ^ B, "A ^ B");
40+
41+
Console.Write("\n--Transpose\n");
42+
Util.Print(A, "A");
43+
Util.Print(Matrix.Transpose(A, false), "Matrix.Transpose(A)");
44+
45+
Console.Write("\n--Sum along columns\n");
46+
Util.Print(A, "A");
47+
Util.Print(Algorithm.Sum(A), "Algorithm.Sum(A)");
48+
49+
Console.Write("\n--Product along columns\n");
50+
Util.Print(A, "A");
51+
Util.Print(Algorithm.Product(A), "Algorithm.Product(A)");
52+
53+
Console.Write("\n--Minimum along columns\n");
54+
Util.Print(A, "A");
55+
Util.Print(Algorithm.Min(A), "Algorithm.Min(A)");
56+
57+
Console.Write("\n--Maximum along columns\n");
58+
Util.Print(A, "A");
59+
Util.Print(Algorithm.Max(A), "Algorithm.Max(A)");
60+
61+
Console.Write("\n--Minimum along columns with index\n");
62+
Util.Print(A, "A");
63+
64+
ArrayFire.Array outArray, idx;
65+
outArray = Algorithm.Min(A, out idx);
66+
Util.Print(outArray, "output");
67+
Util.Print(idx, "indexes");
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)