@@ -373,8 +373,98 @@ public unsafe Vector(T value)
373
373
/// <summary>
374
374
/// Constructs a vector from the given array. The size of the given array must be at least Vector'T.Count.
375
375
/// </summary>
376
- [ Intrinsic ]
377
- public unsafe Vector ( T [ ] values ) : this ( values , 0 ) { }
376
+ public unsafe Vector ( T [ ] values ) : this ( )
377
+ {
378
+ if ( values == null )
379
+ {
380
+ // Match the JIT's exception type here. For perf, a NullReference is thrown instead of an ArgumentNull.
381
+ throw new NullReferenceException ( SR . Arg_NullArgumentNullRef ) ;
382
+ }
383
+ if ( typeof ( T ) == typeof ( Byte ) )
384
+ {
385
+ if ( values . Length < Count )
386
+ {
387
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
388
+ }
389
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
390
+ }
391
+ else if ( typeof ( T ) == typeof ( SByte ) )
392
+ {
393
+ if ( values . Length < Count )
394
+ {
395
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
396
+ }
397
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
398
+ }
399
+ else if ( typeof ( T ) == typeof ( UInt16 ) )
400
+ {
401
+ if ( values . Length < Count )
402
+ {
403
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
404
+ }
405
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
406
+ }
407
+ else if ( typeof ( T ) == typeof ( Int16 ) )
408
+ {
409
+ if ( values . Length < Count )
410
+ {
411
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
412
+ }
413
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
414
+ }
415
+ else if ( typeof ( T ) == typeof ( UInt32 ) )
416
+ {
417
+ if ( values . Length < Count )
418
+ {
419
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
420
+ }
421
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
422
+ }
423
+ else if ( typeof ( T ) == typeof ( Int32 ) )
424
+ {
425
+ if ( values . Length < Count )
426
+ {
427
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
428
+ }
429
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
430
+ }
431
+ else if ( typeof ( T ) == typeof ( UInt64 ) )
432
+ {
433
+ if ( values . Length < Count )
434
+ {
435
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
436
+ }
437
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
438
+ }
439
+ else if ( typeof ( T ) == typeof ( Int64 ) )
440
+ {
441
+ if ( values . Length < Count )
442
+ {
443
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
444
+ }
445
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
446
+ }
447
+ else if ( typeof ( T ) == typeof ( Single ) )
448
+ {
449
+ if ( values . Length < Count )
450
+ {
451
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
452
+ }
453
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
454
+ }
455
+ else if ( typeof ( T ) == typeof ( Double ) )
456
+ {
457
+ if ( values . Length < Count )
458
+ {
459
+ throw new IndexOutOfRangeException ( SR . Format ( SR . Arg_InsufficientNumberOfElements , Vector < T > . Count , nameof ( values ) ) ) ;
460
+ }
461
+ this = Unsafe . ReadUnaligned < Vector < T > > ( ref values . GetRawSzArrayData ( ) ) ;
462
+ }
463
+ else
464
+ {
465
+ throw new NotSupportedException ( SR . Arg_TypeNotSupported ) ;
466
+ }
467
+ }
378
468
379
469
/// <summary>
380
470
/// Constructs a vector from the given array, starting from the given index.
0 commit comments