├── .gitignore
├── ArrayFire.sln
├── AutoGenTool
├── App.config
├── AutoGenTool.fsproj
├── CodeWriter.fs
├── Config.fs
├── ForInDo.fs
├── Interop.fs
├── Program.fs
├── Utils.fs
└── packages.config
├── Examples
├── GettingStarted
│ └── Integer
│ │ ├── CSharp
│ │ ├── Integer (CSharp).csproj
│ │ └── Program.cs
│ │ └── FSharp
│ │ ├── App.config
│ │ ├── Integer (FSharp).fsproj
│ │ └── Program.fs
├── HelloWorld
│ ├── CSharp
│ │ ├── HelloWorld (CSharp).csproj
│ │ └── Program.cs
│ └── FSharp
│ │ ├── App.config
│ │ ├── HelloWorld (FSharp).fsproj
│ │ └── Program.fs
└── Unified
│ ├── CSharp
│ ├── Program.cs
│ └── Unified (CSharp).csproj
│ └── FSharp
│ ├── App.config
│ ├── Program.fs
│ └── Unified (FSharp).fsproj
├── LICENSE
├── README.md
├── src
└── Wrapper
│ ├── Algorithm.cs
│ ├── Arith.cs
│ ├── Array.cs
│ ├── ArrayFire.csproj
│ ├── Data.cs
│ ├── Device.cs
│ ├── Internal.cs
│ ├── Interop
│ ├── AFAlgorithm.cs
│ ├── AFArith.cs
│ ├── AFArray.cs
│ ├── AFBackend.cs
│ ├── AFBlas.cs
│ ├── AFData.cs
│ ├── AFDevice.cs
│ ├── AFIndex.cs
│ ├── AFInternal.cs
│ ├── AFLapack.cs
│ ├── AFRandom.cs
│ ├── AFSignal.cs
│ ├── AFSparse.cs
│ ├── AFStatistics.cs
│ ├── AFUtil.cs
│ ├── enums.cs
│ └── types.cs
│ ├── Matrix.cs
│ ├── Util.cs
│ ├── Vector.cs
│ ├── enums.cs
│ └── exceptions.cs
└── test
└── ArrayFire.UnitTest
├── ArrayFire.UnitTest.csproj
├── ArrayTest.cs
└── UnitTestBase.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | Wrapper/obj/
2 | Wrapper/bin/
3 | AutoGenTool/bin/
4 | AutoGenTool/obj/
5 | Examples/HelloWorld/CSharp/bin/
6 | Examples/HelloWorld/CSharp/obj/
7 | Examples/HelloWorld/FSharp/bin/
8 | Examples/HelloWorld/FSharp/obj/
9 | Examples/Unified/CSharp/bin/
10 | Examples/Unified/CSharp/obj/
11 | Examples/Unified/FSharp/bin/
12 | Examples/Unified/FSharp/obj/
13 | .vs
14 | /src/Wrapper/bin/Debug/netstandard2.0
15 | /src/Wrapper/obj
16 | /test/ArrayFire.UnitTest/obj
17 | /test/ArrayFire.UnitTest/bin/Debug/netcoreapp2.2
18 | /AutoGenTool/packages/FSharp.Core.4.6.2
19 | /test/ArrayFire.UnitTest/bin/Release/netcoreapp2.2
20 | /src/Wrapper/bin
21 | /packages/FSharp.Core.4.6.2
22 | /Examples/GettingStarted/Integer/CSharp/bin
23 | /Examples/GettingStarted/Integer/CSharp/obj
24 | /Examples/GettingStarted/Integer/FSharp/obj
25 | /Examples/GettingStarted/Integer/FSharp/bin/Debug/netcoreapp2.2
26 |
--------------------------------------------------------------------------------
/ArrayFire.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29020.237
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{45CBAB24-008E-4178-A16A-9FBBE040CDBE}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelloWorld", "HelloWorld", "{3C7B8845-1E14-4C71-BBFE-979743D577F7}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Unified", "Unified", "{0292AF78-CBCD-4005-9A62-3399F43F22BE}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld (CSharp)", "Examples\HelloWorld\CSharp\HelloWorld (CSharp).csproj", "{62C9C9D5-871D-4A53-9823-677141BFB66D}"
13 | EndProject
14 | Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "HelloWorld (FSharp)", "Examples\HelloWorld\FSharp\HelloWorld (FSharp).fsproj", "{40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Unified (CSharp)", "Examples\Unified\CSharp\Unified (CSharp).csproj", "{A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}"
17 | EndProject
18 | Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Unified (FSharp)", "Examples\Unified\FSharp\Unified (FSharp).fsproj", "{E1B97271-6364-4D9E-972A-A65156674BF4}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArrayFire", "src\Wrapper\ArrayFire.csproj", "{4F082D5B-2AED-461E-8288-66BCAE3E20D9}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArrayFire.UnitTest", "test\ArrayFire.UnitTest\ArrayFire.UnitTest.csproj", "{E47D6CCA-1397-4FD4-997A-A8520F74C367}"
23 | EndProject
24 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AutoGenTool", "AutoGenTool\AutoGenTool.fsproj", "{C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}"
25 | 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
30 | Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Integer (FSharp)", "Examples\GettingStarted\Integer\FSharp\Integer (FSharp).fsproj", "{751A6367-32AF-479A-8221-5DB0BB7C000B}"
31 | EndProject
32 | Global
33 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
34 | Debug|Any CPU = Debug|Any CPU
35 | Debug|x64 = Debug|x64
36 | Release|Any CPU = Release|Any CPU
37 | Release|x64 = Release|x64
38 | EndGlobalSection
39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
40 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Debug|x64.ActiveCfg = Debug|Any CPU
43 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Debug|x64.Build.0 = Debug|Any CPU
44 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Release|x64.ActiveCfg = Release|Any CPU
47 | {62C9C9D5-871D-4A53-9823-677141BFB66D}.Release|x64.Build.0 = Release|Any CPU
48 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Debug|x64.ActiveCfg = Debug|Any CPU
51 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Debug|x64.Build.0 = Debug|Any CPU
52 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Release|x64.ActiveCfg = Release|Any CPU
55 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7}.Release|x64.Build.0 = Release|Any CPU
56 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Debug|x64.ActiveCfg = Debug|Any CPU
59 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Debug|x64.Build.0 = Debug|Any CPU
60 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Release|x64.ActiveCfg = Release|Any CPU
63 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3}.Release|x64.Build.0 = Release|Any CPU
64 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Debug|x64.ActiveCfg = Debug|Any CPU
67 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Debug|x64.Build.0 = Debug|Any CPU
68 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
69 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Release|Any CPU.Build.0 = Release|Any CPU
70 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Release|x64.ActiveCfg = Release|Any CPU
71 | {E1B97271-6364-4D9E-972A-A65156674BF4}.Release|x64.Build.0 = Release|Any CPU
72 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
74 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Debug|x64.ActiveCfg = Debug|Any CPU
75 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Debug|x64.Build.0 = Debug|Any CPU
76 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
77 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Release|Any CPU.Build.0 = Release|Any CPU
78 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Release|x64.ActiveCfg = Release|Any CPU
79 | {4F082D5B-2AED-461E-8288-66BCAE3E20D9}.Release|x64.Build.0 = Release|Any CPU
80 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
81 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Debug|Any CPU.Build.0 = Debug|Any CPU
82 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Debug|x64.ActiveCfg = Debug|Any CPU
83 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Debug|x64.Build.0 = Debug|Any CPU
84 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Release|Any CPU.ActiveCfg = Release|Any CPU
85 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Release|Any CPU.Build.0 = Release|Any CPU
86 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Release|x64.ActiveCfg = Release|Any CPU
87 | {E47D6CCA-1397-4FD4-997A-A8520F74C367}.Release|x64.Build.0 = Release|Any CPU
88 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Debug|Any CPU.ActiveCfg = Debug|x64
89 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Debug|x64.ActiveCfg = Debug|x64
90 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Debug|x64.Build.0 = Debug|x64
91 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|Any CPU.ActiveCfg = Release|x64
92 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|x64.ActiveCfg = Release|x64
93 | {C2338C5E-AEC9-4AA0-BEE1-A75EB26A172D}.Release|x64.Build.0 = Release|x64
94 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
96 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|x64.ActiveCfg = Debug|Any CPU
97 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Debug|x64.Build.0 = Debug|Any CPU
98 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
99 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Release|Any CPU.Build.0 = Release|Any CPU
100 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Release|x64.ActiveCfg = Release|Any CPU
101 | {CF93F274-DA85-4845-81DB-C719B95665DA}.Release|x64.Build.0 = Release|Any CPU
102 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Debug|Any CPU.Build.0 = Debug|Any CPU
104 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Debug|x64.ActiveCfg = Debug|Any CPU
105 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Debug|x64.Build.0 = Debug|Any CPU
106 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Release|Any CPU.ActiveCfg = Release|Any CPU
107 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Release|Any CPU.Build.0 = Release|Any CPU
108 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Release|x64.ActiveCfg = Release|Any CPU
109 | {751A6367-32AF-479A-8221-5DB0BB7C000B}.Release|x64.Build.0 = Release|Any CPU
110 | EndGlobalSection
111 | GlobalSection(SolutionProperties) = preSolution
112 | HideSolutionNode = FALSE
113 | EndGlobalSection
114 | GlobalSection(NestedProjects) = preSolution
115 | {3C7B8845-1E14-4C71-BBFE-979743D577F7} = {45CBAB24-008E-4178-A16A-9FBBE040CDBE}
116 | {0292AF78-CBCD-4005-9A62-3399F43F22BE} = {45CBAB24-008E-4178-A16A-9FBBE040CDBE}
117 | {62C9C9D5-871D-4A53-9823-677141BFB66D} = {3C7B8845-1E14-4C71-BBFE-979743D577F7}
118 | {40EB7006-A2B7-4BE7-A0C3-84E196DEDCA7} = {3C7B8845-1E14-4C71-BBFE-979743D577F7}
119 | {A3AEAA02-2E4D-4F7D-AF91-E85F455A71A3} = {0292AF78-CBCD-4005-9A62-3399F43F22BE}
120 | {E1B97271-6364-4D9E-972A-A65156674BF4} = {0292AF78-CBCD-4005-9A62-3399F43F22BE}
121 | {FAAB6802-F422-4F69-B543-5A68A81245FD} = {45CBAB24-008E-4178-A16A-9FBBE040CDBE}
122 | {CF93F274-DA85-4845-81DB-C719B95665DA} = {FAAB6802-F422-4F69-B543-5A68A81245FD}
123 | {751A6367-32AF-479A-8221-5DB0BB7C000B} = {FAAB6802-F422-4F69-B543-5A68A81245FD}
124 | EndGlobalSection
125 | GlobalSection(ExtensibilityGlobals) = postSolution
126 | SolutionGuid = {E3A0DE14-88D3-4AEC-B6F6-97A6CA052C53}
127 | EndGlobalSection
128 | EndGlobal
129 |
--------------------------------------------------------------------------------
/AutoGenTool/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AutoGenTool/AutoGenTool.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 2.0
6 | c2338c5e-aec9-4aa0-bee1-a75eb26a172d
7 | Exe
8 | AutoGenTool
9 | AutoGenTool
10 | v4.7.2
11 | true
12 | 4.4.3.0
13 | AutoGenTool
14 |
15 |
16 |
17 | 11
18 |
19 |
20 | true
21 | full
22 | false
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | 3
27 |
28 |
29 | true
30 | x64
31 |
32 |
33 | pdbonly
34 | true
35 | true
36 | bin\Release\
37 | TRACE
38 | 3
39 |
40 |
41 | true
42 | x64
43 |
44 |
45 |
46 |
47 | $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets
48 |
49 |
50 |
51 |
52 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | Always
66 |
67 |
68 |
69 |
70 |
71 | packages\FSharp.Core.4.6.2\lib\net45\FSharp.Core.dll
72 |
73 |
74 |
75 | True
76 |
77 |
78 |
79 |
80 |
81 |
88 |
--------------------------------------------------------------------------------
/AutoGenTool/CodeWriter.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | namespace AutoGenTool
33 |
34 | open System
35 | open System.IO
36 |
37 | type CodeWriter(file) =
38 | let sw = new StreamWriter(file, false)
39 | do sw.WriteLine "// This file was automatically generated using the AutoGenTool project"
40 | do sw.WriteLine "// If possible, edit the tool instead of editing this file directly"
41 | do sw.WriteLine ()
42 | do sw.WriteLine "using System;"
43 | do sw.WriteLine "using System.Text;"
44 | do sw.WriteLine "using System.Numerics;"
45 | do sw.WriteLine "using System.Security;"
46 | do sw.WriteLine "using System.Runtime.InteropServices;"
47 | do sw.WriteLine ()
48 | do sw.WriteLine "namespace ArrayFire.Interop"
49 | do sw.WriteLine "{"
50 | let mutable tabs = "\t";
51 |
52 | member private x.println (str:String) =
53 | if str.StartsWith "}" && tabs.Length > 0 then tabs <- tabs.Substring 1
54 | if str.Length > 0 then sw.WriteLine (tabs + str) else sw.WriteLine()
55 | if str.EndsWith "{" then tabs <- tabs + "\t";
56 |
57 | static member (<=-)(cw:CodeWriter, txt:string) = cw.println txt
58 |
59 | member x.Dispose() = x.println "}"; sw.Dispose()
60 |
61 | interface IDisposable with member x.Dispose() = x.Dispose()
62 |
--------------------------------------------------------------------------------
/AutoGenTool/Config.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | namespace AutoGenTool
33 |
34 | module Config =
35 |
36 | // possible values for the arrayfire include/af folder (the first one that exists gets used)
37 | let INCLUDE_DIR = [
38 | @"C:\Program Files\ArrayFire\v3\include\af"; // windows
39 | "/usr/local/include/af" // osx
40 | ]
41 |
42 | // include (*.h) files not (yet) supported
43 | let SKIP_INCLUDES = ["compatible"; "cuda"; "features"; "graphics"; "image"; "opencl"; "vision" ]
44 |
45 | // path to the ArrayFire library source code (relative to this project's bin/Debug or bin/Release folders)
46 | let OUTPUT_DIR = "../../../src/Wrapper"
47 |
--------------------------------------------------------------------------------
/AutoGenTool/ForInDo.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | namespace AutoGenTool
33 |
34 | open System
35 | open System.IO
36 | open System.Text
37 | open System.Collections.Generic
38 | open System.Text.RegularExpressions
39 |
40 | open Config
41 | open Utils
42 |
43 | // expand the for-in-do loops in the /ArrayFire/*.cs files
44 | module ForInDo =
45 |
46 | let rec private processFile (lines:string list) (changed,result) =
47 | match lines with
48 | | [] -> (changed,result |> List.rev)
49 | | line::rest ->
50 | if Regex.IsMatch(line, "^\s*#if\s*_") then
51 | processFor rest (changed, line::result)
52 | else processFile rest (changed, line::result)
53 |
54 | and private processFor lines (changed,result) =
55 | match lines with
56 | [] -> failwith "syntax error"
57 | | line::rest ->
58 | let mat = Regex.Match(line, "^\s*for\s+([^\s]+)\s+in\s*$")
59 | if mat.Success then
60 | let patt = mat.Groups.[1].Value
61 | processIn rest (line::result) patt []
62 | else processFile rest (changed, line::result)
63 |
64 | and private processIn lines result patt items =
65 | match lines with
66 | [] -> failwith "syntax error"
67 | | line::rest ->
68 | if Regex.IsMatch(line, "^\s*do\s*$") then
69 | let mats = [ for mat in Regex.Matches(items |> List.rev |> String.concat " ", patt) -> mat.Value ] |> List.rev
70 | processDo rest (line::result) patt mats []
71 | else processIn rest (line::result) patt (line::items)
72 |
73 | and private processDo lines result patt mats repls =
74 | match lines with
75 | [] -> failwith "syntax error"
76 | | line::rest ->
77 | if Regex.IsMatch(line, "^\s*#else") then
78 | let addNewLine = function [one] -> [one] | many -> ""::many
79 | let cutEmptyHead = function ""::rest -> rest | other -> other
80 | let replaces = repls |> addNewLine |> listCartesian mats |> List.map (fun (m,r) -> replaceLU patt r m)
81 | processEnd rest ((cutEmptyHead replaces) @ (line::result))
82 | else processDo rest (line::result) patt mats (line::repls)
83 |
84 | and private processEnd lines result =
85 | match lines with
86 | | [] -> failwith "syntax error"
87 | | line::rest ->
88 | if Regex.IsMatch(line, "^\s*#endif") then
89 | processFile rest (true, line::result)
90 | else processEnd rest result // intentionally dont add it to the results
91 |
92 | let expand() =
93 |
94 | let files = Directory.GetFiles(OUTPUT_DIR, "*.cs")
95 | for file in files do
96 | try
97 | let lines = loadLinesFromFile file
98 | let changed, results = processFile lines (false,[])
99 | if changed then
100 | results |> saveLinesToFile file
101 | Console.WriteLine (file + " ... [ok]")
102 | with
103 | | _ -> Console.WriteLine ("Error processing " + file)
104 |
105 |
--------------------------------------------------------------------------------
/AutoGenTool/Interop.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | namespace AutoGenTool
33 |
34 | open System
35 | open System.IO
36 | open System.Text
37 | open System.Collections.Generic
38 | open System.Text.RegularExpressions
39 |
40 | open Config
41 | open Utils
42 |
43 | // generate the /ArrayFire/Interop/*.cs classes
44 | module Interop =
45 |
46 | let private fixTypes =
47 | replaceWord Anywhere "unsigned" "uint" >>
48 | replaceWord Anywhere "intl" "long" >>
49 | replaceWord Anywhere "uintl" "ulong"
50 |
51 | let private transformParameter (param:string) =
52 | let ismatch pat = Regex.IsMatch(param, "^" + pat + "$")
53 | match [ // long-typedef inputs:
54 | "(?:const\s+)?af_window\s+(\w+)", "long window_$1";
55 | "(?:const\s+)?dim_t\s+(\w+)", "long dim_$1";
56 | // pointer-sized inputs:
57 | "(?:const\s+)?size_t\s+(\w+)", "UIntPtr size_$1";
58 | "(?:const\s+)?af_array\s+(\w+)", "IntPtr array_$1";
59 | // array inputs:
60 | "const\s+af_array\s*\*\s*(?:const\s+)?(\w+)", "[In] IntPtr[] array_$1";
61 | "const\s+af_seq\s*\*\s*(?:const\s+)?(\w+)", "[In] af_seq[] $1";
62 | "const\s+dim_t\s*\*\s*(?:const\s+)?(\w+)", "[In] long[] dim_$1";
63 | "const\s+void\s*\*\s*(?:const\s+)?(\w+)", "[In] T[_] $1"
64 | "const\s+char\s*\*\s*(?:const\s+)?(\w+)", "string $1";
65 | // trivial-case inputs:
66 | "(?:const\s+)?(\w+)\s+(\w+)", "$1 $2";
67 | // long-typedef outputs:
68 | "dim_t\s*\*\s*(\w+)", "out long dim_$1";
69 | "af_window\s*\*\s*(\w+)", "out long window_$1";
70 | // pointer-sized outputs:
71 | "af_array\s*\*\s*(\w+)", "out IntPtr array_$1";
72 | "size_t\s*\*\s*(\w+)", "out UIntPtr size_$1";
73 | // array outputs:
74 | "void\s*\*\s*(\w+)", "[Out] T[_] $1";
75 | "char\s*\*\s*(\w+)", "[Out] StringBuilder $1";
76 | // trivial-case outputs:
77 | "(\w+)\s*\*\s*(\w+)", "out $1 $2";
78 | ] |> List.tryFind (fst >> ismatch) with
79 | | Some (pat, rep) ->
80 | Regex.Replace(param, pat, rep)
81 | |> replaceWord LastWord "in" "input"
82 | |> replaceWord LastWord "out" "output"
83 | | None -> "???" + param + "???"
84 |
85 | let private finalFixes api str =
86 | if api = "af_assign_seq" then replaceWord FirstWord "out" "ref" str
87 | else if str.Contains("af_index_t") && not (str.Contains "???") then replaceWord Anywhere "af_index_t" "???af_index_t???" str
88 | else str
89 |
90 | let private getFileMatches (file:string) =
91 | let matches =
92 | use sr = new StreamReader(file)
93 | Regex.Matches(sr.ReadToEnd(), "AFAPI\s+af_err\s+(\w+)\s*\(\s*(?:([\w\s\d\*]+)\s*[,)]\s*)*")
94 | seq {
95 | for mat in matches do
96 | let apiname = mat.Groups.[1].Value
97 | let parcaps = mat.Groups.[2].Captures
98 | yield apiname, [ for cap in parcaps -> cap.Value.Trim() |> fixTypes |> transformParameter |> finalFixes apiname ] |> String.concat ", "
99 | } |> Seq.toList // lazy -> eager (release regex/match resources)
100 |
101 | let private getEnums (file:string) =
102 | let matches =
103 | use sr = new StreamReader(file)
104 | Regex.Matches(sr.ReadToEnd(), "typedef\s+enum\s{([^}]+)}\s+(\w+)")
105 | seq {
106 | for mat in matches do
107 | let fixline (line:string) =
108 | let trim = line.Trim()
109 | if trim.StartsWith "#" then "// " + trim else trim
110 | let vals = mat.Groups.[1].Value.Trim().Split('\n') |> Array.map fixline
111 | let name = mat.Groups.[2].Value
112 | yield name, vals
113 | } |> Seq.toList // lazy -> eager (release regex/match resources)
114 |
115 | let generate() =
116 | let root = INCLUDE_DIR |> List.find Directory.Exists
117 |
118 | do
119 | use cw = new CodeWriter(OUTPUT_DIR + "/Interop/enums.cs")
120 | let mutable is1st = true
121 | Console.WriteLine "Enumerations:"
122 | for enum in getEnums (root + "/defines.h") do
123 | if is1st then is1st <- false else cw <=- ""
124 | cw <=- "public enum " + (fst enum)
125 | cw <=- "{"
126 | for value in snd enum do cw <=- value
127 | cw <=- "}"
128 | Console.WriteLine (" + " + (fst enum))
129 | Console.WriteLine()
130 |
131 | let namelower file = Path.GetFileNameWithoutExtension(file).ToLower()
132 | let upperFirst (name:string) = name.Substring(0,1).ToUpper() + name.Substring(1)
133 |
134 | let files =
135 | let find lst elem = List.exists ((=) elem) lst
136 | Directory.GetFiles(root, "*.h") |> Array.toList |> List.filter (namelower >> find SKIP_INCLUDES >> not)
137 |
138 | for file in files do
139 | let matches = getFileMatches file
140 | if List.isEmpty matches |> not then
141 | let name = "AF" + (file |> namelower |> upperFirst)
142 | Console.WriteLine ("class " + name + ":")
143 | use cw = new CodeWriter(OUTPUT_DIR + "/Interop/" + name + ".cs")
144 | cw <=- "[SuppressUnmanagedCodeSecurity]"
145 | cw <=- "public static class " + name
146 | cw <=- "{"
147 | let mutable is1st = true
148 | for api, pars in matches do
149 | let unsupported = pars.Contains("???")
150 | let versions =
151 | if not unsupported && pars.Contains("T[_]") then
152 | [ "bool"; "Complex"; "float"; "double"; "int"; "long"; "uint"; "ulong"; "byte"; "short"; "ushort" ]
153 | |> listCartesian [ "[]"; "[,]"; "[,,]"; "[,,,]" ]
154 | |> List.map (fun (x,y) -> pars.Replace("T[_]", y + x))
155 | else [ pars ]
156 | for vpars in versions do
157 | if is1st then is1st <- false else cw <=- ""
158 | if unsupported then cw <=- "/* not yet supported:"
159 | else Console.WriteLine (" + " + api)
160 | cw <=- "[DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]"
161 | cw <=- "public static extern af_err " + api + "(" + vpars + ");" + (if unsupported then " */" else "")
162 | cw <=- "}"
163 | Console.WriteLine()
164 |
165 |
--------------------------------------------------------------------------------
/AutoGenTool/Program.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | open System
33 | open AutoGenTool
34 |
35 | []
36 | let main argv =
37 |
38 | // generate the /ArrayFire/Interop/*.cs classes
39 | Interop.generate()
40 |
41 | // expand the for-in-do loops in the /ArrayFire/*.cs files
42 | ForInDo.expand()
43 |
44 | 0 // return an integer exit code
45 |
--------------------------------------------------------------------------------
/AutoGenTool/Utils.fs:
--------------------------------------------------------------------------------
1 | (*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *)
31 |
32 | namespace AutoGenTool
33 |
34 | open System
35 | open System.IO
36 | open System.Text
37 | open System.Text.RegularExpressions
38 |
39 | module Utils =
40 |
41 | // performs the cartesian product of two lists
42 | let listCartesian xlist ylist = xlist |> List.collect (fun x -> ylist |> List.map (fun y -> x,y))
43 |
44 | // a version of Regex.Replace that supports $Ux and $Lx as the uppercase and lowercase versions of $x where x is the group number (e.g. $U1 is the same as $1 but in lowercase)
45 | let replaceLU pattern replacement input =
46 | let mev (mat:Match) =
47 | let mutable res = mat.Result replacement
48 | for i = 1 to mat.Groups.Count - 1 do
49 | res <- Regex.Replace(res, "\$U" + i.ToString(), mat.Groups.[i].Value.ToUpper())
50 | res <- Regex.Replace(res, "\$L" + i.ToString(), mat.Groups.[i].Value.ToLower())
51 | res
52 | Regex.Replace(input, pattern, mev)
53 |
54 | // loads a file as a list of lines
55 | let loadLinesFromFile (file:string) =
56 | use sr = new StreamReader(file)
57 | let line = sr.ReadLine() |> ref
58 | seq {
59 | while !line <> Unchecked.defaultof do
60 | yield !line
61 | line := sr.ReadLine()
62 | } |> Seq.toList // evaluate sequence
63 |
64 | // saves a list of lines to a file
65 | let saveLinesToFile (file:string) (lines:string list) =
66 | use sw = new StreamWriter(file, false)
67 | for line in lines do line.TrimEnd() |> sw.WriteLine
68 |
69 | type WordLocation = Anywhere | FirstWord | LastWord
70 |
71 | let replaceWord loc oldword (newword:string) input =
72 | let pat =
73 | match loc with
74 | | Anywhere -> @"\b" + oldword + @"\b"
75 | | FirstWord -> "^" + oldword + @"\b"
76 | | LastWord -> @"\b" + oldword + "$"
77 | Regex.Replace(input, pat, newword)
78 |
--------------------------------------------------------------------------------
/AutoGenTool/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Examples/GettingStarted/Integer/CSharp/Integer (CSharp).csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | GettingStarted__Integer__CSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Examples/GettingStarted/Integer/CSharp/Program.cs:
--------------------------------------------------------------------------------
1 | using ArrayFire;
2 | using System;
3 |
4 | namespace GettingStarted__Integer__CSharp_
5 | {
6 | ///
7 | /// port from getting_started\integer.cpp
8 | ///
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 | }
71 |
--------------------------------------------------------------------------------
/Examples/GettingStarted/Integer/FSharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Examples/GettingStarted/Integer/FSharp/Integer (FSharp).fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | HelloWorld__FSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Examples/GettingStarted/Integer/FSharp/Program.fs:
--------------------------------------------------------------------------------
1 | // Learn more about F# at http://fsharp.org
2 | // See the 'F# Tutorial' project for more help.
3 |
4 | open System
5 | open System.Numerics
6 | open System.Collections.Generic
7 | open ArrayFire
8 |
9 | []
10 | let main argv =
11 |
12 | Device.SetBackend(Backend.DEFAULT)
13 | Device.PrintInfo()
14 | printfn "\n=== ArrayFire signed(s32) / unsigned(u32) Integer Example ===\n"
15 |
16 | let h_A = array2D[ [ 1; 2; 4 ]; [ -1; 2; 0 ]; [ 4; 2; 3 ] ]
17 | let h_B = array2D[ [ 2; 3; -5 ]; [ 6; 0; 10 ]; [ -12; 0; 1 ] ]
18 | //printfn "Array 2D is %A" h_A.GetType()
19 | let A = Data.CreateArray(h_A)
20 | let B = Data.CreateArray(h_B)
21 | printfn "--\nSub-refencing and Sub-assignment\n"
22 |
23 | Util.Print(A, "A");
24 | Util.Print(A.Rows(0, 0), "A's first row")
25 | Util.Print(A.Cols(0, 0), "A's first column")
26 | A.[Util.Seq(0, 0), Util.Seq(0, 0)] <- Data.CreateArray([|100|])
27 | A.[Util.Seq(1, 1), Util.Seq(2, 2)] <- Data.CreateArray([|100|])
28 | Util.Print(A, "A")
29 | Util.Print(B, "B")
30 | A.[Util.Seq(1, 1), Util.Span] <- B.[Util.Seq(2, 2), Util.Span]
31 | Util.Print(A, "A")
32 | Util.Print(B, "B")
33 | let C = A + B
34 | printf "--Bit-wise operations\n"
35 | Util.Print(A &&& B, "A &&& B")
36 | Util.Print(A ||| B, "A ||| B")
37 | Util.Print(A ^^^ B, "A ^^^ B")
38 |
39 | printfn "\n--Transpose\n"
40 | Util.Print(A, "A")
41 | Util.Print(Matrix.Transpose(A, false), "Matrix.Transpose(A)")
42 |
43 | printfn "\n--Sum along columns\n"
44 | Util.Print(A, "A")
45 | Util.Print(Algorithm.Sum(A), "Algorithm.Sum(A)")
46 |
47 | printfn "\n--Product along columns\n"
48 | Util.Print(A, "A")
49 | Util.Print(Algorithm.Product(A), "Algorithm.Product(A)")
50 |
51 | printfn "\n--Minimum along columns\n"
52 | Util.Print(A, "A")
53 | Util.Print(Algorithm.Min(A), "Algorithm.Min(A)")
54 |
55 | printfn "\n--Maximum along columns\n"
56 | Util.Print(A, "A")
57 | Util.Print(Algorithm.Max(A), "Algorithm.Max(A)")
58 |
59 | printfn "\n--Minimum along columns with index\n"
60 | Util.Print(A, "A")
61 |
62 | let mutable idx = null
63 | let outArray = Algorithm.Min(A, &idx)
64 | Util.Print(outArray, "output")
65 | Util.Print(idx, "indexes")
66 |
67 | 0 // return an integer exit code
68 |
--------------------------------------------------------------------------------
/Examples/HelloWorld/CSharp/HelloWorld (CSharp).csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | HelloWorld__CSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Examples/HelloWorld/CSharp/Program.cs:
--------------------------------------------------------------------------------
1 | using ArrayFire;
2 | using System;
3 |
4 | namespace HelloWorld__CSharp_
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | Device.SetBackend(Backend.DEFAULT);
11 | Device.PrintInfo();
12 |
13 | var arr1 = Data.RandNormal(3, 3);
14 | var arr2 = Data.RandNormal(3, 3);
15 | var arr3 = arr1 + arr2;
16 | var arr4 = Matrix.Multiply(arr1, arr2);
17 | var arr5 = Arith.Sin(arr1) + Arith.Cos(arr2);
18 | Util.Print(arr1, "arr1");
19 | Util.Print(arr2, "arr2");
20 | Util.Print(arr3, "arr1 + arr2");
21 | Util.Print(arr4, "arr1 * arr2 (matrix product)");
22 | Util.Print(arr5, "Sin(arr1) + Cos(arr2)");
23 |
24 | // new! indexing:
25 | Util.Print(arr1[Util.Span, 0], "arr1's first column");
26 | Util.Print(arr1.Cols(0, 0), "arr1's first row (again)");
27 | var corner = arr1[Util.Seq(0, 1), Util.Seq(0, 1)];
28 | Util.Print(corner, "arr1's top-left 2x2 corner");
29 | arr2[Util.Seq(1, 2), Util.Seq(1, 2)] = corner;
30 | Util.Print(arr2, "arr2 with botton-right 2x2 corner ovewritten with the previous result");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Examples/HelloWorld/FSharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Examples/HelloWorld/FSharp/HelloWorld (FSharp).fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | HelloWorld__FSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Examples/HelloWorld/FSharp/Program.fs:
--------------------------------------------------------------------------------
1 | // Learn more about F# at http://fsharp.org
2 | // See the 'F# Tutorial' project for more help.
3 |
4 | open System
5 | open System.Numerics
6 | open System.Collections.Generic
7 | open ArrayFire
8 |
9 | []
10 | let main argv =
11 |
12 | Device.SetBackend(Backend.DEFAULT)
13 | Device.PrintInfo()
14 |
15 | let arr1 = Data.RandNormal(3, 3)
16 | let arr2 = Data.RandNormal(3, 3)
17 | let arr3 = arr1 + arr2
18 | let arr4 = Matrix.Multiply(arr1, arr2)
19 | let arr5 = (sin arr1) + (cos arr2)
20 | Util.Print(arr1, "arr1")
21 | Util.Print(arr2, "arr2")
22 | Util.Print(arr3, "arr1 + arr2")
23 | Util.Print(arr4, "arr1 * arr2 (matrix product)")
24 | Util.Print(arr5, "sin(arr1) + cos(arr2)");
25 |
26 | // new! indexing:
27 | Util.Print(arr1.[Util.Span, Util.Seq(0,0)], "arr1's first column");
28 | Util.Print(arr1.Cols(0, 0), "arr1's first row (again)");
29 | let corner = arr1.[Util.Seq(0, 1), Util.Seq(0, 1)]
30 | Util.Print(corner, "arr1's top-left 2x2 corner")
31 | arr2.[Util.Seq(1, 2), Util.Seq(1, 2)] <- corner
32 | Util.Print(arr2, "arr2 with botton-right 2x2 corner ovewritten with the previous result");
33 |
34 | 0 // return an integer exit code
35 |
--------------------------------------------------------------------------------
/Examples/Unified/CSharp/Program.cs:
--------------------------------------------------------------------------------
1 | using ArrayFire;
2 | using System;
3 |
4 | namespace Unified__CSharp_
5 | {
6 | class Program
7 | {
8 | static void TestBackend()
9 | {
10 | Device.PrintInfo();
11 | Console.WriteLine(Device.BackendCount);
12 | var arr1 = Data.RandNormal(3, 3);
13 | var arr2 = Data.RandNormal(3, 3);
14 | var arr3 = arr1 + arr2;
15 | var arr4 = Matrix.Multiply(arr1, arr2);
16 | var arr5 = Arith.Sin(arr1) + Arith.Cos(arr2);
17 | Util.Print(arr1, "arr1");
18 | Util.Print(arr2, "arr2");
19 | Util.Print(arr3, "arr1 + arr2");
20 | Util.Print(arr4, "arr1 * arr2 (matrix product)");
21 | Util.Print(arr5, "Sin(arr1) + Cos(arr2)");
22 | }
23 |
24 | static void Main(string[] args)
25 | {
26 | try
27 | {
28 | Console.WriteLine("Testing CPU Backend");
29 | Device.SetBackend(Backend.CPU);
30 | TestBackend();
31 | }
32 | catch (Exception ex) { Console.WriteLine(ex.ToString()); }
33 | try
34 | {
35 | Console.WriteLine("Testing CUDA Backend");
36 | Device.SetBackend(Backend.CUDA);
37 | TestBackend();
38 | }
39 | catch (Exception ex) { Console.WriteLine(ex.ToString()); }
40 | try
41 | {
42 | Console.WriteLine("Testing OPENCL Backend");
43 | Device.SetBackend(Backend.OPENCL);
44 | TestBackend();
45 | }
46 | catch (Exception ex) { Console.WriteLine(ex.ToString()); }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Examples/Unified/CSharp/Unified (CSharp).csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | Unified__CSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Examples/Unified/FSharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Examples/Unified/FSharp/Program.fs:
--------------------------------------------------------------------------------
1 | // Learn more about F# at http://fsharp.org
2 | // See the 'F# Tutorial' project for more help.
3 |
4 | open System
5 | open System.Numerics
6 | open System.Collections.Generic
7 | open ArrayFire
8 |
9 | []
10 | let main argv =
11 |
12 | let testBackend() =
13 | Device.PrintInfo()
14 | let arr1 = Data.RandNormal(3, 3)
15 | let arr2 = Data.RandNormal(3, 3)
16 | let arr3 = arr1 + arr2
17 | let arr4 = Matrix.Multiply(arr1, arr2)
18 | let arr5 = (sin arr1) + (cos arr2)
19 | Util.Print(arr1, "arr1")
20 | Util.Print(arr2, "arr2")
21 | Util.Print(arr3, "arr1 + arr2")
22 | Util.Print(arr4, "arr1 * arr2 (matrix product)")
23 | Util.Print(arr5, "sin(arr1) + cos(arr2)");
24 |
25 | try
26 | printfn "Testing CPU Backend"
27 | Device.SetBackend Backend.CPU
28 | testBackend()
29 | with
30 | | ex -> printfn "%s" (ex.ToString())
31 |
32 | try
33 | printfn "Testing CUDA Backend"
34 | Device.SetBackend Backend.CUDA
35 | testBackend()
36 | with
37 | | ex -> printfn "%s" (ex.ToString())
38 |
39 | try
40 | printfn "Testing OPENCL Backend"
41 | Device.SetBackend Backend.OPENCL
42 | testBackend()
43 | with
44 | | ex -> printfn "%s" (ex.ToString())
45 |
46 | 0 // return an integer exit code
47 |
--------------------------------------------------------------------------------
/Examples/Unified/FSharp/Unified (FSharp).fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 | Unified__FSharp_
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, ArrayFire
2 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | * Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | * Neither the name of arrayfire_dotnet nor the names of its
16 | contributors may be used to endorse or promote products derived from
17 | this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ArrayFire Binding in .NET Standard
2 |
3 |
4 |
5 | [](https://www.nuget.org/packages/ArrayFire)
6 | [](https://arrayfirenet.readthedocs.io/en/latest/?badge=latest)
7 | [](https://ci.appveyor.com/project/Haiping-Chen/arrayfire-dotnet)
8 |
9 | [ArrayFire](https://github.com/arrayfire/arrayfire) is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices. This project provides .NET bindings for the ArrayFire library. It conforms to .NET Standard 2.x, so it can be used from any .net Language such as C# or F#
10 |
11 | ### Prerequisites
12 |
13 | - The latest version of ArrayFire. You can get ArrayFire using one of the following:
14 | - [Download binary installers](http://www.arrayfire.com/download)
15 | - [Build from source](https://github.com/arrayfire/arrayfire)
16 |
17 | - .NET Core 2.2
18 |
19 | - [.NET Downloads](https://dotnet.microsoft.com/download)
20 |
21 | - Visual Studio 2017 or above.
22 |
23 | - [Download Visual Studio Community Free](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx)
24 |
25 |
26 |
27 |
28 | ### Contents
29 |
30 | - `Wrapper/`: Contains the C# source code for the .net ArrayFire wrapper library. This is the library that you need to reference from your project.
31 |
32 | - `AutoGenTool/`: Contains the F# source code for a tool that automatically generates part of the library code. Not meant to be used by consumers of the library.
33 |
34 | - `Examples/`: contains a few examples demonstrating the usage from both C# and F#
35 |
36 | ### Usage
37 |
38 | 1. Install from NuGet
39 |
40 | `PM> Install-Package ArrayFire`
41 |
42 | - Refer to the Examples folder.
43 |
44 | - Or run in command line
45 |
46 | `dotnet "HelloWorld (CSharp).dll"`
47 |
48 | Documentation
49 | ---------------
50 |
51 | - Refer [here](https://readthedocs.org/projects/arrayfirenet).
52 |
53 |
--------------------------------------------------------------------------------
/src/Wrapper/Algorithm.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | public static class Algorithm
41 | {
42 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
43 | public static Array Sum(Array arr, int dim = -1)
44 | {
45 | IntPtr ptr;
46 | Internal.VERIFY(AFAlgorithm.af_sum(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
47 | return new Array(ptr);
48 | }
49 |
50 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
51 | public static Array Sum(Array arr, int dim, double nanval)
52 | {
53 | IntPtr ptr;
54 | Internal.VERIFY(AFAlgorithm.af_sum_nan(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions), nanval));
55 | return new Array(ptr);
56 | }
57 |
58 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
59 | public static Array Product(Array arr, int dim = -1)
60 | {
61 | IntPtr ptr;
62 | Internal.VERIFY(AFAlgorithm.af_product(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
63 | return new Array(ptr);
64 | }
65 |
66 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
67 | public static Array Product(Array arr, int dim, double nanval)
68 | {
69 | IntPtr ptr;
70 | Internal.VERIFY(AFAlgorithm.af_product_nan(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions), nanval));
71 | return new Array(ptr);
72 | }
73 |
74 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
75 | public static Array Min(Array arr, int dim = -1)
76 | {
77 | IntPtr ptr;
78 | Internal.VERIFY(AFAlgorithm.af_min(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
79 | return new Array(ptr);
80 | }
81 |
82 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
83 | public static Array Max(Array arr, int dim = -1)
84 | {
85 | IntPtr ptr;
86 | Internal.VERIFY(AFAlgorithm.af_max(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
87 | return new Array(ptr);
88 | }
89 |
90 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
91 | public static Array AllTrue(Array arr, int dim = -1)
92 | {
93 | IntPtr ptr;
94 | Internal.VERIFY(AFAlgorithm.af_all_true(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
95 | return new Array(ptr);
96 | }
97 |
98 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
99 | public static Array AnyTrue(Array arr, int dim = -1)
100 | {
101 | IntPtr ptr;
102 | Internal.VERIFY(AFAlgorithm.af_any_true(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
103 | return new Array(ptr);
104 | }
105 |
106 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
107 | public static Array Count(Array arr, int dim = -1)
108 | {
109 | IntPtr ptr;
110 | Internal.VERIFY(AFAlgorithm.af_count(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
111 | return new Array(ptr);
112 | }
113 |
114 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
115 | public static Complex SumAll(Array arr) => SumAll(arr);
116 |
117 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
118 | public static returnType SumAll(Array arr)
119 | {
120 | double r, i;
121 | Internal.VERIFY(AFAlgorithm.af_sum_all(out r, out i, arr._ptr));
122 | if (typeof(returnType) == typeof(Complex))
123 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
124 | else
125 | return (returnType)Convert.ChangeType(r, typeof(returnType));
126 | }
127 |
128 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
129 | public static Complex SumAll(Array arr, double nanval) => SumAll(arr, nanval);
130 |
131 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
132 | public static returnType SumAll(Array arr, double nanval)
133 | {
134 | double r, i;
135 | Internal.VERIFY(AFAlgorithm.af_sum_nan_all(out r, out i, arr._ptr, nanval));
136 | if (typeof(returnType) == typeof(Complex))
137 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
138 | else
139 | return (returnType)Convert.ChangeType(r, typeof(returnType));
140 | }
141 |
142 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
143 | public static Complex ProductAll(Array arr) => ProductAll(arr);
144 |
145 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
146 | public static returnType ProductAll(Array arr)
147 | {
148 | double r, i;
149 | Internal.VERIFY(AFAlgorithm.af_product_all(out r, out i, arr._ptr));
150 | if (typeof(returnType) == typeof(Complex))
151 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
152 | else
153 | return (returnType)Convert.ChangeType(r, typeof(returnType));
154 | }
155 |
156 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
157 | public static Complex ProductAll(Array arr, double nanval) => ProductAll(arr, nanval);
158 |
159 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
160 | public static returnType ProductAll(Array arr, double nanval)
161 | {
162 | double r, i;
163 | Internal.VERIFY(AFAlgorithm.af_product_nan_all(out r, out i, arr._ptr, nanval));
164 | if (typeof(returnType) == typeof(Complex))
165 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
166 | else
167 | return (returnType)Convert.ChangeType(r, typeof(returnType));
168 | }
169 |
170 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
171 | public static Complex MinAll(Array arr) => MinAll(arr);
172 |
173 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
174 | public static returnType MinAll(Array arr)
175 | {
176 | double r, i;
177 | Internal.VERIFY(AFAlgorithm.af_min_all(out r, out i, arr._ptr));
178 | if (typeof(returnType) == typeof(Complex))
179 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
180 | else
181 | return (returnType)Convert.ChangeType(r, typeof(returnType));
182 | }
183 |
184 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
185 | public static Complex MaxAll(Array arr) => MaxAll(arr);
186 |
187 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
188 | public static returnType MaxAll(Array arr)
189 | {
190 | double r, i;
191 | Internal.VERIFY(AFAlgorithm.af_max_all(out r, out i, arr._ptr));
192 | if (typeof(returnType) == typeof(Complex))
193 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
194 | else
195 | return (returnType)Convert.ChangeType(r, typeof(returnType));
196 | }
197 |
198 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
199 | public static bool AllTrueAll(Array arr)
200 | {
201 | double r, i;
202 | Internal.VERIFY(AFAlgorithm.af_all_true_all(out r, out i, arr._ptr));
203 | if (r == 0)
204 | return false;
205 | else
206 | return true;
207 | }
208 |
209 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
210 | public static bool AnyTrueAll(Array arr)
211 | {
212 | double r, i;
213 | Internal.VERIFY(AFAlgorithm.af_any_true_all(out r, out i, arr._ptr));
214 | if (r == 0)
215 | return false;
216 | else
217 | return true;
218 | }
219 |
220 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
221 | public static long CountAll(Array arr)
222 | {
223 | double r, i;
224 | Internal.VERIFY(AFAlgorithm.af_count_all(out r, out i, arr._ptr));
225 | return (long)r;
226 | }
227 |
228 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
229 | public static Array Min(Array arr, out Array idx ,int dim = -1)
230 | {
231 | IntPtr outPtr;
232 | IntPtr idxPtr;
233 | Internal.VERIFY(AFAlgorithm.af_imin(out outPtr, out idxPtr, arr._ptr, getFNSD(dim, arr.Dimensions)));
234 | idx = new Array(idxPtr);
235 | return new Array(outPtr);
236 | }
237 |
238 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
239 | public static Array Max(Array arr, out Array idx, int dim = -1)
240 | {
241 | IntPtr outPtr;
242 | IntPtr idxPtr;
243 | Internal.VERIFY(AFAlgorithm.af_imax(out outPtr, out idxPtr, arr._ptr, getFNSD(dim, arr.Dimensions)));
244 | idx = new Array(idxPtr);
245 | return new Array(outPtr);
246 | }
247 |
248 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
249 | public static Complex MinAll(Array arr, out uint idx) => MinAll(arr, out idx);
250 |
251 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
252 | public static returnType MinAll(Array arr, out uint idx)
253 | {
254 | double r, i;
255 | Internal.VERIFY(AFAlgorithm.af_imin_all(out r, out i, out idx, arr._ptr));
256 | if (typeof(returnType) == typeof(Complex))
257 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
258 | else
259 | return (returnType)Convert.ChangeType(r, typeof(returnType));
260 | }
261 |
262 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
263 | public static Complex MaxAll(Array arr, out uint idx) => MaxAll(arr, out idx);
264 |
265 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
266 | public static returnType MaxAll(Array arr, out uint idx)
267 | {
268 | double r, i;
269 | Internal.VERIFY(AFAlgorithm.af_imax_all(out r, out i, out idx, arr._ptr));
270 | if (typeof(returnType) == typeof(Complex))
271 | return (returnType)Convert.ChangeType(new Complex(r, i), typeof(returnType));
272 | else
273 | return (returnType)Convert.ChangeType(r, typeof(returnType));
274 | }
275 |
276 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
277 | public static Array Accumulate(Array arr, int dim = -1)
278 | {
279 | IntPtr ptr;
280 | Internal.VERIFY(AFAlgorithm.af_accum(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions)));
281 | return new Array(ptr);
282 | }
283 |
284 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
285 | public static Array Scan(Array arr, int dim, af_binary_op op, bool inclusive_scan = true)
286 | {
287 | IntPtr ptr;
288 | Internal.VERIFY(AFAlgorithm.af_scan(out ptr, arr._ptr, getFNSD(dim, arr.Dimensions), op, inclusive_scan));
289 | return new Array(ptr);
290 | }
291 |
292 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
293 | public static Array ScanByKey(Array key, Array arr, int dim, af_binary_op op, bool inclusive_scan = true)
294 | {
295 | IntPtr ptr;
296 | Internal.VERIFY(AFAlgorithm.af_scan_by_key(out ptr, key._ptr, arr._ptr, getFNSD(dim, arr.Dimensions), op, inclusive_scan));
297 | return new Array(ptr);
298 | }
299 |
300 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
301 | public static Array Where(Array arr)
302 | {
303 | IntPtr ptr;
304 | Internal.VERIFY(AFAlgorithm.af_where(out ptr, arr._ptr));
305 | return new Array(ptr);
306 | }
307 |
308 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
309 | public static Array Diff1(Array arr, int dim = 0)
310 | {
311 | IntPtr ptr;
312 | Internal.VERIFY(AFAlgorithm.af_diff1(out ptr, arr._ptr, dim));
313 | return new Array(ptr);
314 | }
315 |
316 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
317 | public static Array Diff2(Array arr, int dim = 0)
318 | {
319 | IntPtr ptr;
320 | Internal.VERIFY(AFAlgorithm.af_diff2(out ptr, arr._ptr, dim));
321 | return new Array(ptr);
322 | }
323 |
324 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
325 | public static Array Sort(Array arr, uint dim = 0, bool isAscending = true)
326 | {
327 | IntPtr ptr;
328 | Internal.VERIFY(AFAlgorithm.af_sort(out ptr, arr._ptr, dim, isAscending));
329 | return new Array(ptr);
330 | }
331 |
332 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
333 | public static Array Sort(Array arr, out Array indices, uint dim = 0, bool isAscending = true)
334 | {
335 | IntPtr outPtr, indPtr;
336 | Internal.VERIFY(AFAlgorithm.af_sort_index(out outPtr, out indPtr , arr._ptr, dim, isAscending));
337 | indices = new Array(indPtr);
338 | return new Array(outPtr);
339 | }
340 |
341 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
342 | public static Array Sort(out Array outValues, Array keys, Array values, uint dim = 0, bool isAscending = true)
343 | {
344 | IntPtr outKeyPtr;
345 | IntPtr outValPtr;
346 | Internal.VERIFY(AFAlgorithm.af_sort_by_key(out outKeyPtr, out outValPtr, keys._ptr, values._ptr, dim, isAscending));
347 | outValues = new Array(outValPtr);
348 | return new Array(outKeyPtr);
349 | }
350 |
351 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
352 | public static Array SetUnique(Array arr, bool isSorted = false)
353 | {
354 | IntPtr ptr;
355 | Internal.VERIFY(AFAlgorithm.af_set_unique(out ptr, arr._ptr, isSorted));
356 | return new Array(ptr);
357 | }
358 |
359 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
360 | public static Array SetUnion(Array arr1, Array arr2, bool isUnique = false)
361 | {
362 | IntPtr ptr;
363 | Internal.VERIFY(AFAlgorithm.af_set_union(out ptr, arr1._ptr, arr2._ptr, isUnique));
364 | return new Array(ptr);
365 | }
366 |
367 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
368 | public static Array SetIntersect(Array arr1, Array arr2, bool isUnique = false)
369 | {
370 | IntPtr ptr;
371 | Internal.VERIFY(AFAlgorithm.af_set_intersect(out ptr, arr1._ptr, arr2._ptr, isUnique));
372 | return new Array(ptr);
373 | }
374 |
375 | /// Get the first non-zero dimension
376 | private static int getFNSD(int dim, int[] dims)
377 | {
378 | if (dim >= 0) return dim;
379 |
380 | for (int i = 0; i < 4; ++i)
381 | {
382 | if (dims[i] > 1)
383 | {
384 | return i;
385 | }
386 | }
387 | return 0;
388 | }
389 | }
390 | }
391 |
--------------------------------------------------------------------------------
/src/Wrapper/Arith.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | // we can't make Arith static because Array inherits from it (so the F# Core.Operators free functions work correctly)
41 | public /*static*/ class Arith
42 | {
43 | protected Arith() { }
44 |
45 | #region Mathematical Functions
46 | #if _
47 | for (\w+) in
48 | Sin Sinh Asin Asinh
49 | Cos Cosh Acos Acosh
50 | Tan Tanh Atan Atanh
51 | Exp Expm1 Log Log10 Log1p Log2 Erf Erfc
52 | Sqrt Pow2 Cbrt
53 | LGamma TGamma
54 | Abs Sigmoid Factorial
55 | Round Trunc Floor Ceil
56 | do
57 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
58 | public static Array $1(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_$L1(out ptr, arr._ptr)); return new Array(ptr); }
59 | #else
60 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
61 | public static Array Sin(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_sin(out ptr, arr._ptr)); return new Array(ptr); }
62 |
63 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
64 | public static Array Sinh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_sinh(out ptr, arr._ptr)); return new Array(ptr); }
65 |
66 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
67 | public static Array Asin(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_asin(out ptr, arr._ptr)); return new Array(ptr); }
68 |
69 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
70 | public static Array Asinh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_asinh(out ptr, arr._ptr)); return new Array(ptr); }
71 |
72 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
73 | public static Array Cos(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_cos(out ptr, arr._ptr)); return new Array(ptr); }
74 |
75 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
76 | public static Array Cosh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_cosh(out ptr, arr._ptr)); return new Array(ptr); }
77 |
78 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
79 | public static Array Acos(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_acos(out ptr, arr._ptr)); return new Array(ptr); }
80 |
81 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
82 | public static Array Acosh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_acosh(out ptr, arr._ptr)); return new Array(ptr); }
83 |
84 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
85 | public static Array Tan(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_tan(out ptr, arr._ptr)); return new Array(ptr); }
86 |
87 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
88 | public static Array Tanh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_tanh(out ptr, arr._ptr)); return new Array(ptr); }
89 |
90 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
91 | public static Array Atan(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_atan(out ptr, arr._ptr)); return new Array(ptr); }
92 |
93 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
94 | public static Array Atanh(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_atanh(out ptr, arr._ptr)); return new Array(ptr); }
95 |
96 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
97 | public static Array Exp(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_exp(out ptr, arr._ptr)); return new Array(ptr); }
98 |
99 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
100 | public static Array Expm1(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_expm1(out ptr, arr._ptr)); return new Array(ptr); }
101 |
102 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
103 | public static Array Log(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_log(out ptr, arr._ptr)); return new Array(ptr); }
104 |
105 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
106 | public static Array Log10(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_log10(out ptr, arr._ptr)); return new Array(ptr); }
107 |
108 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
109 | public static Array Log1p(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_log1p(out ptr, arr._ptr)); return new Array(ptr); }
110 |
111 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
112 | public static Array Log2(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_log2(out ptr, arr._ptr)); return new Array(ptr); }
113 |
114 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
115 | public static Array Erf(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_erf(out ptr, arr._ptr)); return new Array(ptr); }
116 |
117 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
118 | public static Array Erfc(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_erfc(out ptr, arr._ptr)); return new Array(ptr); }
119 |
120 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
121 | public static Array Sqrt(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_sqrt(out ptr, arr._ptr)); return new Array(ptr); }
122 |
123 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
124 | public static Array Pow2(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_pow2(out ptr, arr._ptr)); return new Array(ptr); }
125 |
126 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
127 | public static Array Cbrt(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_cbrt(out ptr, arr._ptr)); return new Array(ptr); }
128 |
129 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
130 | public static Array LGamma(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_lgamma(out ptr, arr._ptr)); return new Array(ptr); }
131 |
132 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
133 | public static Array TGamma(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_tgamma(out ptr, arr._ptr)); return new Array(ptr); }
134 |
135 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
136 | public static Array Abs(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_abs(out ptr, arr._ptr)); return new Array(ptr); }
137 |
138 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
139 | public static Array Sigmoid(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_sigmoid(out ptr, arr._ptr)); return new Array(ptr); }
140 |
141 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
142 | public static Array Factorial(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_factorial(out ptr, arr._ptr)); return new Array(ptr); }
143 |
144 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
145 | public static Array Round(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_round(out ptr, arr._ptr)); return new Array(ptr); }
146 |
147 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
148 | public static Array Trunc(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_trunc(out ptr, arr._ptr)); return new Array(ptr); }
149 |
150 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
151 | public static Array Floor(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_floor(out ptr, arr._ptr)); return new Array(ptr); }
152 |
153 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
154 | public static Array Ceil(Array arr) { IntPtr ptr; Internal.VERIFY(AFArith.af_ceil(out ptr, arr._ptr)); return new Array(ptr); }
155 | #endif
156 |
157 | #if _
158 | for (\w+) in
159 | Atan2 Rem Pow
160 | do
161 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
162 | public static Array $1(Array lhs, Array rhs) { IntPtr ptr; Internal.VERIFY(AFArith.af_$L1(out ptr, lhs._ptr, rhs._ptr, false)); return new Array(ptr); }
163 | #else
164 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
165 | public static Array Atan2(Array lhs, Array rhs) { IntPtr ptr; Internal.VERIFY(AFArith.af_atan2(out ptr, lhs._ptr, rhs._ptr, false)); return new Array(ptr); }
166 |
167 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
168 | public static Array Rem(Array lhs, Array rhs) { IntPtr ptr; Internal.VERIFY(AFArith.af_rem(out ptr, lhs._ptr, rhs._ptr, false)); return new Array(ptr); }
169 |
170 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
171 | public static Array Pow(Array lhs, Array rhs) { IntPtr ptr; Internal.VERIFY(AFArith.af_pow(out ptr, lhs._ptr, rhs._ptr, false)); return new Array(ptr); }
172 | #endif
173 | #endregion
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/src/Wrapper/ArrayFire.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | true
6 | 0.0.1
7 | Haiping Chen
8 | BSD-3
9 | git
10 | ArrayFire is a high performance library for parallel computing with an easy-to-use API. It enables users to write scientific computing code that is portable across CUDA, OpenCL and CPU devices. This project provides .NET bindings for the ArrayFire library.
11 | https://raw.githubusercontent.com/arrayfire/arrayfire-dotnet/master/LICENSE
12 | https://github.com/arrayfire/arrayfire-dotnet
13 | https://avatars3.githubusercontent.com/u/5395442?s=200&v=4
14 | https://github.com/arrayfire/arrayfire-dotnet
15 | ArrayFire
16 | Upgrade Interop to arrayfire v3.6.
17 | ArrayFire (https://www.arrayfire.com)
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Wrapper/Device.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | public static class Device
41 | {
42 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
43 | public static void SetBackend(Backend backend)
44 | {
45 | Internal.VERIFY(AFBackend.af_set_backend((af_backend)backend));
46 | }
47 |
48 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
49 | public static void SetDevice(int device)
50 | {
51 | Internal.VERIFY(AFDevice.af_set_device(device));
52 | }
53 |
54 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
55 | public static void PrintInfo()
56 | {
57 | Internal.VERIFY(AFDevice.af_info());
58 | }
59 |
60 | public static int BackendCount
61 | {
62 | get
63 | {
64 | uint res;
65 | Internal.VERIFY(AFBackend.af_get_backend_count(out res));
66 | return (int)res;
67 | }
68 | }
69 |
70 | public static int DeviceCount
71 | {
72 | get
73 | {
74 | int res;
75 | Internal.VERIFY(AFDevice.af_get_device_count(out res));
76 | return res;
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Wrapper/Internal.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Collections.Generic;
35 | using System.Runtime.InteropServices;
36 | using System.Runtime.CompilerServices;
37 |
38 | using ArrayFire.Interop;
39 |
40 | namespace ArrayFire
41 | {
42 | internal static class Internal // shared functionality
43 | {
44 | private static Dictionary dtype2clr;
45 | private static Dictionary clr2dtype;
46 | private static Dictionary>[] getdatafn;
47 |
48 | static Internal()
49 | {
50 | clr2dtype = new Dictionary();
51 | dtype2clr = new Dictionary();
52 | getdatafn = new Dictionary>[4];
53 | for(int i = 0; i < getdatafn.Length; ++i) getdatafn[i] = new Dictionary>();
54 |
55 | #if _
56 | for (\w+)=(\w+) in
57 | b8=bool c64=Complex f32=float f64=double s32=int s64=long u32=uint u64=ulong u8=byte s16=short u16=ushort
58 | do
59 | dtype2clr.Add(af_dtype.$1, typeof($2));
60 | clr2dtype.Add(typeof($2), af_dtype.$1);
61 | getdatafn[0].Add(typeof($2), (data, ptr) => AFArray.af_get_data_ptr(($2[])data, ptr));
62 | getdatafn[1].Add(typeof($2), (data, ptr) => AFArray.af_get_data_ptr(($2[,])data, ptr));
63 | getdatafn[2].Add(typeof($2), (data, ptr) => AFArray.af_get_data_ptr(($2[,,])data, ptr));
64 | getdatafn[3].Add(typeof($2), (data, ptr) => AFArray.af_get_data_ptr(($2[,,,])data, ptr));
65 | #else
66 | dtype2clr.Add(af_dtype.b8, typeof(bool));
67 | clr2dtype.Add(typeof(bool), af_dtype.b8);
68 | getdatafn[0].Add(typeof(bool), (data, ptr) => AFArray.af_get_data_ptr((bool[])data, ptr));
69 | getdatafn[1].Add(typeof(bool), (data, ptr) => AFArray.af_get_data_ptr((bool[,])data, ptr));
70 | getdatafn[2].Add(typeof(bool), (data, ptr) => AFArray.af_get_data_ptr((bool[,,])data, ptr));
71 | getdatafn[3].Add(typeof(bool), (data, ptr) => AFArray.af_get_data_ptr((bool[,,,])data, ptr));
72 |
73 | dtype2clr.Add(af_dtype.c64, typeof(Complex));
74 | clr2dtype.Add(typeof(Complex), af_dtype.c64);
75 | getdatafn[0].Add(typeof(Complex), (data, ptr) => AFArray.af_get_data_ptr((Complex[])data, ptr));
76 | getdatafn[1].Add(typeof(Complex), (data, ptr) => AFArray.af_get_data_ptr((Complex[,])data, ptr));
77 | getdatafn[2].Add(typeof(Complex), (data, ptr) => AFArray.af_get_data_ptr((Complex[,,])data, ptr));
78 | getdatafn[3].Add(typeof(Complex), (data, ptr) => AFArray.af_get_data_ptr((Complex[,,,])data, ptr));
79 |
80 | dtype2clr.Add(af_dtype.f32, typeof(float));
81 | clr2dtype.Add(typeof(float), af_dtype.f32);
82 | getdatafn[0].Add(typeof(float), (data, ptr) => AFArray.af_get_data_ptr((float[])data, ptr));
83 | getdatafn[1].Add(typeof(float), (data, ptr) => AFArray.af_get_data_ptr((float[,])data, ptr));
84 | getdatafn[2].Add(typeof(float), (data, ptr) => AFArray.af_get_data_ptr((float[,,])data, ptr));
85 | getdatafn[3].Add(typeof(float), (data, ptr) => AFArray.af_get_data_ptr((float[,,,])data, ptr));
86 |
87 | dtype2clr.Add(af_dtype.f64, typeof(double));
88 | clr2dtype.Add(typeof(double), af_dtype.f64);
89 | getdatafn[0].Add(typeof(double), (data, ptr) => AFArray.af_get_data_ptr((double[])data, ptr));
90 | getdatafn[1].Add(typeof(double), (data, ptr) => AFArray.af_get_data_ptr((double[,])data, ptr));
91 | getdatafn[2].Add(typeof(double), (data, ptr) => AFArray.af_get_data_ptr((double[,,])data, ptr));
92 | getdatafn[3].Add(typeof(double), (data, ptr) => AFArray.af_get_data_ptr((double[,,,])data, ptr));
93 |
94 | dtype2clr.Add(af_dtype.s32, typeof(int));
95 | clr2dtype.Add(typeof(int), af_dtype.s32);
96 | getdatafn[0].Add(typeof(int), (data, ptr) => AFArray.af_get_data_ptr((int[])data, ptr));
97 | getdatafn[1].Add(typeof(int), (data, ptr) => AFArray.af_get_data_ptr((int[,])data, ptr));
98 | getdatafn[2].Add(typeof(int), (data, ptr) => AFArray.af_get_data_ptr((int[,,])data, ptr));
99 | getdatafn[3].Add(typeof(int), (data, ptr) => AFArray.af_get_data_ptr((int[,,,])data, ptr));
100 |
101 | dtype2clr.Add(af_dtype.s64, typeof(long));
102 | clr2dtype.Add(typeof(long), af_dtype.s64);
103 | getdatafn[0].Add(typeof(long), (data, ptr) => AFArray.af_get_data_ptr((long[])data, ptr));
104 | getdatafn[1].Add(typeof(long), (data, ptr) => AFArray.af_get_data_ptr((long[,])data, ptr));
105 | getdatafn[2].Add(typeof(long), (data, ptr) => AFArray.af_get_data_ptr((long[,,])data, ptr));
106 | getdatafn[3].Add(typeof(long), (data, ptr) => AFArray.af_get_data_ptr((long[,,,])data, ptr));
107 |
108 | dtype2clr.Add(af_dtype.u32, typeof(uint));
109 | clr2dtype.Add(typeof(uint), af_dtype.u32);
110 | getdatafn[0].Add(typeof(uint), (data, ptr) => AFArray.af_get_data_ptr((uint[])data, ptr));
111 | getdatafn[1].Add(typeof(uint), (data, ptr) => AFArray.af_get_data_ptr((uint[,])data, ptr));
112 | getdatafn[2].Add(typeof(uint), (data, ptr) => AFArray.af_get_data_ptr((uint[,,])data, ptr));
113 | getdatafn[3].Add(typeof(uint), (data, ptr) => AFArray.af_get_data_ptr((uint[,,,])data, ptr));
114 |
115 | dtype2clr.Add(af_dtype.u64, typeof(ulong));
116 | clr2dtype.Add(typeof(ulong), af_dtype.u64);
117 | getdatafn[0].Add(typeof(ulong), (data, ptr) => AFArray.af_get_data_ptr((ulong[])data, ptr));
118 | getdatafn[1].Add(typeof(ulong), (data, ptr) => AFArray.af_get_data_ptr((ulong[,])data, ptr));
119 | getdatafn[2].Add(typeof(ulong), (data, ptr) => AFArray.af_get_data_ptr((ulong[,,])data, ptr));
120 | getdatafn[3].Add(typeof(ulong), (data, ptr) => AFArray.af_get_data_ptr((ulong[,,,])data, ptr));
121 |
122 | dtype2clr.Add(af_dtype.u8, typeof(byte));
123 | clr2dtype.Add(typeof(byte), af_dtype.u8);
124 | getdatafn[0].Add(typeof(byte), (data, ptr) => AFArray.af_get_data_ptr((byte[])data, ptr));
125 | getdatafn[1].Add(typeof(byte), (data, ptr) => AFArray.af_get_data_ptr((byte[,])data, ptr));
126 | getdatafn[2].Add(typeof(byte), (data, ptr) => AFArray.af_get_data_ptr((byte[,,])data, ptr));
127 | getdatafn[3].Add(typeof(byte), (data, ptr) => AFArray.af_get_data_ptr((byte[,,,])data, ptr));
128 |
129 | dtype2clr.Add(af_dtype.s16, typeof(short));
130 | clr2dtype.Add(typeof(short), af_dtype.s16);
131 | getdatafn[0].Add(typeof(short), (data, ptr) => AFArray.af_get_data_ptr((short[])data, ptr));
132 | getdatafn[1].Add(typeof(short), (data, ptr) => AFArray.af_get_data_ptr((short[,])data, ptr));
133 | getdatafn[2].Add(typeof(short), (data, ptr) => AFArray.af_get_data_ptr((short[,,])data, ptr));
134 | getdatafn[3].Add(typeof(short), (data, ptr) => AFArray.af_get_data_ptr((short[,,,])data, ptr));
135 |
136 | dtype2clr.Add(af_dtype.u16, typeof(ushort));
137 | clr2dtype.Add(typeof(ushort), af_dtype.u16);
138 | getdatafn[0].Add(typeof(ushort), (data, ptr) => AFArray.af_get_data_ptr((ushort[])data, ptr));
139 | getdatafn[1].Add(typeof(ushort), (data, ptr) => AFArray.af_get_data_ptr((ushort[,])data, ptr));
140 | getdatafn[2].Add(typeof(ushort), (data, ptr) => AFArray.af_get_data_ptr((ushort[,,])data, ptr));
141 | getdatafn[3].Add(typeof(ushort), (data, ptr) => AFArray.af_get_data_ptr((ushort[,,,])data, ptr));
142 | #endif
143 | }
144 |
145 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
146 | internal static af_dtype toDType() { return clr2dtype[typeof(T)]; }
147 |
148 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
149 | internal static Type toClrType(af_dtype dtype) { return dtype2clr[dtype]; }
150 |
151 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
152 | internal static af_err getData(System.Array arr, IntPtr ptr)
153 | {
154 | // lookup time was experimentally found to be negligible (less than 1%)
155 | // compared to the time the actual operation takes, even for small arrays
156 | return getdatafn[arr.Rank - 1][typeof(T)](arr, ptr);
157 | }
158 |
159 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
160 | internal static long[] toLongArray(int[] intarr)
161 | {
162 | return System.Array.ConvertAll(intarr, x => (long)x);
163 | }
164 |
165 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
166 | internal static void VERIFY(af_err err)
167 | {
168 | if (err != af_err.AF_SUCCESS) throw new ArrayFireException(err);
169 | }
170 |
171 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
172 | internal static UIntPtr sizeOfArray(System.Array arr)
173 | {
174 | return (UIntPtr)(Marshal.SizeOf(arr.GetType().GetElementType()) * arr.Length);
175 | }
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFAlgorithm.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFAlgorithm
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_sum(out IntPtr array_out, IntPtr array_in, int dim);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_sum_nan(out IntPtr array_out, IntPtr array_in, int dim, double nanval);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_product(out IntPtr array_out, IntPtr array_in, int dim);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_product_nan(out IntPtr array_out, IntPtr array_in, int dim, double nanval);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_min(out IntPtr array_out, IntPtr array_in, int dim);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_max(out IntPtr array_out, IntPtr array_in, int dim);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_all_true(out IntPtr array_out, IntPtr array_in, int dim);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_any_true(out IntPtr array_out, IntPtr array_in, int dim);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_count(out IntPtr array_out, IntPtr array_in, int dim);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_sum_all(out double real, out double imag, IntPtr array_in);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_sum_nan_all(out double real, out double imag, IntPtr array_in, double nanval);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_product_all(out double real, out double imag, IntPtr array_in);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_product_nan_all(out double real, out double imag, IntPtr array_in, double nanval);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_min_all(out double real, out double imag, IntPtr array_in);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_max_all(out double real, out double imag, IntPtr array_in);
59 |
60 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern af_err af_all_true_all(out double real, out double imag, IntPtr array_in);
62 |
63 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
64 | public static extern af_err af_any_true_all(out double real, out double imag, IntPtr array_in);
65 |
66 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern af_err af_count_all(out double real, out double imag, IntPtr array_in);
68 |
69 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70 | public static extern af_err af_imin(out IntPtr array_out, out IntPtr array_idx, IntPtr array_in, int dim);
71 |
72 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern af_err af_imax(out IntPtr array_out, out IntPtr array_idx, IntPtr array_in, int dim);
74 |
75 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76 | public static extern af_err af_imin_all(out double real, out double imag, out uint idx, IntPtr array_in);
77 |
78 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern af_err af_imax_all(out double real, out double imag, out uint idx, IntPtr array_in);
80 |
81 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82 | public static extern af_err af_accum(out IntPtr array_out, IntPtr array_in, int dim);
83 |
84 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern af_err af_scan(out IntPtr array_out, IntPtr array_in, int dim, af_binary_op op, bool inclusive_scan);
86 |
87 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
88 | public static extern af_err af_scan_by_key(out IntPtr array_out, IntPtr array_key, IntPtr array_in, int dim, af_binary_op op, bool inclusive_scan);
89 |
90 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
91 | public static extern af_err af_where(out IntPtr array_idx, IntPtr array_in);
92 |
93 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
94 | public static extern af_err af_diff1(out IntPtr array_out, IntPtr array_in, int dim);
95 |
96 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
97 | public static extern af_err af_diff2(out IntPtr array_out, IntPtr array_in, int dim);
98 |
99 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
100 | public static extern af_err af_sort(out IntPtr array_out, IntPtr array_in, uint dim, bool isAscending);
101 |
102 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
103 | public static extern af_err af_sort_index(out IntPtr array_out, out IntPtr array_indices, IntPtr array_in, uint dim, bool isAscending);
104 |
105 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
106 | public static extern af_err af_sort_by_key(out IntPtr array_out_keys, out IntPtr array_out_values, IntPtr array_keys, IntPtr array_values, uint dim, bool isAscending);
107 |
108 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
109 | public static extern af_err af_set_unique(out IntPtr array_out, IntPtr array_in, bool is_sorted);
110 |
111 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
112 | public static extern af_err af_set_union(out IntPtr array_out, IntPtr array_first, IntPtr array_second, bool is_unique);
113 |
114 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
115 | public static extern af_err af_set_intersect(out IntPtr array_out, IntPtr array_first, IntPtr array_second, bool is_unique);
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFArith.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFArith
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_add(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_sub(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_mul(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_div(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_lt(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_gt(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_le(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_ge(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_eq(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_neq(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_and(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_or(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_not(out IntPtr array_out, IntPtr array_in);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_bitand(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_bitor(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
59 |
60 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern af_err af_bitxor(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
62 |
63 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
64 | public static extern af_err af_bitshiftl(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
65 |
66 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern af_err af_bitshiftr(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
68 |
69 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70 | public static extern af_err af_cast(out IntPtr array_out, IntPtr array_in, af_dtype type);
71 |
72 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern af_err af_minof(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
74 |
75 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76 | public static extern af_err af_maxof(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
77 |
78 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern af_err af_clamp(out IntPtr array_out, IntPtr array_in, IntPtr array_lo, IntPtr array_hi, bool batch);
80 |
81 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82 | public static extern af_err af_rem(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
83 |
84 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern af_err af_mod(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
86 |
87 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
88 | public static extern af_err af_abs(out IntPtr array_out, IntPtr array_in);
89 |
90 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
91 | public static extern af_err af_arg(out IntPtr array_out, IntPtr array_in);
92 |
93 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
94 | public static extern af_err af_sign(out IntPtr array_out, IntPtr array_in);
95 |
96 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
97 | public static extern af_err af_round(out IntPtr array_out, IntPtr array_in);
98 |
99 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
100 | public static extern af_err af_trunc(out IntPtr array_out, IntPtr array_in);
101 |
102 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
103 | public static extern af_err af_floor(out IntPtr array_out, IntPtr array_in);
104 |
105 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
106 | public static extern af_err af_ceil(out IntPtr array_out, IntPtr array_in);
107 |
108 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
109 | public static extern af_err af_hypot(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
110 |
111 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
112 | public static extern af_err af_sin(out IntPtr array_out, IntPtr array_in);
113 |
114 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
115 | public static extern af_err af_cos(out IntPtr array_out, IntPtr array_in);
116 |
117 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
118 | public static extern af_err af_tan(out IntPtr array_out, IntPtr array_in);
119 |
120 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
121 | public static extern af_err af_asin(out IntPtr array_out, IntPtr array_in);
122 |
123 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
124 | public static extern af_err af_acos(out IntPtr array_out, IntPtr array_in);
125 |
126 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
127 | public static extern af_err af_atan(out IntPtr array_out, IntPtr array_in);
128 |
129 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
130 | public static extern af_err af_atan2(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
131 |
132 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
133 | public static extern af_err af_cplx2(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
134 |
135 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
136 | public static extern af_err af_cplx(out IntPtr array_out, IntPtr array_in);
137 |
138 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
139 | public static extern af_err af_real(out IntPtr array_out, IntPtr array_in);
140 |
141 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
142 | public static extern af_err af_imag(out IntPtr array_out, IntPtr array_in);
143 |
144 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
145 | public static extern af_err af_conjg(out IntPtr array_out, IntPtr array_in);
146 |
147 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
148 | public static extern af_err af_sinh(out IntPtr array_out, IntPtr array_in);
149 |
150 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
151 | public static extern af_err af_cosh(out IntPtr array_out, IntPtr array_in);
152 |
153 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
154 | public static extern af_err af_tanh(out IntPtr array_out, IntPtr array_in);
155 |
156 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
157 | public static extern af_err af_asinh(out IntPtr array_out, IntPtr array_in);
158 |
159 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
160 | public static extern af_err af_acosh(out IntPtr array_out, IntPtr array_in);
161 |
162 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
163 | public static extern af_err af_atanh(out IntPtr array_out, IntPtr array_in);
164 |
165 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
166 | public static extern af_err af_root(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
167 |
168 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
169 | public static extern af_err af_pow(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, bool batch);
170 |
171 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
172 | public static extern af_err af_pow2(out IntPtr array_out, IntPtr array_in);
173 |
174 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
175 | public static extern af_err af_exp(out IntPtr array_out, IntPtr array_in);
176 |
177 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
178 | public static extern af_err af_sigmoid(out IntPtr array_out, IntPtr array_in);
179 |
180 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
181 | public static extern af_err af_expm1(out IntPtr array_out, IntPtr array_in);
182 |
183 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
184 | public static extern af_err af_erf(out IntPtr array_out, IntPtr array_in);
185 |
186 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
187 | public static extern af_err af_erfc(out IntPtr array_out, IntPtr array_in);
188 |
189 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
190 | public static extern af_err af_log(out IntPtr array_out, IntPtr array_in);
191 |
192 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
193 | public static extern af_err af_log1p(out IntPtr array_out, IntPtr array_in);
194 |
195 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
196 | public static extern af_err af_log10(out IntPtr array_out, IntPtr array_in);
197 |
198 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
199 | public static extern af_err af_log2(out IntPtr array_out, IntPtr array_in);
200 |
201 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
202 | public static extern af_err af_sqrt(out IntPtr array_out, IntPtr array_in);
203 |
204 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
205 | public static extern af_err af_cbrt(out IntPtr array_out, IntPtr array_in);
206 |
207 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
208 | public static extern af_err af_factorial(out IntPtr array_out, IntPtr array_in);
209 |
210 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
211 | public static extern af_err af_tgamma(out IntPtr array_out, IntPtr array_in);
212 |
213 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
214 | public static extern af_err af_lgamma(out IntPtr array_out, IntPtr array_in);
215 |
216 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
217 | public static extern af_err af_iszero(out IntPtr array_out, IntPtr array_in);
218 |
219 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
220 | public static extern af_err af_isinf(out IntPtr array_out, IntPtr array_in);
221 |
222 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
223 | public static extern af_err af_isnan(out IntPtr array_out, IntPtr array_in);
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFBackend.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFBackend
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_set_backend(af_backend bknd);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_get_backend_count(out uint num_backends);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_get_available_backends(out int backends);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_get_backend_id(out af_backend backend, IntPtr array_in);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_get_active_backend(out af_backend backend);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_get_device_id(out int device, IntPtr array_in);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFBlas.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFBlas
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_matmul(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, af_mat_prop optLhs, af_mat_prop optRhs);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_dot(out IntPtr array_out, IntPtr array_lhs, IntPtr array_rhs, af_mat_prop optLhs, af_mat_prop optRhs);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_dot_all(out double real, out double imag, IntPtr array_lhs, IntPtr array_rhs, af_mat_prop optLhs, af_mat_prop optRhs);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_transpose(out IntPtr array_out, IntPtr array_in, bool conjugate);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_transpose_inplace(IntPtr array_in, bool conjugate);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFData.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFData
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_constant(out IntPtr array_arr, double val, uint ndims, [In] long[] dim_dims, af_dtype type);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_constant_complex(out IntPtr array_arr, double real, double imag, uint ndims, [In] long[] dim_dims, af_dtype type);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_constant_long(out IntPtr array_arr, long val, uint ndims, [In] long[] dim_dims);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_constant_ulong(out IntPtr array_arr, ulong val, uint ndims, [In] long[] dim_dims);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_range(out IntPtr array_out, uint ndims, [In] long[] dim_dims, int seq_dim, af_dtype type);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_iota(out IntPtr array_out, uint ndims, [In] long[] dim_dims, uint t_ndims, [In] long[] dim_tdims, af_dtype type);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_identity(out IntPtr array_out, uint ndims, [In] long[] dim_dims, af_dtype type);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_diag_create(out IntPtr array_out, IntPtr array_in, int num);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_diag_extract(out IntPtr array_out, IntPtr array_in, int num);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_join(out IntPtr array_out, int dim, IntPtr array_first, IntPtr array_second);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_join_many(out IntPtr array_out, int dim, uint n_arrays, [In] IntPtr[] array_inputs);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_tile(out IntPtr array_out, IntPtr array_in, uint x, uint y, uint z, uint w);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_reorder(out IntPtr array_out, IntPtr array_in, uint x, uint y, uint z, uint w);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_shift(out IntPtr array_out, IntPtr array_in, int x, int y, int z, int w);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_moddims(out IntPtr array_out, IntPtr array_in, uint ndims, [In] long[] dim_dims);
59 |
60 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern af_err af_flat(out IntPtr array_out, IntPtr array_in);
62 |
63 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
64 | public static extern af_err af_flip(out IntPtr array_out, IntPtr array_in, uint dim);
65 |
66 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern af_err af_lower(out IntPtr array_out, IntPtr array_in, bool is_unit_diag);
68 |
69 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70 | public static extern af_err af_upper(out IntPtr array_out, IntPtr array_in, bool is_unit_diag);
71 |
72 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern af_err af_select(out IntPtr array_out, IntPtr array_cond, IntPtr array_a, IntPtr array_b);
74 |
75 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76 | public static extern af_err af_select_scalar_r(out IntPtr array_out, IntPtr array_cond, IntPtr array_a, double b);
77 |
78 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern af_err af_select_scalar_l(out IntPtr array_out, IntPtr array_cond, double a, IntPtr array_b);
80 |
81 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82 | public static extern af_err af_replace(IntPtr array_a, IntPtr array_cond, IntPtr array_b);
83 |
84 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern af_err af_replace_scalar(IntPtr array_a, IntPtr array_cond, double b);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFIndex.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFIndex
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_index(out IntPtr array_out, IntPtr array_in, uint ndims, [In] af_seq[] index);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_lookup(out IntPtr array_out, IntPtr array_in, IntPtr array_indices, uint dim);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_assign_seq(ref IntPtr array_out, IntPtr array_lhs, uint ndims, [In] af_seq[] indices, IntPtr array_rhs);
23 |
24 | /* not yet supported:
25 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
26 | public static extern af_err af_index_gen(out IntPtr array_out, IntPtr array_in, long dim_ndims, ???const af_index_t* indices???); */
27 |
28 | /* not yet supported:
29 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
30 | public static extern af_err af_assign_gen(out IntPtr array_out, IntPtr array_lhs, long dim_ndims, ???const af_index_t* indices???, IntPtr array_rhs); */
31 |
32 | /* not yet supported:
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_create_indexers(???af_index_t** indexers???); */
35 |
36 | /* not yet supported:
37 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
38 | public static extern af_err af_set_array_indexer(out ???af_index_t??? indexer, IntPtr array_idx, long dim_dim); */
39 |
40 | /* not yet supported:
41 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
42 | public static extern af_err af_set_seq_indexer(out ???af_index_t??? indexer, [In] af_seq[] idx, long dim_dim, bool is_batch); */
43 |
44 | /* not yet supported:
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_set_seq_param_indexer(out ???af_index_t??? indexer, double begin, double end, double step, long dim_dim, bool is_batch); */
47 |
48 | /* not yet supported:
49 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
50 | public static extern af_err af_release_indexers(out ???af_index_t??? indexers); */
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFInternal.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFInternal
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] bool[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] Complex[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] float[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] double[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] int[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] long[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] uint[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ulong[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] byte[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] short[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ushort[] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] bool[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] Complex[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] float[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] double[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
59 |
60 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] int[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
62 |
63 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
64 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] long[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
65 |
66 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] uint[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
68 |
69 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ulong[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
71 |
72 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] byte[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
74 |
75 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] short[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
77 |
78 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ushort[,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
80 |
81 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] bool[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
83 |
84 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] Complex[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
86 |
87 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
88 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] float[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
89 |
90 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
91 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] double[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
92 |
93 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
94 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] int[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
95 |
96 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
97 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] long[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
98 |
99 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
100 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] uint[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
101 |
102 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
103 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ulong[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
104 |
105 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
106 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] byte[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
107 |
108 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
109 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] short[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
110 |
111 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
112 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ushort[,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
113 |
114 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
115 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] bool[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
116 |
117 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
118 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] Complex[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
119 |
120 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
121 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] float[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
122 |
123 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
124 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] double[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
125 |
126 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
127 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] int[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
128 |
129 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
130 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] long[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
131 |
132 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
133 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] uint[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
134 |
135 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
136 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ulong[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
137 |
138 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
139 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] byte[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
140 |
141 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
142 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] short[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
143 |
144 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
145 | public static extern af_err af_create_strided_array(out IntPtr array_arr, [In] ushort[,,,] data, long dim_offset, uint ndims, [In] long[] dim_dims, [In] long[] dim_strides, af_dtype ty, af_source location);
146 |
147 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
148 | public static extern af_err af_get_strides(out long dim_s0, out long dim_s1, out long dim_s2, out long dim_s3, IntPtr array_arr);
149 |
150 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
151 | public static extern af_err af_get_offset(out long dim_offset, IntPtr array_arr);
152 |
153 | /* not yet supported:
154 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
155 | public static extern af_err af_get_raw_ptr(???void **ptr???, IntPtr array_arr); */
156 |
157 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
158 | public static extern af_err af_is_linear(out bool result, IntPtr array_arr);
159 |
160 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
161 | public static extern af_err af_is_owner(out bool result, IntPtr array_arr);
162 |
163 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
164 | public static extern af_err af_get_allocated_bytes(out UIntPtr size_bytes, IntPtr array_arr);
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFLapack.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFLapack
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_svd(out IntPtr array_u, out IntPtr array_s, out IntPtr array_vt, IntPtr array_in);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_svd_inplace(out IntPtr array_u, out IntPtr array_s, out IntPtr array_vt, IntPtr array_in);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_lu(out IntPtr array_lower, out IntPtr array_upper, out IntPtr array_pivot, IntPtr array_in);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_lu_inplace(out IntPtr array_pivot, IntPtr array_in, bool is_lapack_piv);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_qr(out IntPtr array_q, out IntPtr array_r, out IntPtr array_tau, IntPtr array_in);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_qr_inplace(out IntPtr array_tau, IntPtr array_in);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_cholesky(out IntPtr array_out, out int info, IntPtr array_in, bool is_upper);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_cholesky_inplace(out int info, IntPtr array_in, bool is_upper);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_solve(out IntPtr array_x, IntPtr array_a, IntPtr array_b, af_mat_prop options);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_solve_lu(out IntPtr array_x, IntPtr array_a, IntPtr array_piv, IntPtr array_b, af_mat_prop options);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_inverse(out IntPtr array_out, IntPtr array_in, af_mat_prop options);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_rank(out uint rank, IntPtr array_in, double tol);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_det(out double det_real, out double det_imag, IntPtr array_in);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_norm(out double output, IntPtr array_in, af_norm_type type, double p, double q);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_is_lapack_available(out bool output);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFRandom.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFRandom
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_create_random_engine(out IntPtr engine, af_random_engine_type rtype, ulong seed);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_retain_random_engine(out IntPtr output, IntPtr engine);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_random_engine_set_type(out IntPtr engine, af_random_engine_type rtype);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_random_engine_get_type(out af_random_engine_type rtype, IntPtr engine);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_random_uniform(out IntPtr array_out, uint ndims, [In] long[] dim_dims, af_dtype type, IntPtr engine);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_random_normal(out IntPtr array_out, uint ndims, [In] long[] dim_dims, af_dtype type, IntPtr engine);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_random_engine_set_seed(out IntPtr engine, ulong seed);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_get_default_random_engine(out IntPtr engine);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_set_default_random_engine_type(af_random_engine_type rtype);
41 |
42 | /* not yet supported:
43 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
44 | public static extern af_err af_random_engine_get_seed(???ulong * const seed???, af_random_engine engine); */
45 |
46 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
47 | public static extern af_err af_release_random_engine(IntPtr engine);
48 |
49 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
50 | public static extern af_err af_randu(out IntPtr array_out, uint ndims, [In] long[] dim_dims, af_dtype type);
51 |
52 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
53 | public static extern af_err af_randn(out IntPtr array_out, uint ndims, [In] long[] dim_dims, af_dtype type);
54 |
55 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
56 | public static extern af_err af_set_seed(ulong seed);
57 |
58 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
59 | public static extern af_err af_get_seed(out ulong seed);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFSignal.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFSignal
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_approx1(out IntPtr array_out, IntPtr array_in, IntPtr array_pos, af_interp_type method, float offGrid);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_approx2(out IntPtr array_out, IntPtr array_in, IntPtr array_pos0, IntPtr array_pos1, af_interp_type method, float offGrid);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_fft(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_fft_inplace(IntPtr array_in, double norm_factor);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_fft2(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0, long dim_odim1);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_fft2_inplace(IntPtr array_in, double norm_factor);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_fft3(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0, long dim_odim1, long dim_odim2);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_fft3_inplace(IntPtr array_in, double norm_factor);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_ifft(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_ifft_inplace(IntPtr array_in, double norm_factor);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_ifft2(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0, long dim_odim1);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_ifft2_inplace(IntPtr array_in, double norm_factor);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_ifft3(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_odim0, long dim_odim1, long dim_odim2);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_ifft3_inplace(IntPtr array_in, double norm_factor);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_fft_r2c(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_pad0);
59 |
60 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
61 | public static extern af_err af_fft2_r2c(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_pad0, long dim_pad1);
62 |
63 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
64 | public static extern af_err af_fft3_r2c(out IntPtr array_out, IntPtr array_in, double norm_factor, long dim_pad0, long dim_pad1, long dim_pad2);
65 |
66 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
67 | public static extern af_err af_fft_c2r(out IntPtr array_out, IntPtr array_in, double norm_factor, bool is_odd);
68 |
69 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
70 | public static extern af_err af_fft2_c2r(out IntPtr array_out, IntPtr array_in, double norm_factor, bool is_odd);
71 |
72 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
73 | public static extern af_err af_fft3_c2r(out IntPtr array_out, IntPtr array_in, double norm_factor, bool is_odd);
74 |
75 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
76 | public static extern af_err af_convolve1(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode, af_conv_domain domain);
77 |
78 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
79 | public static extern af_err af_convolve2(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode, af_conv_domain domain);
80 |
81 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
82 | public static extern af_err af_convolve3(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode, af_conv_domain domain);
83 |
84 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
85 | public static extern af_err af_convolve2_sep(out IntPtr array_out, IntPtr array_col_filter, IntPtr array_row_filter, IntPtr array_signal, af_conv_mode mode);
86 |
87 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
88 | public static extern af_err af_fft_convolve1(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode);
89 |
90 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
91 | public static extern af_err af_fft_convolve2(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode);
92 |
93 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
94 | public static extern af_err af_fft_convolve3(out IntPtr array_out, IntPtr array_signal, IntPtr array_filter, af_conv_mode mode);
95 |
96 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
97 | public static extern af_err af_fir(out IntPtr array_y, IntPtr array_b, IntPtr array_x);
98 |
99 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
100 | public static extern af_err af_iir(out IntPtr array_y, IntPtr array_b, IntPtr array_a, IntPtr array_x);
101 |
102 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
103 | public static extern af_err af_medfilt(out IntPtr array_out, IntPtr array_in, long dim_wind_length, long dim_wind_width, af_border_type edge_pad);
104 |
105 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
106 | public static extern af_err af_medfilt1(out IntPtr array_out, IntPtr array_in, long dim_wind_width, af_border_type edge_pad);
107 |
108 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
109 | public static extern af_err af_medfilt2(out IntPtr array_out, IntPtr array_in, long dim_wind_length, long dim_wind_width, af_border_type edge_pad);
110 |
111 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
112 | public static extern af_err af_set_fft_plan_cache_size(UIntPtr size_cache_size);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFSparse.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFSparse
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_create_sparse_array(out IntPtr array_out, long dim_nRows, long dim_nCols, IntPtr array_values, IntPtr array_rowIdx, IntPtr array_colIdx, af_storage stype);
17 |
18 | /* not yet supported:
19 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
20 | public static extern af_err af_create_sparse_array_from_ptr(out IntPtr array_out, long dim_nRows, long dim_nCols, long dim_nNZ, [In] T[_] values, ???const int * const rowIdx???, ???const int * const colIdx???, af_dtype type, af_storage stype, af_source src); */
21 |
22 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
23 | public static extern af_err af_create_sparse_array_from_dense(out IntPtr array_out, IntPtr array_dense, af_storage stype);
24 |
25 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
26 | public static extern af_err af_sparse_convert_to(out IntPtr array_out, IntPtr array_in, af_storage destStorage);
27 |
28 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
29 | public static extern af_err af_sparse_to_dense(out IntPtr array_out, IntPtr array_sparse);
30 |
31 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
32 | public static extern af_err af_sparse_get_info(out IntPtr array_values, out IntPtr array_rowIdx, out IntPtr array_colIdx, out af_storage stype, IntPtr array_in);
33 |
34 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
35 | public static extern af_err af_sparse_get_values(out IntPtr array_out, IntPtr array_in);
36 |
37 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
38 | public static extern af_err af_sparse_get_row_idx(out IntPtr array_out, IntPtr array_in);
39 |
40 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
41 | public static extern af_err af_sparse_get_col_idx(out IntPtr array_out, IntPtr array_in);
42 |
43 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
44 | public static extern af_err af_sparse_get_nnz(out long dim_out, IntPtr array_in);
45 |
46 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
47 | public static extern af_err af_sparse_get_storage(out af_storage output, IntPtr array_in);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFStatistics.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFStatistics
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_mean(out IntPtr array_out, IntPtr array_in, long dim_dim);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_mean_weighted(out IntPtr array_out, IntPtr array_in, IntPtr array_weights, long dim_dim);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_var(out IntPtr array_out, IntPtr array_in, bool isbiased, long dim_dim);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_var_weighted(out IntPtr array_out, IntPtr array_in, IntPtr array_weights, long dim_dim);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_stdev(out IntPtr array_out, IntPtr array_in, long dim_dim);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_cov(out IntPtr array_out, IntPtr array_X, IntPtr array_Y, bool isbiased);
32 |
33 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
34 | public static extern af_err af_median(out IntPtr array_out, IntPtr array_in, long dim_dim);
35 |
36 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
37 | public static extern af_err af_mean_all(out double real, out double imag, IntPtr array_in);
38 |
39 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
40 | public static extern af_err af_mean_all_weighted(out double real, out double imag, IntPtr array_in, IntPtr array_weights);
41 |
42 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
43 | public static extern af_err af_var_all(out double realVal, out double imagVal, IntPtr array_in, bool isbiased);
44 |
45 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
46 | public static extern af_err af_var_all_weighted(out double realVal, out double imagVal, IntPtr array_in, IntPtr array_weights);
47 |
48 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
49 | public static extern af_err af_stdev_all(out double real, out double imag, IntPtr array_in);
50 |
51 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
52 | public static extern af_err af_median_all(out double realVal, out double imagVal, IntPtr array_in);
53 |
54 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
55 | public static extern af_err af_corrcoef(out double realVal, out double imagVal, IntPtr array_X, IntPtr array_Y);
56 |
57 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
58 | public static extern af_err af_topk(out IntPtr array_values, out IntPtr array_indices, IntPtr array_in, int k, int dim, af_topk_function order);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/AFUtil.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | [SuppressUnmanagedCodeSecurity]
13 | public static class AFUtil
14 | {
15 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
16 | public static extern af_err af_print_array(IntPtr array_arr);
17 |
18 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
19 | public static extern af_err af_print_array_gen(string exp, IntPtr array_arr, int precision);
20 |
21 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
22 | public static extern af_err af_save_array(out int index, string key, IntPtr array_arr, string filename, bool append);
23 |
24 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
25 | public static extern af_err af_read_array_index(out IntPtr array_out, string filename, uint index);
26 |
27 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
28 | public static extern af_err af_read_array_key(out IntPtr array_out, string filename, string key);
29 |
30 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
31 | public static extern af_err af_read_array_key_check(out int index, string filename, string key);
32 |
33 | /* not yet supported:
34 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
35 | public static extern af_err af_array_to_string(???char **output???, string exp, IntPtr array_arr, int precision, bool transpose); */
36 |
37 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
38 | public static extern af_err af_example_function(out IntPtr array_out, IntPtr array_in, af_someenum_t param);
39 |
40 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
41 | public static extern af_err af_get_version(out int major, out int minor, out int patch);
42 |
43 | [DllImport(af_config.dll, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
44 | public static extern af_err af_get_size_of(out UIntPtr size_size, af_dtype type);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/enums.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | public enum af_err
13 | {
14 | ///
15 | /// The function returned successfully
16 | ///
17 | AF_SUCCESS = 0,
18 |
19 | // 100-199 Errors in environment
20 |
21 | ///
22 | /// The system or device ran out of memory
23 | ///
24 | AF_ERR_NO_MEM = 101,
25 |
26 | ///
27 | /// There was an error in the device driver
28 | ///
29 | AF_ERR_DRIVER = 102,
30 |
31 | ///
32 | /// There was an error with the runtime environment
33 | ///
34 | AF_ERR_RUNTIME = 103,
35 |
36 | // 200-299 Errors in input parameters
37 |
38 | ///
39 | /// The input array is not a valid af_array object
40 | ///
41 | AF_ERR_INVALID_ARRAY = 201,
42 |
43 | ///
44 | /// One of the function arguments is incorrect
45 | ///
46 | AF_ERR_ARG = 202,
47 |
48 | ///
49 | /// The size is incorrect
50 | ///
51 | AF_ERR_SIZE = 203,
52 |
53 | ///
54 | /// The type is not suppported by this function
55 | ///
56 | AF_ERR_TYPE = 204,
57 |
58 | ///
59 | /// The type of the input arrays are not compatible
60 | ///
61 | AF_ERR_DIFF_TYPE = 205,
62 |
63 | ///
64 | /// Function does not support GFOR / batch mode
65 | ///
66 | AF_ERR_BATCH = 207,
67 |
68 |
69 | // #if AF_API_VERSION >= 33
70 | ///
71 | /// Input does not belong to the current device.
72 | ///
73 | AF_ERR_DEVICE = 208,
74 | // #endif
75 |
76 | // 300-399 Errors for missing software features
77 |
78 | ///
79 | /// The option is not supported
80 | ///
81 | AF_ERR_NOT_SUPPORTED = 301,
82 |
83 | ///
84 | /// This build of ArrayFire does not support this feature
85 | ///
86 | AF_ERR_NOT_CONFIGURED = 302,
87 |
88 | // #if AF_API_VERSION >= 32
89 | ///
90 | /// This build of ArrayFire is not compiled with "nonfree" algorithms
91 | ///
92 | AF_ERR_NONFREE = 303,
93 | // #endif
94 |
95 | // 400-499 Errors for missing hardware features
96 |
97 | ///
98 | /// This device does not support double
99 | ///
100 | AF_ERR_NO_DBL = 401,
101 |
102 | ///
103 | /// This build of ArrayFire was not built with graphics or this device does
104 | /// not support graphics
105 | ///
106 | AF_ERR_NO_GFX = 402,
107 |
108 | // 500-599 Errors specific to heterogenous API
109 |
110 | // #if AF_API_VERSION >= 32
111 | ///
112 | /// There was an error when loading the libraries
113 | ///
114 | AF_ERR_LOAD_LIB = 501,
115 | // #endif
116 |
117 | // #if AF_API_VERSION >= 32
118 | ///
119 | /// There was an error when loading the symbols
120 | ///
121 | AF_ERR_LOAD_SYM = 502,
122 | // #endif
123 |
124 | // #if AF_API_VERSION >= 32
125 | ///
126 | /// There was a mismatch between the input array and the active backend
127 | ///
128 | AF_ERR_ARR_BKND_MISMATCH = 503,
129 | // #endif
130 |
131 | // 900-999 Errors from upstream libraries and runtimes
132 |
133 | ///
134 | /// There was an internal error either in ArrayFire or in a project
135 | /// upstream
136 | ///
137 | AF_ERR_INTERNAL = 998,
138 |
139 | ///
140 | /// Unknown Error
141 | ///
142 | AF_ERR_UNKNOWN = 999
143 | }
144 |
145 | public enum af_dtype
146 | {
147 | f32, ///< 32-bit floating point values
148 | c32, ///< 32-bit complex floating point values
149 | f64, ///< 64-bit complex floating point values
150 | c64, ///< 64-bit complex floating point values
151 | b8 , ///< 8-bit boolean values
152 | s32, ///< 32-bit signed integral values
153 | u32, ///< 32-bit unsigned integral values
154 | u8 , ///< 8-bit unsigned integral values
155 | s64, ///< 64-bit signed integral values
156 | u64, ///< 64-bit unsigned integral values
157 | // #if AF_API_VERSION >= 32
158 | s16, ///< 16-bit signed integral values
159 | // #endif
160 | // #if AF_API_VERSION >= 32
161 | u16, ///< 16-bit unsigned integral values
162 | // #endif
163 | }
164 |
165 | public enum af_source
166 | {
167 | afDevice, ///< Device pointer
168 | afHost, ///< Host pointer
169 | }
170 |
171 | public enum af_interp_type
172 | {
173 | AF_INTERP_NEAREST, ///< Nearest Interpolation
174 | AF_INTERP_LINEAR, ///< Linear Interpolation
175 | AF_INTERP_BILINEAR, ///< Bilinear Interpolation
176 | AF_INTERP_CUBIC, ///< Cubic Interpolation
177 | AF_INTERP_LOWER, ///< Floor Indexed
178 | // #if AF_API_VERSION >= 34
179 | AF_INTERP_LINEAR_COSINE, ///< Linear Interpolation with cosine smoothing
180 | // #endif
181 | // #if AF_API_VERSION >= 34
182 | AF_INTERP_BILINEAR_COSINE, ///< Bilinear Interpolation with cosine smoothing
183 | // #endif
184 | // #if AF_API_VERSION >= 34
185 | AF_INTERP_BICUBIC, ///< Bicubic Interpolation
186 | // #endif
187 | // #if AF_API_VERSION >= 34
188 | AF_INTERP_CUBIC_SPLINE, ///< Cubic Interpolation with Catmull-Rom splines
189 | // #endif
190 | // #if AF_API_VERSION >= 34
191 | AF_INTERP_BICUBIC_SPLINE, ///< Bicubic Interpolation with Catmull-Rom splines
192 | // #endif
193 | }
194 |
195 | public enum af_border_type
196 | {
197 | ///
198 | /// Out of bound values are 0
199 | ///
200 | AF_PAD_ZERO = 0,
201 |
202 | ///
203 | /// Out of bound values are symmetric over the edge
204 | ///
205 | AF_PAD_SYM,
206 |
207 | ///
208 | /// Out of bound values are clamped to the edge
209 | ///
210 | AF_PAD_CLAMP_TO_EDGE,
211 | }
212 |
213 | public enum af_connectivity
214 | {
215 | ///
216 | /// Connectivity includes neighbors, North, East, South and West of current pixel
217 | ///
218 | AF_CONNECTIVITY_4 = 4,
219 |
220 | ///
221 | /// Connectivity includes 4-connectivity neigbors and also those on Northeast, Northwest, Southeast and Southwest
222 | ///
223 | AF_CONNECTIVITY_8 = 8
224 | }
225 |
226 | public enum af_conv_mode
227 | {
228 | ///
229 | /// Output of the convolution is the same size as input
230 | ///
231 | AF_CONV_DEFAULT,
232 |
233 | ///
234 | /// Output of the convolution is signal_len + filter_len - 1
235 | ///
236 | AF_CONV_EXPAND,
237 | }
238 |
239 | public enum af_conv_domain
240 | {
241 | AF_CONV_AUTO, ///< ArrayFire automatically picks the right convolution algorithm
242 | AF_CONV_SPATIAL, ///< Perform convolution in spatial domain
243 | AF_CONV_FREQ, ///< Perform convolution in frequency domain
244 | }
245 |
246 | public enum af_match_type
247 | {
248 | AF_SAD = 0, ///< Match based on Sum of Absolute Differences (SAD)
249 | AF_ZSAD, ///< Match based on Zero mean SAD
250 | AF_LSAD, ///< Match based on Locally scaled SAD
251 | AF_SSD, ///< Match based on Sum of Squared Differences (SSD)
252 | AF_ZSSD, ///< Match based on Zero mean SSD
253 | AF_LSSD, ///< Match based on Locally scaled SSD
254 | AF_NCC, ///< Match based on Normalized Cross Correlation (NCC)
255 | AF_ZNCC, ///< Match based on Zero mean NCC
256 | AF_SHD ///< Match based on Sum of Hamming Distances (SHD)
257 | }
258 |
259 | public enum af_ycc_std
260 | {
261 | AF_YCC_601 = 601, ///< ITU-R BT.601 (formerly CCIR 601) standard
262 | AF_YCC_709 = 709, ///< ITU-R BT.709 standard
263 | AF_YCC_2020 = 2020 ///< ITU-R BT.2020 standard
264 | }
265 |
266 | public enum af_cspace_t
267 | {
268 | AF_GRAY = 0, ///< Grayscale
269 | AF_RGB, ///< 3-channel RGB
270 | AF_HSV, ///< 3-channel HSV
271 | // #if AF_API_VERSION >= 31
272 | AF_YCbCr ///< 3-channel YCbCr
273 | // #endif
274 | }
275 |
276 | public enum af_mat_prop
277 | {
278 | AF_MAT_NONE = 0, ///< Default
279 | AF_MAT_TRANS = 1, ///< Data needs to be transposed
280 | AF_MAT_CTRANS = 2, ///< Data needs to be conjugate tansposed
281 | AF_MAT_CONJ = 4, ///< Data needs to be conjugate
282 | AF_MAT_UPPER = 32, ///< Matrix is upper triangular
283 | AF_MAT_LOWER = 64, ///< Matrix is lower triangular
284 | AF_MAT_DIAG_UNIT = 128, ///< Matrix diagonal contains unitary values
285 | AF_MAT_SYM = 512, ///< Matrix is symmetric
286 | AF_MAT_POSDEF = 1024, ///< Matrix is positive definite
287 | AF_MAT_ORTHOG = 2048, ///< Matrix is orthogonal
288 | AF_MAT_TRI_DIAG = 4096, ///< Matrix is tri diagonal
289 | AF_MAT_BLOCK_DIAG = 8192 ///< Matrix is block diagonal
290 | }
291 |
292 | public enum af_norm_type
293 | {
294 | AF_NORM_VECTOR_1, ///< treats the input as a vector and returns the sum of absolute values
295 | AF_NORM_VECTOR_INF, ///< treats the input as a vector and returns the max of absolute values
296 | AF_NORM_VECTOR_2, ///< treats the input as a vector and returns euclidean norm
297 | AF_NORM_VECTOR_P, ///< treats the input as a vector and returns the p-norm
298 | AF_NORM_MATRIX_1, ///< return the max of column sums
299 | AF_NORM_MATRIX_INF, ///< return the max of row sums
300 | AF_NORM_MATRIX_2, ///< returns the max singular value). Currently NOT SUPPORTED
301 | AF_NORM_MATRIX_L_PQ, ///< returns Lpq-norm
302 |
303 | AF_NORM_EUCLID = AF_NORM_VECTOR_2, ///< The default. Same as AF_NORM_VECTOR_2
304 | }
305 |
306 | public enum af_image_format
307 | {
308 | AF_FIF_BMP = 0, ///< FreeImage Enum for Bitmap File
309 | AF_FIF_ICO = 1, ///< FreeImage Enum for Windows Icon File
310 | AF_FIF_JPEG = 2, ///< FreeImage Enum for JPEG File
311 | AF_FIF_JNG = 3, ///< FreeImage Enum for JPEG Network Graphics File
312 | AF_FIF_PNG = 13, ///< FreeImage Enum for Portable Network Graphics File
313 | AF_FIF_PPM = 14, ///< FreeImage Enum for Portable Pixelmap (ASCII) File
314 | AF_FIF_PPMRAW = 15, ///< FreeImage Enum for Portable Pixelmap (Binary) File
315 | AF_FIF_TIFF = 18, ///< FreeImage Enum for Tagged Image File Format File
316 | AF_FIF_PSD = 20, ///< FreeImage Enum for Adobe Photoshop File
317 | AF_FIF_HDR = 26, ///< FreeImage Enum for High Dynamic Range File
318 | AF_FIF_EXR = 29, ///< FreeImage Enum for ILM OpenEXR File
319 | AF_FIF_JP2 = 31, ///< FreeImage Enum for JPEG-2000 File
320 | AF_FIF_RAW = 34 ///< FreeImage Enum for RAW Camera Image File
321 | }
322 |
323 | public enum af_moment_type
324 | {
325 | AF_MOMENT_M00 = 1,
326 | AF_MOMENT_M01 = 2,
327 | AF_MOMENT_M10 = 4,
328 | AF_MOMENT_M11 = 8,
329 | AF_MOMENT_FIRST_ORDER = AF_MOMENT_M00 | AF_MOMENT_M01 | AF_MOMENT_M10 | AF_MOMENT_M11
330 | }
331 |
332 | public enum af_homography_type
333 | {
334 | AF_HOMOGRAPHY_RANSAC = 0, ///< Computes homography using RANSAC
335 | AF_HOMOGRAPHY_LMEDS = 1 ///< Computes homography using Least Median of Squares
336 | }
337 |
338 | public enum af_backend
339 | {
340 | AF_BACKEND_DEFAULT = 0, ///< Default backend order: OpenCL -> CUDA -> CPU
341 | AF_BACKEND_CPU = 1, ///< CPU a.k.a sequential algorithms
342 | AF_BACKEND_CUDA = 2, ///< CUDA Compute Backend
343 | AF_BACKEND_OPENCL = 4, ///< OpenCL Compute Backend
344 | }
345 |
346 | public enum af_someenum_t
347 | {
348 | AF_ID = 0
349 | }
350 |
351 | public enum af_binary_op
352 | {
353 | AF_BINARY_ADD = 0,
354 | AF_BINARY_MUL = 1,
355 | AF_BINARY_MIN = 2,
356 | AF_BINARY_MAX = 3
357 | }
358 |
359 | public enum af_random_engine_type
360 | {
361 | AF_RANDOM_ENGINE_PHILOX_4X32_10 = 100, //Philox variant with N = 4, W = 32 and Rounds = 10
362 | AF_RANDOM_ENGINE_THREEFRY_2X32_16 = 200, //Threefry variant with N = 2, W = 32 and Rounds = 16
363 | AF_RANDOM_ENGINE_MERSENNE_GP11213 = 300, //Mersenne variant with MEXP = 11213
364 | AF_RANDOM_ENGINE_PHILOX = AF_RANDOM_ENGINE_PHILOX_4X32_10, //Resolves to Philox 4x32_10
365 | AF_RANDOM_ENGINE_THREEFRY = AF_RANDOM_ENGINE_THREEFRY_2X32_16, //Resolves to Threefry 2X32_16
366 | AF_RANDOM_ENGINE_MERSENNE = AF_RANDOM_ENGINE_MERSENNE_GP11213, //Resolves to Mersenne GP 11213
367 | AF_RANDOM_ENGINE_DEFAULT = AF_RANDOM_ENGINE_PHILOX //Resolves to Philox
368 | }
369 |
370 | public enum af_colormap
371 | {
372 | AF_COLORMAP_DEFAULT = 0, ///< Default grayscale map
373 | AF_COLORMAP_SPECTRUM= 1, ///< Spectrum map (390nm-830nm, in sRGB colorspace)
374 | AF_COLORMAP_COLORS = 2, ///< Colors, aka. Rainbow
375 | AF_COLORMAP_RED = 3, ///< Red hue map
376 | AF_COLORMAP_MOOD = 4, ///< Mood map
377 | AF_COLORMAP_HEAT = 5, ///< Heat map
378 | AF_COLORMAP_BLUE = 6, ///< Blue hue map
379 | AF_COLORMAP_INFERNO = 7, ///< Perceptually uniform shades of black-red-yellow
380 | AF_COLORMAP_MAGMA = 8, ///< Perceptually uniform shades of black-red-white
381 | AF_COLORMAP_PLASMA = 9, ///< Perceptually uniform shades of blue-red-yellow
382 | AF_COLORMAP_VIRIDIS = 10 ///< Perceptually uniform shades of blue-green-yellow
383 | }
384 |
385 | public enum af_marker_type
386 | {
387 | AF_MARKER_NONE = 0,
388 | AF_MARKER_POINT = 1,
389 | AF_MARKER_CIRCLE = 2,
390 | AF_MARKER_SQUARE = 3,
391 | AF_MARKER_TRIANGLE = 4,
392 | AF_MARKER_CROSS = 5,
393 | AF_MARKER_PLUS = 6,
394 | AF_MARKER_STAR = 7
395 | }
396 |
397 | public enum af_canny_threshold
398 | {
399 | AF_CANNY_THRESHOLD_MANUAL = 0, ///< User has to define canny thresholds manually
400 | AF_CANNY_THRESHOLD_AUTO_OTSU = 1, ///< Determine canny algorithm thresholds using Otsu algorithm
401 | }
402 |
403 | public enum af_storage
404 | {
405 | AF_STORAGE_DENSE = 0, ///< Storage type is dense
406 | AF_STORAGE_CSR = 1, ///< Storage type is CSR
407 | AF_STORAGE_CSC = 2, ///< Storage type is CSC
408 | AF_STORAGE_COO = 3, ///< Storage type is COO
409 | }
410 |
411 | public enum af_flux_function
412 | {
413 | AF_FLUX_QUADRATIC = 1, ///< Quadratic flux function
414 | AF_FLUX_EXPONENTIAL = 2, ///< Exponential flux function
415 | AF_FLUX_DEFAULT = 0 ///< Default flux function is exponential
416 | }
417 |
418 | public enum af_diffusion_eq
419 | {
420 | AF_DIFFUSION_GRAD = 1, ///< Gradient diffusion equation
421 | AF_DIFFUSION_MCDE = 2, ///< Modified curvature diffusion equation
422 | AF_DIFFUSION_DEFAULT = 0 ///< Default option is same as AF_DIFFUSION_GRAD
423 | }
424 |
425 | public enum af_topk_function
426 | {
427 | AF_TOPK_MIN = 1, ///< Top k min values
428 | AF_TOPK_MAX = 2, ///< Top k max values
429 | AF_TOPK_DEFAULT = 0 ///< Default option (max)
430 | }
431 | }
432 |
--------------------------------------------------------------------------------
/src/Wrapper/Interop/types.cs:
--------------------------------------------------------------------------------
1 | // This file was automatically generated using the AutoGenTool project
2 | // If possible, edit the tool instead of editing this file directly
3 |
4 | using System;
5 | using System.Text;
6 | using System.Numerics;
7 | using System.Security;
8 | using System.Runtime.InteropServices;
9 |
10 | namespace ArrayFire.Interop
11 | {
12 | internal static class af_config
13 | {
14 | internal const string dll = @"af";
15 | }
16 |
17 | [StructLayout(LayoutKind.Sequential)]
18 | public struct af_seq
19 | {
20 | public af_seq(double begin, double end, double step)
21 | {
22 | this.begin = begin;
23 | this.end = end;
24 | this.step = step;
25 | }
26 |
27 | // the C-API uses doubles so we have to do the same
28 | public double begin;
29 | public double end;
30 | public double step;
31 |
32 | public static readonly af_seq Span = new af_seq(1, 1, 0); // as defined in include/af/seq.h
33 |
34 | // implicit conversion from a number, only works in C# (not in F#)
35 | public static implicit operator af_seq(double begin) { return new af_seq(begin, begin, 1); }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Wrapper/Matrix.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 |
41 | public static class Matrix
42 | {
43 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
44 | public static Array Multiply(Array lhs, Array rhs, MatMulOp lop = MatMulOp.None, MatMulOp rop = MatMulOp.None)
45 | {
46 | IntPtr ptr;
47 | Internal.VERIFY(AFBlas.af_matmul(out ptr, lhs._ptr, rhs._ptr, (af_mat_prop)lop, (af_mat_prop)rop));
48 | return new Array(ptr);
49 | }
50 |
51 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
52 | public static void TransposeInPlace(Array arr, bool conjugate)
53 | {
54 | Internal.VERIFY(AFBlas.af_transpose_inplace(arr._ptr, conjugate));
55 | }
56 |
57 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
58 | public static Array Transpose(Array arr, bool conjugate)
59 | {
60 | IntPtr ptr;
61 | Internal.VERIFY(AFBlas.af_transpose(out ptr, arr._ptr, conjugate));
62 | return new Array(ptr);
63 | }
64 |
65 | /*
66 | public static double Det(Array arr)
67 | {
68 | double r, i;
69 | Internal.VERIFY(AFLapack.af_det(out r, out i, arr._ptr));
70 | return r;
71 | }
72 |
73 | public static float Det(Array arr)
74 | {
75 | double r, i;
76 | Internal.VERIFY(AFLapack.af_det(out r, out i, arr._ptr));
77 | return (float)r;
78 | }*/
79 |
80 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
81 | public static Complex Det(Array arr)
82 | {
83 | double r, i;
84 | Internal.VERIFY(AFLapack.af_det(out r, out i, arr._ptr));
85 | return new Complex(r, i);
86 | }
87 |
88 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
89 | public static Array Inverse(Array arr)
90 | {
91 | IntPtr ptr;
92 | Internal.VERIFY(AFLapack.af_inverse(out ptr, arr._ptr, af_mat_prop.AF_MAT_NONE));
93 | return new Array(ptr);
94 | }
95 |
96 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
97 | public static Array ExtractDiagonal(Array arr, int diagonalIndex = 0)
98 | {
99 | IntPtr ptr;
100 | Internal.VERIFY(AFData.af_diag_extract(out ptr, arr._ptr, diagonalIndex));
101 | return new Array(ptr);
102 | }
103 |
104 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
105 | public static Array CreateDiagonal(Array arr, int diagonalIndex = 0)
106 | {
107 | IntPtr ptr;
108 | Internal.VERIFY(AFData.af_diag_create(out ptr, arr._ptr, diagonalIndex));
109 | return new Array(ptr);
110 | }
111 |
112 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
113 | public static Array Lower(Array arr, bool unitDiagonal = false)
114 | {
115 | IntPtr ptr;
116 | Internal.VERIFY(AFData.af_lower(out ptr, arr._ptr, unitDiagonal));
117 | return new Array(ptr);
118 | }
119 |
120 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
121 | public static Array Upper(Array arr, bool unitDiagonal = false)
122 | {
123 | IntPtr ptr;
124 | Internal.VERIFY(AFData.af_upper(out ptr, arr._ptr, unitDiagonal));
125 | return new Array(ptr);
126 | }
127 |
128 | #region Convenience methods
129 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
130 | public static Array Identity(int dim0, int dim1) { return Data.Identity(dim0, dim1); }
131 |
132 | public static T[,] GetData(Array arr) { return Data.GetData2D(arr); }
133 | #endregion
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/src/Wrapper/Util.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | public static class Util
41 | {
42 | #region Printing
43 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
44 | public static void Print(Array arr)
45 | {
46 | Internal.VERIFY(AFUtil.af_print_array(arr._ptr));
47 | }
48 |
49 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
50 | public static void Print(Array arr, string name, int precision = 4)
51 | {
52 | Internal.VERIFY(AFUtil.af_print_array_gen(name, arr._ptr, precision));
53 | }
54 | #endregion
55 |
56 | #region Sequences
57 | public static readonly af_seq Span = af_seq.Span; // for convenience
58 |
59 | public static af_seq Seq(double begin, double end, double step = 1)
60 | {
61 | return new af_seq(begin, end, step);
62 | }
63 |
64 | public static af_seq Seq(int begin, int end, int step = 1)
65 | {
66 | return new af_seq(begin, end, step);
67 | }
68 | #endregion
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/Wrapper/Vector.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | public static class Vector
41 | {
42 | [MethodImpl(MethodImplOptions.AggressiveInlining)]
43 | public static Array Dot(Array lhs, Array rhs, bool lconj = false, bool rconj = false)
44 | {
45 | IntPtr ptr;
46 | Internal.VERIFY(AFBlas.af_dot(out ptr, lhs._ptr, rhs._ptr, lconj ? af_mat_prop.AF_MAT_CONJ : af_mat_prop.AF_MAT_NONE, rconj ? af_mat_prop.AF_MAT_CONJ : af_mat_prop.AF_MAT_NONE));
47 | return new Array(ptr);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/Wrapper/enums.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 | using System.Numerics;
34 | using System.Runtime.CompilerServices;
35 |
36 | using ArrayFire.Interop;
37 |
38 | namespace ArrayFire
39 | {
40 | public enum MatMulOp
41 | {
42 | None = af_mat_prop.AF_MAT_NONE,
43 | Transpose = af_mat_prop.AF_MAT_TRANS,
44 | ConjugateTranspose = af_mat_prop.AF_MAT_CTRANS
45 | }
46 |
47 | public enum Backend
48 | {
49 | CPU = af_backend.AF_BACKEND_CPU,
50 | CUDA = af_backend.AF_BACKEND_CUDA,
51 | DEFAULT = af_backend.AF_BACKEND_DEFAULT,
52 | OPENCL = af_backend.AF_BACKEND_OPENCL
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Wrapper/exceptions.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2015, ArrayFire
3 | Copyright (c) 2015, Steven Burns (royalstream@hotmail.com)
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of arrayfire_dotnet nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | */
31 |
32 | using System;
33 |
34 | using ArrayFire.Interop;
35 |
36 | namespace ArrayFire
37 | {
38 | public class ArrayFireException : Exception
39 | {
40 | public ArrayFireException(af_err message) : base(getError(message)) { }
41 |
42 | private static string getError(af_err err)
43 | {
44 | switch (err)
45 | {
46 | case af_err.AF_SUCCESS: return "Success";
47 | case af_err.AF_ERR_INTERNAL: return "Internal error";
48 | case af_err.AF_ERR_NO_MEM: return "Device out of memory";
49 | case af_err.AF_ERR_DRIVER: return "Driver not available or incompatible";
50 | case af_err.AF_ERR_RUNTIME: return "Runtime error ";
51 | case af_err.AF_ERR_INVALID_ARRAY: return "Invalid array";
52 | case af_err.AF_ERR_ARG: return "Invalid input argument";
53 | case af_err.AF_ERR_SIZE: return "Invalid input size";
54 | case af_err.AF_ERR_DIFF_TYPE: return "Input types are not the same";
55 | case af_err.AF_ERR_NOT_SUPPORTED: return "Function not supported";
56 | case af_err.AF_ERR_NOT_CONFIGURED: return "Function not configured to build";
57 | case af_err.AF_ERR_TYPE: return "Function does not support this data type";
58 | case af_err.AF_ERR_NO_DBL: return "Double precision not supported for this device";
59 | case af_err.AF_ERR_LOAD_LIB: return "Failed to load dynamic library";
60 | case af_err.AF_ERR_LOAD_SYM: return "Failed to load symbol";
61 | case af_err.AF_ERR_UNKNOWN: return "Unknown error";
62 | default: return err.ToString();
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/test/ArrayFire.UnitTest/ArrayFire.UnitTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.2
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/ArrayFire.UnitTest/ArrayTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 |
3 | namespace ArrayFire.UnitTest
4 | {
5 | ///
6 | /// port from test\array.cpp
7 | ///
8 | [TestClass]
9 | public class ArrayTest : UnitTestBase
10 | {
11 | [TestMethod]
12 | public void Creation()
13 | {
14 | var A = Data.Range(2, 2);
15 | Util.Print(A, "A");
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/ArrayFire.UnitTest/UnitTestBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace ArrayFire.UnitTest
6 | {
7 | public class UnitTestBase
8 | {
9 | public UnitTestBase()
10 | {
11 | Device.SetBackend(Backend.DEFAULT);
12 | Device.PrintInfo();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------