File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ namespace NumSharp.Core
3030{
3131 public partial class NDArray
3232 {
33+ public static implicit operator float ( NDArray nd )
34+ {
35+ if ( nd . ndim > 0 )
36+ throw new IncorrectShapeException ( ) ;
37+
38+ return nd . Data < float > ( 0 ) ;
39+ }
40+
3341 public static implicit operator NDArray ( float d )
3442 {
3543 var ndArray = new NDArray ( typeof ( float ) , new int [ 0 ] ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ public override string ToString()
2121 case "Int32" :
2222 output = Data < int > ( ) [ 0 ] . ToString ( ) ;
2323 break ;
24+ case "Single" :
25+ output = Data < float > ( ) [ 0 ] . ToString ( ) ;
26+ break ;
2427 case "Double" :
2528 output = Data < double > ( ) [ 0 ] . ToString ( ) ;
2629 break ;
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ public partial class NDArray : ICloneable
6666 /// <returns></returns>
6767 public T [ ] Data < T > ( ) => Storage . GetData < T > ( ) ;
6868
69+ public T Data < T > ( int index ) => Storage . GetData < T > ( ) [ index ] ;
70+
6971 public Array Data ( ) => Storage . GetData ( dtype ) ;
7072
7173 /// <summary>
You can’t perform that action at this time.
0 commit comments