Skip to content

Commit d2b6f9d

Browse files
committed
added a simple example
1 parent b55c74c commit d2b6f9d

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

Numpy.NET.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Numpy", "src\Numpy\Numpy.cs
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Numpy.UnitTest", "test\Numpy.UnitTest\Numpy.UnitTest.csproj", "{1B69F24E-8C60-421D-B11B-5306ED7A060E}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{25D84E98-E107-45C9-A0EC-0B25E24DA607}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatmulExample", "src\Examples\MatmulExample\MatmulExample.csproj", "{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
@@ -21,10 +25,17 @@ Global
2125
{1B69F24E-8C60-421D-B11B-5306ED7A060E}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{1B69F24E-8C60-421D-B11B-5306ED7A060E}.Release|Any CPU.ActiveCfg = Release|Any CPU
2327
{1B69F24E-8C60-421D-B11B-5306ED7A060E}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F}.Release|Any CPU.Build.0 = Release|Any CPU
2432
EndGlobalSection
2533
GlobalSection(SolutionProperties) = preSolution
2634
HideSolutionNode = FALSE
2735
EndGlobalSection
36+
GlobalSection(NestedProjects) = preSolution
37+
{A92C1287-BF2B-4FDC-8BBA-A17F410CD41F} = {25D84E98-E107-45C9-A0EC-0B25E24DA607}
38+
EndGlobalSection
2839
GlobalSection(ExtensibilityGlobals) = postSolution
2940
SolutionGuid = {5EB08541-5168-443C-B524-A5CB7E7C613D}
3041
EndGlobalSection

doc/img/numpy_intellisense.png

14.5 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.2</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\Numpy\Numpy.csproj" />
10+
</ItemGroup>
11+
12+
</Project>

src/Examples/MatmulExample/Program.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Diagnostics;
3+
using Numpy;
4+
5+
namespace MatmulExample
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
Console.WriteLine("Efficient matrix multiplication with NumPy (only GPU backed libraries are faster):");
12+
// before starting the measurement, let us call numpy once to get the setup checks done.
13+
np.arange(1);
14+
15+
var stopwatch = Stopwatch.StartNew();
16+
var a1 = np.arange(60000).reshape(300, 200);
17+
var a2 = np.arange(80000).reshape(200, 400);
18+
19+
var result = np.matmul(a1, a2);
20+
stopwatch.Stop();
21+
22+
Console.WriteLine($"execution time with NumPy: {stopwatch.Elapsed.TotalMilliseconds}ms\n");
23+
24+
Console.WriteLine("Result:\n"+result.repr);
25+
Console.ReadKey();
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy