386 }
387
388 public IntVector<S> ashiftR(Vector<Integer,S> o) {
389 return bOp(o, (i, a, b) -> (int) (a >> b));
390 }
391
392 public IntVector<S> ashiftR(Vector<Integer,S> o, Mask<Integer, S> m) {
393 return bOp(o, m, (i, a, b) -> (int) (a >> b));
394 }
395
396 public IntVector<S> rotateL(int j) {
397 return uOp((i, a) -> (int) Integer.rotateLeft(a, j));
398 }
399
400 public IntVector<S> rotateR(int j) {
401 return uOp((i, a) -> (int) Integer.rotateRight(a, j));
402 }
403
404 @Override
405 public void intoByteArray(byte[] a, int ix) {
406 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix);
407 intoByteBuffer(bb);
408 }
409
410 @Override
411 public void intoByteArray(byte[] a, int ix, Mask<Integer, S> m) {
412 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix);
413 intoByteBuffer(bb, m);
414 }
415
416 @Override
417 public void intoByteBuffer(ByteBuffer bb) {
418 IntBuffer fb = bb.asIntBuffer();
419 forEach((i, a) -> fb.put(a));
420 }
421
422 @Override
423 public void intoByteBuffer(ByteBuffer bb, Mask<Integer, S> m) {
424 IntBuffer fb = bb.asIntBuffer();
425 forEach((i, a) -> {
426 if (m.getElement(i))
427 fb.put(a);
428 else
429 fb.position(fb.position() + 1);
430 });
431 }
432
777 *
778 * @param a the array
779 * @param i the offset into the array, may be negative if relative
780 * indexes in the index map compensate to produce a value within the
781 * array bounds
782 * @param indexMap the index map
783 * @param j the offset into the index map
784 * @return the vector loaded from an array
785 * @throws IndexOutOfBoundsException if {@code j < 0}, or
786 * {@code j > indexMap.length - this.length()},
787 * or for any vector lane index {@code N} where the mask at lane
788 * {@code N} is set the result of {@code i + indexMap[j + N]} is
789 * {@code < 0} or {@code >= a.length}
790 */
791 public IntVector<S> fromArray(int[] a, int i, Mask<Integer, S> m, int[] indexMap, int j) {
792 return op(m, n -> a[i + indexMap[j + n]]);
793 }
794
795 @Override
796 public IntVector<S> fromByteArray(byte[] a, int ix) {
797 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix);
798 return fromByteBuffer(bb);
799 }
800
801 @Override
802 public IntVector<S> fromByteArray(byte[] a, int ix, Mask<Integer, S> m) {
803 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix);
804 return fromByteBuffer(bb, m);
805 }
806
807 @Override
808 public IntVector<S> fromByteBuffer(ByteBuffer bb) {
809 IntBuffer fb = bb.asIntBuffer();
810 return op(i -> fb.get());
811 }
812
813 @Override
814 public IntVector<S> fromByteBuffer(ByteBuffer bb, Mask<Integer, S> m) {
815 IntBuffer fb = bb.asIntBuffer();
816 return op(i -> {
817 if(m.getElement(i))
818 return fb.get();
819 else {
820 fb.position(fb.position() + 1);
821 return (int) 0;
822 }
823 });
824 }
825
826 @Override
827 public IntVector<S> fromByteBuffer(ByteBuffer bb, int ix) {
828 bb = bb.duplicate().position(ix);
829 IntBuffer fb = bb.asIntBuffer();
830 return op(i -> fb.get(i));
831 }
832
833 @Override
834 public IntVector<S> fromByteBuffer(ByteBuffer bb, int ix, Mask<Integer, S> m) {
835 bb = bb.duplicate().position(ix);
836 IntBuffer fb = bb.asIntBuffer();
837 return op(m, i -> fb.get(i));
838 }
839
840 @Override
841 public <F, T extends Shape> IntVector<S> reshape(Vector<F, T> o) {
842 int blen = Math.max(o.species().bitSize(), bitSize()) / Byte.SIZE;
843 ByteBuffer bb = ByteBuffer.allocate(blen).order(ByteOrder.nativeOrder());
844 o.intoByteBuffer(bb, 0);
845 return fromByteBuffer(bb, 0);
846 }
847
848 @Override
849 @ForceInline
850 public <F> IntVector<S> rebracket(Vector<F, S> o) {
851 return reshape(o);
852 }
853
854 @Override
855 @ForceInline
|
386 }
387
388 public IntVector<S> ashiftR(Vector<Integer,S> o) {
389 return bOp(o, (i, a, b) -> (int) (a >> b));
390 }
391
392 public IntVector<S> ashiftR(Vector<Integer,S> o, Mask<Integer, S> m) {
393 return bOp(o, m, (i, a, b) -> (int) (a >> b));
394 }
395
396 public IntVector<S> rotateL(int j) {
397 return uOp((i, a) -> (int) Integer.rotateLeft(a, j));
398 }
399
400 public IntVector<S> rotateR(int j) {
401 return uOp((i, a) -> (int) Integer.rotateRight(a, j));
402 }
403
404 @Override
405 public void intoByteArray(byte[] a, int ix) {
406 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix).order(ByteOrder.nativeOrder());
407 intoByteBuffer(bb);
408 }
409
410 @Override
411 public void intoByteArray(byte[] a, int ix, Mask<Integer, S> m) {
412 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix).order(ByteOrder.nativeOrder());
413 intoByteBuffer(bb, m);
414 }
415
416 @Override
417 public void intoByteBuffer(ByteBuffer bb) {
418 IntBuffer fb = bb.asIntBuffer();
419 forEach((i, a) -> fb.put(a));
420 }
421
422 @Override
423 public void intoByteBuffer(ByteBuffer bb, Mask<Integer, S> m) {
424 IntBuffer fb = bb.asIntBuffer();
425 forEach((i, a) -> {
426 if (m.getElement(i))
427 fb.put(a);
428 else
429 fb.position(fb.position() + 1);
430 });
431 }
432
777 *
778 * @param a the array
779 * @param i the offset into the array, may be negative if relative
780 * indexes in the index map compensate to produce a value within the
781 * array bounds
782 * @param indexMap the index map
783 * @param j the offset into the index map
784 * @return the vector loaded from an array
785 * @throws IndexOutOfBoundsException if {@code j < 0}, or
786 * {@code j > indexMap.length - this.length()},
787 * or for any vector lane index {@code N} where the mask at lane
788 * {@code N} is set the result of {@code i + indexMap[j + N]} is
789 * {@code < 0} or {@code >= a.length}
790 */
791 public IntVector<S> fromArray(int[] a, int i, Mask<Integer, S> m, int[] indexMap, int j) {
792 return op(m, n -> a[i + indexMap[j + n]]);
793 }
794
795 @Override
796 public IntVector<S> fromByteArray(byte[] a, int ix) {
797 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix).order(ByteOrder.nativeOrder());
798 return fromByteBuffer(bb);
799 }
800
801 @Override
802 public IntVector<S> fromByteArray(byte[] a, int ix, Mask<Integer, S> m) {
803 ByteBuffer bb = ByteBuffer.wrap(a, ix, a.length - ix).order(ByteOrder.nativeOrder());
804 return fromByteBuffer(bb, m);
805 }
806
807 @Override
808 public IntVector<S> fromByteBuffer(ByteBuffer bb) {
809 IntBuffer fb = bb.asIntBuffer();
810 return op(i -> fb.get());
811 }
812
813 @Override
814 public IntVector<S> fromByteBuffer(ByteBuffer bb, Mask<Integer, S> m) {
815 IntBuffer fb = bb.asIntBuffer();
816 return op(i -> {
817 if(m.getElement(i))
818 return fb.get();
819 else {
820 fb.position(fb.position() + 1);
821 return (int) 0;
822 }
823 });
824 }
825
826 @Override
827 public IntVector<S> fromByteBuffer(ByteBuffer bb, int ix) {
828 bb = bb.duplicate().order(ByteOrder.nativeOrder()).position(ix);
829 IntBuffer fb = bb.asIntBuffer();
830 return op(i -> fb.get(i));
831 }
832
833 @Override
834 public IntVector<S> fromByteBuffer(ByteBuffer bb, int ix, Mask<Integer, S> m) {
835 bb = bb.duplicate().order(ByteOrder.nativeOrder()).position(ix);
836 IntBuffer fb = bb.asIntBuffer();
837 return op(m, i -> fb.get(i));
838 }
839
840 @Override
841 public <F, T extends Shape> IntVector<S> reshape(Vector<F, T> o) {
842 int blen = Math.max(o.species().bitSize(), bitSize()) / Byte.SIZE;
843 ByteBuffer bb = ByteBuffer.allocate(blen).order(ByteOrder.nativeOrder());
844 o.intoByteBuffer(bb, 0);
845 return fromByteBuffer(bb, 0);
846 }
847
848 @Override
849 @ForceInline
850 public <F> IntVector<S> rebracket(Vector<F, S> o) {
851 return reshape(o);
852 }
853
854 @Override
855 @ForceInline
|