11// See https://aka.ms/new-console-template for more information
2- using SmartVectorDotNet ;
32
4- int [ ] x = [ .. Enumerable . Range ( 0 , 1000 ) . Select ( i => ( int ) i ) ] ;
5- var y = new int [ x . Length ] ;
6- var z = new int [ x . Length ] ;
7- var vectorization = new InterceptVectorization ( Console . Out ) ;
8-
9- vectorization . Calculate (
10- static x => x * x ,
11- x . AsSpan ( ) ,
12- y . AsSpan ( )
13- ) ;
14-
15- vectorization . Calculate (
16- static ( x , y ) => ScalarOp . Add ( x , y ) ,
17- x . AsSpan ( ) ,
18- y . AsSpan ( ) ,
19- z . AsSpan ( )
20- ) ;
21-
22- Console . WriteLine ( string . Join ( ", " , z . Take ( 10 ) ) ) ;
23-
24-
25- class InterceptVectorization ( TextWriter logger ) : SimdVectorization
26- {
27- protected override void CalculateCore < T , TFormula > ( TFormula formula , ReadOnlySpan < T > x1 , Span < T > ans )
28- {
29- logger . WriteLine ( "Intercepterd by CalculateCore`2(formula, x1, ans)" ) ;
30- base . CalculateCore ( formula , x1 , ans ) ;
31- }
32-
33- protected override void CalculateCore < T , TFormula > ( TFormula formula , ReadOnlySpan < T > x1 , ReadOnlySpan < T > x2 , Span < T > ans )
34- {
35- logger . WriteLine ( "Intercepterd by CalculateCore`2(formula, x1, x2, ans)" ) ;
36- base . CalculateCore ( formula , x1 , x2 , ans ) ;
37- }
38- }
3+ new GeneralizeMathFunc ( ) . Run ( Console . Out ) ;
4+ new VoctorizeSimply ( ) . Run ( Console . Out ) ;
5+ new CalculateVectorized ( ) . Run ( Console . Out ) ;
6+ new CalculateVectorizedInterceptor ( ) . Run ( Console . Out ) ;
0 commit comments