Skip to content

Commit 0817001

Browse files
committed
int divid ndarray
1 parent e6f2c3d commit 0817001

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/NumSharp.Core/Operations/NdArray.Division.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,29 @@ public partial class NDArray
103103

104104
return sum;
105105
}
106-
106+
107+
public static NDArray operator /(int scalar, NDArray np1)
108+
{
109+
return (double)scalar / np1;
110+
}
111+
112+
public static NDArray operator /(double scalar, NDArray np1)
113+
{
114+
var nd = new NDArray(typeof(double), np1.shape);
115+
116+
switch (np1.dtype.Name)
117+
{
118+
case "Double":
119+
nd.Set(np1.float64.Select(x => scalar / x).ToArray());
120+
break;
121+
case "Int32":
122+
nd.Set(np1.int32.Select(x => scalar / x).ToArray());
123+
break;
124+
}
125+
126+
return nd;
127+
}
128+
129+
107130
}
108131
}

0 commit comments

Comments
 (0)