|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 |
| -using System.Diagnostics; |
5 | 4 | using System.Runtime.Intrinsics;
|
6 | 5 |
|
7 | 6 | namespace System.Numerics.Tensors
|
@@ -30,109 +29,12 @@ public static void SinCos<T>(ReadOnlySpan<T> x, Span<T> sinDestination, Span<T>
|
30 | 29 | /// <summary>T.SinCos(x)</summary>
|
31 | 30 | private readonly struct SinCosOperator<T> : IUnaryInputBinaryOutput<T> where T : ITrigonometricFunctions<T>
|
32 | 31 | {
|
33 |
| - public static bool Vectorizable => (typeof(T) == typeof(float)) |
34 |
| - || (typeof(T) == typeof(double)); |
| 32 | + public static bool Vectorizable => false; // TODO: vectorize |
35 | 33 |
|
36 | 34 | public static (T, T) Invoke(T x) => T.SinCos(x);
|
37 |
| - |
38 |
| - public static (Vector128<T> First, Vector128<T> Second) Invoke(Vector128<T> x) |
39 |
| - { |
40 |
| -#if NET9_0_OR_GREATER |
41 |
| - if (typeof(T) == typeof(double)) |
42 |
| - { |
43 |
| - (Vector128<double> sin, Vector128<double> cos) = Vector128.SinCos(x.AsDouble()); |
44 |
| - return (sin.As<double, T>(), cos.As<double, T>()); |
45 |
| - } |
46 |
| - else |
47 |
| - { |
48 |
| - Debug.Assert(typeof(T) == typeof(float)); |
49 |
| - (Vector128<float> sin, Vector128<float> cos) = Vector128.SinCos(x.AsSingle()); |
50 |
| - return (sin.As<float, T>(), cos.As<float, T>()); |
51 |
| - } |
52 |
| -#else |
53 |
| - if (typeof(T) == typeof(float)) |
54 |
| - { |
55 |
| - return ( |
56 |
| - SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(), |
57 |
| - CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>() |
58 |
| - ); |
59 |
| - } |
60 |
| - else |
61 |
| - { |
62 |
| - Debug.Assert(typeof(T) == typeof(double)); |
63 |
| - return ( |
64 |
| - SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(), |
65 |
| - CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>() |
66 |
| - ); |
67 |
| - } |
68 |
| -#endif |
69 |
| - } |
70 |
| - |
71 |
| - public static (Vector256<T> First, Vector256<T> Second) Invoke(Vector256<T> x) |
72 |
| - { |
73 |
| -#if NET9_0_OR_GREATER |
74 |
| - if (typeof(T) == typeof(double)) |
75 |
| - { |
76 |
| - (Vector256<double> sin, Vector256<double> cos) = Vector256.SinCos(x.AsDouble()); |
77 |
| - return (sin.As<double, T>(), cos.As<double, T>()); |
78 |
| - } |
79 |
| - else |
80 |
| - { |
81 |
| - Debug.Assert(typeof(T) == typeof(float)); |
82 |
| - (Vector256<float> sin, Vector256<float> cos) = Vector256.SinCos(x.AsSingle()); |
83 |
| - return (sin.As<float, T>(), cos.As<float, T>()); |
84 |
| - } |
85 |
| -#else |
86 |
| - if (typeof(T) == typeof(float)) |
87 |
| - { |
88 |
| - return ( |
89 |
| - SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(), |
90 |
| - CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>() |
91 |
| - ); |
92 |
| - } |
93 |
| - else |
94 |
| - { |
95 |
| - Debug.Assert(typeof(T) == typeof(double)); |
96 |
| - return ( |
97 |
| - SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(), |
98 |
| - CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>() |
99 |
| - ); |
100 |
| - } |
101 |
| -#endif |
102 |
| - } |
103 |
| - |
104 |
| - public static (Vector512<T> First, Vector512<T> Second) Invoke(Vector512<T> x) |
105 |
| - { |
106 |
| -#if NET9_0_OR_GREATER |
107 |
| - if (typeof(T) == typeof(double)) |
108 |
| - { |
109 |
| - (Vector512<double> sin, Vector512<double> cos) = Vector512.SinCos(x.AsDouble()); |
110 |
| - return (sin.As<double, T>(), cos.As<double, T>()); |
111 |
| - } |
112 |
| - else |
113 |
| - { |
114 |
| - Debug.Assert(typeof(T) == typeof(float)); |
115 |
| - (Vector512<float> sin, Vector512<float> cos) = Vector512.SinCos(x.AsSingle()); |
116 |
| - return (sin.As<float, T>(), cos.As<float, T>()); |
117 |
| - } |
118 |
| -#else |
119 |
| - if (typeof(T) == typeof(float)) |
120 |
| - { |
121 |
| - return ( |
122 |
| - SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(), |
123 |
| - CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>() |
124 |
| - ); |
125 |
| - } |
126 |
| - else |
127 |
| - { |
128 |
| - Debug.Assert(typeof(T) == typeof(double)); |
129 |
| - return ( |
130 |
| - SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(), |
131 |
| - CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>() |
132 |
| - ); |
133 |
| - } |
134 |
| -#endif |
135 |
| - } |
| 35 | + public static (Vector128<T> First, Vector128<T> Second) Invoke(Vector128<T> x) => throw new NotSupportedException(); |
| 36 | + public static (Vector256<T> First, Vector256<T> Second) Invoke(Vector256<T> x) => throw new NotSupportedException(); |
| 37 | + public static (Vector512<T> First, Vector512<T> Second) Invoke(Vector512<T> x) => throw new NotSupportedException(); |
136 | 38 | }
|
137 | 39 | }
|
138 | 40 | }
|
0 commit comments