File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 18
18
<PackageReleaseNotes >初始化版本。添加 hex,bin,print 函数</PackageReleaseNotes >
19
19
</PropertyGroup >
20
20
21
+ <ItemGroup >
22
+ <PackageReference Include =" pythonnet" Version =" 3.0.1" />
23
+ </ItemGroup >
24
+
21
25
<ItemGroup >
22
26
<None Update =" S.System.png" >
23
27
<Pack >True</Pack >
Original file line number Diff line number Diff line change 1
- using System ;
1
+ using System ;
2
2
using System . Collections ;
3
3
using System . IO ;
4
4
using System . Linq ;
11
11
using static System . Numerics . Complex ;
12
12
using static System . Numerics . BigInteger ;
13
13
14
+ using Python . Runtime ;
15
+ using static Python . Runtime . Runtime ;
16
+ using static Python . Runtime . Py ;
17
+ using static Python . Runtime . PythonEngine ;
14
18
15
19
namespace S
16
20
{
@@ -133,6 +137,21 @@ public static double Abs(Complex num)
133
137
return Abs ( num . Magnitude ) ;
134
138
}
135
139
140
+ /// <summary>
141
+ /// 仅支持复数类型
142
+ /// </summary>
143
+ /// <param name="num"></param>
144
+ /// <returns></returns>
145
+ public static double Abs ( PyObject num )
146
+ {
147
+ using ( GIL ( ) )
148
+ {
149
+ var c = num . As < Complex > ( ) ;
150
+ return Abs ( c . Magnitude ) ;
151
+ }
152
+ }
153
+
154
+
136
155
[ Obsolete ( "This method is deprecated, use `Abs` instead." ) ]
137
156
public static double abs ( Complex num ) => Abs ( num ) ;
138
157
You can’t perform that action at this time.
0 commit comments