@@ -281,73 +281,156 @@ public float[] ToArray()
281281 /// </summary>
282282 /// <param name="value">The value to multiply by.</param>
283283 [ MethodImpl ( InliningOptions . ShortMethod ) ]
284- public void MultiplyInplace ( float value )
285- {
286- this . V0L *= value ;
287- this . V0R *= value ;
288- this . V1L *= value ;
289- this . V1R *= value ;
290- this . V2L *= value ;
291- this . V2R *= value ;
292- this . V3L *= value ;
293- this . V3R *= value ;
294- this . V4L *= value ;
295- this . V4R *= value ;
296- this . V5L *= value ;
297- this . V5R *= value ;
298- this . V6L *= value ;
299- this . V6R *= value ;
300- this . V7L *= value ;
301- this . V7R *= value ;
284+ public void MultiplyInPlace ( float value )
285+ {
286+ #if SUPPORTS_RUNTIME_INTRINSICS
287+ if ( Avx . IsSupported )
288+ {
289+ var valueVec = Vector256 . Create ( value ) ;
290+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) , valueVec ) ;
291+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) , valueVec ) ;
292+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) , valueVec ) ;
293+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) , valueVec ) ;
294+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) , valueVec ) ;
295+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) , valueVec ) ;
296+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) , valueVec ) ;
297+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) = Avx. Multiply ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) , valueVec ) ;
298+ }
299+ else
300+ #endif
301+ {
302+ var valueVec = new Vector4 ( value ) ;
303+ this . V0L *= valueVec ;
304+ this . V0R *= valueVec ;
305+ this . V1L *= valueVec ;
306+ this . V1R *= valueVec ;
307+ this . V2L *= valueVec ;
308+ this . V2R *= valueVec ;
309+ this . V3L *= valueVec ;
310+ this . V3R *= valueVec ;
311+ this . V4L *= valueVec ;
312+ this . V4R *= valueVec ;
313+ this . V5L *= valueVec ;
314+ this . V5R *= valueVec ;
315+ this . V6L *= valueVec ;
316+ this . V6R *= valueVec ;
317+ this . V7L *= valueVec ;
318+ this . V7R *= valueVec ;
319+ }
302320 }
303321
304322 /// <summary>
305323 /// Multiply all elements of the block by the corresponding elements of 'other'.
306324 /// </summary>
307325 [ MethodImpl ( InliningOptions . ShortMethod ) ]
308- public void MultiplyInplace ( ref Block8x8F other )
309- {
310- this . V0L *= other . V0L ;
311- this . V0R *= other . V0R ;
312- this . V1L *= other . V1L ;
313- this . V1R *= other . V1R ;
314- this . V2L *= other . V2L ;
315- this . V2R *= other . V2R ;
316- this . V3L *= other . V3L ;
317- this . V3R *= other . V3R ;
318- this . V4L *= other . V4L ;
319- this . V4R *= other . V4R ;
320- this . V5L *= other . V5L ;
321- this . V5R *= other . V5R ;
322- this . V6L *= other . V6L ;
323- this . V6R *= other . V6R ;
324- this . V7L *= other . V7L ;
325- this . V7R *= other . V7R ;
326+ public unsafe void MultiplyInPlace ( ref Block8x8F other )
327+ {
328+ #if SUPPORTS_RUNTIME_INTRINSICS
329+ if ( Avx . IsSupported )
330+ {
331+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L )
332+ = Avx. Multiply (
333+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) ,
334+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V0L ) ) ;
335+
336+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L )
337+ = Avx. Multiply (
338+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) ,
339+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V1L ) ) ;
340+
341+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L )
342+ = Avx. Multiply (
343+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) ,
344+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V2L ) ) ;
345+
346+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L )
347+ = Avx. Multiply (
348+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) ,
349+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V3L ) ) ;
350+
351+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L )
352+ = Avx. Multiply (
353+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) ,
354+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V4L ) ) ;
355+
356+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L )
357+ = Avx. Multiply (
358+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) ,
359+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V5L ) ) ;
360+
361+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L )
362+ = Avx. Multiply (
363+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) ,
364+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V6L ) ) ;
365+
366+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L )
367+ = Avx. Multiply (
368+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) ,
369+ Unsafe . As < Vector4 , Vector256 < float > > ( ref other . V7L ) ) ;
370+ }
371+ else
372+ #endif
373+ {
374+ this . V0L *= other . V0L ;
375+ this . V0R *= other . V0R ;
376+ this . V1L *= other . V1L ;
377+ this . V1R *= other . V1R ;
378+ this . V2L *= other . V2L ;
379+ this . V2R *= other . V2R ;
380+ this . V3L *= other . V3L ;
381+ this . V3R *= other . V3R ;
382+ this . V4L *= other . V4L ;
383+ this . V4R *= other . V4R ;
384+ this . V5L *= other . V5L ;
385+ this . V5R *= other . V5R ;
386+ this . V6L *= other . V6L ;
387+ this . V6R *= other . V6R ;
388+ this . V7L *= other . V7L ;
389+ this . V7R *= other . V7R ;
390+ }
326391 }
327392
328393 /// <summary>
329394 /// Adds a vector to all elements of the block.
330395 /// </summary>
331- /// <param name="diff ">The added vector</param>
396+ /// <param name="value ">The added vector. </param>
332397 [ MethodImpl ( InliningOptions . ShortMethod ) ]
333- public void AddToAllInplace ( Vector4 diff )
334- {
335- this . V0L += diff ;
336- this . V0R += diff ;
337- this . V1L += diff ;
338- this . V1R += diff ;
339- this . V2L += diff ;
340- this . V2R += diff ;
341- this . V3L += diff ;
342- this . V3R += diff ;
343- this . V4L += diff ;
344- this . V4R += diff ;
345- this . V5L += diff ;
346- this . V5R += diff ;
347- this . V6L += diff ;
348- this . V6R += diff ;
349- this . V7L += diff ;
350- this . V7R += diff ;
398+ public void AddInPlace ( float value )
399+ {
400+ #if SUPPORTS_RUNTIME_INTRINSICS
401+ if ( Avx . IsSupported )
402+ {
403+ var valueVec = Vector256 . Create ( value ) ;
404+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) , valueVec ) ;
405+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) , valueVec ) ;
406+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) , valueVec ) ;
407+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) , valueVec ) ;
408+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) , valueVec ) ;
409+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) , valueVec ) ;
410+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) , valueVec ) ;
411+ Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) = Avx. Add ( Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) , valueVec ) ;
412+ }
413+ else
414+ #endif
415+ {
416+ var valueVec = new Vector4 ( value ) ;
417+ this . V0L += valueVec ;
418+ this . V0R += valueVec ;
419+ this . V1L += valueVec ;
420+ this . V1R += valueVec ;
421+ this . V2L += valueVec ;
422+ this . V2R += valueVec ;
423+ this . V3L += valueVec ;
424+ this . V3R += valueVec ;
425+ this . V4L += valueVec ;
426+ this . V4R += valueVec ;
427+ this . V5L += valueVec ;
428+ this . V5R += valueVec ;
429+ this . V6L += valueVec ;
430+ this . V6R += valueVec ;
431+ this . V7L += valueVec ;
432+ this . V7R += valueVec ;
433+ }
351434 }
352435
353436 /// <summary>
@@ -468,23 +551,23 @@ public Block8x8 RoundAsInt16Block()
468551 /// <summary>
469552 /// Level shift by +maximum/2, clip to [0..maximum], and round all the values in the block.
470553 /// </summary>
471- public void NormalizeColorsAndRoundInplace ( float maximum )
554+ public void NormalizeColorsAndRoundInPlace ( float maximum )
472555 {
473556 if ( SimdUtils . HasVector8 )
474557 {
475- this . NormalizeColorsAndRoundInplaceVector8 ( maximum ) ;
558+ this . NormalizeColorsAndRoundInPlaceVector8 ( maximum ) ;
476559 }
477560 else
478561 {
479- this . NormalizeColorsInplace ( maximum ) ;
480- this . RoundInplace ( ) ;
562+ this . NormalizeColorsInPlace ( maximum ) ;
563+ this . RoundInPlace ( ) ;
481564 }
482565 }
483566
484567 /// <summary>
485568 /// Rounds all values in the block.
486569 /// </summary>
487- public void RoundInplace ( )
570+ public void RoundInPlace ( )
488571 {
489572 for ( int i = 0 ; i < Size ; i ++ )
490573 {
0 commit comments