|
| 1 | +/* |
| 2 | + * NumSharp |
| 3 | + * Copyright (C) 2018 Haiping Chen |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the Apache License 2.0 as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the Apache License 2.0 |
| 16 | + * along with this program. If not, see <http://www.apache.org/licenses/LICENSE-2.0/>. |
| 17 | + */ |
| 18 | + |
| 19 | +using System; |
| 20 | +using System.Collections.Generic; |
| 21 | +using System.ComponentModel; |
| 22 | +using System.Linq; |
| 23 | +using System.Text; |
| 24 | +using System.Globalization; |
| 25 | +using System.Collections; |
| 26 | +using NumSharp.Core; |
| 27 | +using System.Numerics; |
| 28 | + |
| 29 | +namespace NumSharp.Core |
| 30 | +{ |
| 31 | + public partial class NDArray |
| 32 | + { |
| 33 | + |
| 34 | + public static implicit operator NDArray(double d) |
| 35 | + { |
| 36 | + var ndArray = new NDArray(typeof(double),new int[0]); |
| 37 | + ndArray.Storage.SetData(new double[]{d}); |
| 38 | + |
| 39 | + return ndArray; |
| 40 | + } |
| 41 | + public static implicit operator NDArray(int d) |
| 42 | + { |
| 43 | + var ndArray = new NDArray(typeof(int),new int[0]); |
| 44 | + ndArray.Storage.SetData(new int[]{d}); |
| 45 | + |
| 46 | + return ndArray; |
| 47 | + } |
| 48 | + public static implicit operator NDArray(Int64 d) |
| 49 | + { |
| 50 | + var ndArray = new NDArray(typeof(Int64),new int[0]); |
| 51 | + ndArray.Storage.SetData(new Int64[]{d}); |
| 52 | + |
| 53 | + return ndArray; |
| 54 | + } |
| 55 | + public static implicit operator NDArray(Complex d) |
| 56 | + { |
| 57 | + var ndArray = new NDArray(typeof(Complex),new int[0]); |
| 58 | + ndArray.Storage.SetData(new Complex[]{d}); |
| 59 | + |
| 60 | + return ndArray; |
| 61 | + } |
| 62 | + public static implicit operator NDArray(Quaternion d) |
| 63 | + { |
| 64 | + var ndArray = new NDArray(typeof(Quaternion),new int[0]); |
| 65 | + ndArray.Storage.SetData(new Quaternion[]{d}); |
| 66 | + |
| 67 | + return ndArray; |
| 68 | + } |
| 69 | + |
| 70 | + } |
| 71 | +} |
0 commit comments