< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java

Print this page




 543      * equal to the given vector
 544      */
 545     public abstract VectorMask<E> greaterThanEq(Vector<E> v);
 546 
 547     // Elemental shifting
 548 
 549     /**
 550      * Rotates left the lane elements of this vector by the given number of
 551      * lanes, {@code i}, modulus the vector length.
 552      * <p>
 553      * This is a cross-lane operation that permutes the lane elements of this
 554      * vector.
 555      * For each lane of the input vector, at lane index {@code N}, the lane
 556      * element is placed into the result vector at lane index
 557      * {@code (N + i) % length()}.
 558      *
 559      * @param i the number of lanes to rotate left
 560      * @return the result of rotating left lane elements of this vector by the
 561      * given number of lanes
 562      */
 563     public abstract Vector<E> rotateEL(int i);
 564 
 565     /**
 566      * Rotates right the lane elements of this vector by the given number of
 567      * lanes, {@code i}, modulus the vector length.
 568      * <p>
 569      * This is a cross-lane operation that permutes the lane elements of this
 570      * vector.
 571      * For each lane of the input vector, at lane index {@code N}, the lane
 572      * element is placed into the result vector at lane index
 573      * {@code (N + length() - (i % length())) % length()}
 574      *
 575      * @param i the number of lanes to rotate left
 576      * @return the result of rotating right lane elements of this vector by the
 577      * given number of lanes
 578      */
 579     public abstract Vector<E> rotateER(int i);
 580 
 581     /**
 582      * Shift left the lane elements of this vector by the given number of
 583      * lanes, {@code i}, modulus the vector length.
 584      * <p>
 585      * This is a cross-lane operation that permutes the lane elements of this
 586      * vector and behaves as if rotating left the lane elements by {@code i},
 587      * and then the zero value is placed into the result vector at lane indexes
 588      * less than {@code i % length()}.
 589      *
 590      * @param i the number of lanes to shift left
 591      * @return the result of shifting left lane elements of this vector by the
 592      * given number of lanes
 593      * @throws IllegalArgumentException if {@code i} is {@code < 0}.
 594      */
 595     public abstract Vector<E> shiftEL(int i);
 596 
 597     /**
 598      * Shift right the lane elements of this vector by the given number of
 599      * lanes, {@code i}, modulus the vector length.
 600      * <p>
 601      * This is a cross-lane operation that permutes the lane elements of this
 602      * vector and behaves as if rotating right the lane elements by {@code i},
 603      * and then the zero value is placed into the result vector at lane indexes
 604      * greater or equal to {@code length() - (i % length())}.
 605      *
 606      * @param i the number of lanes to shift right
 607      * @return the result of shifting right lane elements of this vector by the
 608      * given number of lanes
 609      * @throws IllegalArgumentException if {@code i} is {@code < 0}.
 610      */
 611     public abstract Vector<E> shiftER(int i);
 612 
 613     /**
 614      * Blends the lane elements of this vector with those of an input vector,
 615      * selecting lanes controlled by a mask.
 616      * <p>
 617      * For each lane of the mask, at lane index {@code N}, if the mask lane
 618      * is set then the lane element at {@code N} from the input vector is
 619      * selected and placed into the resulting vector at {@code N},
 620      * otherwise the lane element at {@code N} from this vector is
 621      * selected and placed into the resulting vector at {@code N}.
 622      *
 623      * @param v the input vector
 624      * @param m the mask controlling lane selection
 625      * @return the result of blending the lane elements of this vector with
 626      * those of an input vector
 627      */
 628     public abstract Vector<E> blend(Vector<E> v, VectorMask<E> m);
 629 
 630     /**
 631      * Rearranges the lane elements of this vector and those of an input vector,


 918             return Float.SIZE * numElem;
 919         }
 920         else if (c == double.class) {
 921             return Double.SIZE * numElem;
 922         }
 923         else if (c == byte.class) {
 924             return Byte.SIZE * numElem;
 925         }
 926         else if (c == short.class) {
 927             return Short.SIZE * numElem;
 928         }
 929         else if (c == int.class) {
 930             return Integer.SIZE * numElem;
 931         }
 932         else if (c == long.class) {
 933             return Long.SIZE * numElem;
 934         }
 935         else {
 936             throw new IllegalArgumentException("Bad vector type: " + c.getName());
 937         }












































































































































































 938     }
 939 }


 543      * equal to the given vector
 544      */
 545     public abstract VectorMask<E> greaterThanEq(Vector<E> v);
 546 
 547     // Elemental shifting
 548 
 549     /**
 550      * Rotates left the lane elements of this vector by the given number of
 551      * lanes, {@code i}, modulus the vector length.
 552      * <p>
 553      * This is a cross-lane operation that permutes the lane elements of this
 554      * vector.
 555      * For each lane of the input vector, at lane index {@code N}, the lane
 556      * element is placed into the result vector at lane index
 557      * {@code (N + i) % length()}.
 558      *
 559      * @param i the number of lanes to rotate left
 560      * @return the result of rotating left lane elements of this vector by the
 561      * given number of lanes
 562      */
 563     public abstract Vector<E> rotateLanesLeft(int i);
 564 
 565     /**
 566      * Rotates right the lane elements of this vector by the given number of
 567      * lanes, {@code i}, modulus the vector length.
 568      * <p>
 569      * This is a cross-lane operation that permutes the lane elements of this
 570      * vector.
 571      * For each lane of the input vector, at lane index {@code N}, the lane
 572      * element is placed into the result vector at lane index
 573      * {@code (N + length() - (i % length())) % length()}
 574      *
 575      * @param i the number of lanes to rotate left
 576      * @return the result of rotating right lane elements of this vector by the
 577      * given number of lanes
 578      */
 579     public abstract Vector<E> rotateLanesRight(int i);
 580 
 581     /**
 582      * Shift left the lane elements of this vector by the given number of
 583      * lanes, {@code i}, modulus the vector length.
 584      * <p>
 585      * This is a cross-lane operation that permutes the lane elements of this
 586      * vector and behaves as if rotating left the lane elements by {@code i},
 587      * and then the zero value is placed into the result vector at lane indexes
 588      * less than {@code i % length()}.
 589      *
 590      * @param i the number of lanes to shift left
 591      * @return the result of shifting left lane elements of this vector by the
 592      * given number of lanes
 593      * @throws IllegalArgumentException if {@code i} is {@code < 0}.
 594      */
 595     public abstract Vector<E> shiftLanesLeft(int i);
 596 
 597     /**
 598      * Shift right the lane elements of this vector by the given number of
 599      * lanes, {@code i}, modulus the vector length.
 600      * <p>
 601      * This is a cross-lane operation that permutes the lane elements of this
 602      * vector and behaves as if rotating right the lane elements by {@code i},
 603      * and then the zero value is placed into the result vector at lane indexes
 604      * greater or equal to {@code length() - (i % length())}.
 605      *
 606      * @param i the number of lanes to shift right
 607      * @return the result of shifting right lane elements of this vector by the
 608      * given number of lanes
 609      * @throws IllegalArgumentException if {@code i} is {@code < 0}.
 610      */
 611     public abstract Vector<E> shiftLanesRight(int i);
 612 
 613     /**
 614      * Blends the lane elements of this vector with those of an input vector,
 615      * selecting lanes controlled by a mask.
 616      * <p>
 617      * For each lane of the mask, at lane index {@code N}, if the mask lane
 618      * is set then the lane element at {@code N} from the input vector is
 619      * selected and placed into the resulting vector at {@code N},
 620      * otherwise the lane element at {@code N} from this vector is
 621      * selected and placed into the resulting vector at {@code N}.
 622      *
 623      * @param v the input vector
 624      * @param m the mask controlling lane selection
 625      * @return the result of blending the lane elements of this vector with
 626      * those of an input vector
 627      */
 628     public abstract Vector<E> blend(Vector<E> v, VectorMask<E> m);
 629 
 630     /**
 631      * Rearranges the lane elements of this vector and those of an input vector,


 918             return Float.SIZE * numElem;
 919         }
 920         else if (c == double.class) {
 921             return Double.SIZE * numElem;
 922         }
 923         else if (c == byte.class) {
 924             return Byte.SIZE * numElem;
 925         }
 926         else if (c == short.class) {
 927             return Short.SIZE * numElem;
 928         }
 929         else if (c == int.class) {
 930             return Integer.SIZE * numElem;
 931         }
 932         else if (c == long.class) {
 933             return Long.SIZE * numElem;
 934         }
 935         else {
 936             throw new IllegalArgumentException("Bad vector type: " + c.getName());
 937         }
 938     }
 939 
 940     /**
 941      * Returns a mask of same species as {@code this} vector and where each lane is set or unset according to given
 942      * {@code boolean} values.
 943      * <p>
 944      * This method behaves as if it returns the result of calling the static {@link VectorMask#fromValues(VectorSpecies, boolean...) fromValues()}
 945      * method in VectorMask as follows:
 946      * <pre> {@code
 947      *     return VectorMask.fromValues(this.species(), bits);
 948      * } </pre>
 949      *
 950      * @param bits the given {@code boolean} values
 951      * @return a mask where each lane is set or unset according to the given {@code boolean} value
 952      * @throws IndexOutOfBoundsException if {@code bits.length < this.species().length()}
 953      */
 954     @ForceInline
 955     public final VectorMask<E> maskFromValues(boolean... bits) {
 956         return VectorMask.fromValues(this.species(), bits);
 957     }
 958 
 959     /**
 960      * Loads a mask of same species as {@code this} vector from a {@code boolean} array starting at an offset.
 961      * <p>
 962      * This method behaves as if it returns the result of calling the static {@link VectorMask#fromArray(VectorSpecies, boolean[], int) fromArray()}
 963      * method in VectorMask as follows:
 964      * <pre> {@code
 965      *     return VectorMask.fromArray(this.species(), bits, offset);
 966      * } </pre>
 967      *
 968      * @param bits the {@code boolean} array
 969      * @param offset the offset into the array
 970      * @return the mask loaded from a {@code boolean} array
 971      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
 972      * {@code offset > bits.length - species.length()}
 973      */
 974     @ForceInline
 975     public final VectorMask<E> maskFromArray(boolean[] bits, int offset) {
 976         return VectorMask.fromArray(this.species(), bits, offset);
 977     }
 978 
 979     /**
 980      * Returns a mask of same species as {@code this} vector and where all lanes are set.
 981      *
 982      * @return a mask where all lanes are set
 983      */
 984     @ForceInline
 985     public final VectorMask<E> maskAllTrue() {
 986         return VectorMask.maskAllTrue(this.species());
 987     }
 988 
 989     /**
 990      * Returns a mask of same species as {@code this} vector and where all lanes are unset.
 991      *
 992      * @return a mask where all lanes are unset
 993      */
 994     @ForceInline
 995     public final VectorMask<E> maskAllFalse() {
 996         return VectorMask.maskAllFalse(this.species());
 997     }
 998 
 999     /**
1000      * Returns a shuffle of same species as {@code this} vector and where each lane element is set to a given
1001      * {@code int} value logically AND'ed by the species length minus one.
1002      * <p>
1003      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#fromValues(VectorSpecies, int...) fromValues()}
1004      * method in VectorShuffle as follows:
1005      * <pre> {@code
1006      *     return VectorShuffle.fromValues(this.species(), ixs);
1007      * } </pre>
1008      *
1009      * @param ixs the given {@code int} values
1010      * @return a shuffle where each lane element is set to a given
1011      * {@code int} value
1012      * @throws IndexOutOfBoundsException if the number of int values is
1013      * {@code < this.species().length()}
1014      */
1015     @ForceInline
1016     public final VectorShuffle<E> shuffleFromValues(int... ixs) {
1017         return VectorShuffle.fromValues(this.species(), ixs);
1018     }
1019 
1020     /**
1021      * Loads a shuffle of same species as {@code this} vector from an {@code int} array starting at an offset.
1022      * <p>
1023      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#fromArray(VectorSpecies, int[], int) fromArray()}
1024      * method in VectorShuffle as follows:
1025      * <pre> {@code
1026      *     return VectorShuffle.fromArray(this.species(), ixs, offset);
1027      * } </pre>
1028      *
1029      * @param ixs the {@code int} array
1030      * @param offset the offset into the array
1031      * @return a shuffle loaded from the {@code int} array
1032      * @throws IndexOutOfBoundsException if {@code offset < 0}, or
1033      * {@code offset > ixs.length - this.species().length()}
1034      */
1035     @ForceInline
1036     public final VectorShuffle<E> shuffleFromArray(int[] ixs, int offset) {
1037         return VectorShuffle.fromArray(this.species(), ixs, offset);
1038     }
1039 
1040     /**
1041      * Returns a shuffle of same species as {@code this} vector of mapped indexes where each lane element is
1042      * the result of applying a mapping function to the corresponding lane
1043      * index.
1044      * <p>
1045      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#shuffle(VectorSpecies, IntUnaryOperator) shuffle()}
1046      * method in VectorShuffle as follows:
1047      * <pre> {@code
1048      *     return AbstractShuffle.shuffle(this.species(), f);
1049      * } </pre>
1050      *
1051      * @param f the lane index mapping function
1052      * @return a shuffle of mapped indexes
1053      */
1054     @ForceInline
1055     public final VectorShuffle<E> shuffle(IntUnaryOperator f) {
1056         return AbstractShuffle.shuffle(this.species(), f);
1057     }
1058 
1059     /**
1060      * Returns a shuffle of same species has {@code this} vector and where each lane element is the value of its
1061      * corresponding lane index.
1062      * <p>
1063      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#shuffleIota(VectorSpecies) shuffleIota()}
1064      * method in VectorShuffle as follows:
1065      * <pre> {@code
1066      *     return VectorShuffle.shuffleIota(this.species());
1067      * } </pre>
1068      *
1069      * @return a shuffle of lane indexes
1070      */
1071     @ForceInline
1072     public final VectorShuffle<E> shuffleIota() {
1073         return VectorShuffle.shuffleIota(this.species());
1074     }
1075 
1076     /**
1077      * Returns a shuffle of same species has {@code this} vector and with lane elements set to sequential {@code int}
1078      * values starting from {@code start}.
1079      * <p>
1080      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#shuffleIota(VectorSpecies, int) shuffleIota()}
1081      * method in VectorShuffle as follows:
1082      * <pre> {@code
1083      *     return VectorShuffle.shuffleIota(this.species(), start);
1084      * } </pre>
1085      *
1086      * @param start starting value of sequence
1087      * @return a shuffle of lane indexes
1088      */
1089     @ForceInline
1090     public final VectorShuffle<E> shuffleIota(int start) {
1091         return VectorShuffle.shuffleIota(this.species(), start);
1092     }
1093 
1094     /**
1095      * Returns a shuffle of same species has {@code this} vector and with lane elements set to sequential {@code int}
1096      * values starting from {@code start} and looping around species length.
1097      * <p>
1098      * This method behaves as if it returns the result of calling the static {@link VectorShuffle#shuffleOffset(VectorSpecies, int) shuffleOffset()}
1099      * method in VectorShuffle as follows:
1100      * <pre> {@code
1101      *     return VectorShuffle.shuffleOffset(this.species(), start);
1102      * } </pre>
1103      *
1104      * @param start starting value of sequence
1105      * @return a shuffle of lane indexes
1106      */
1107     @ForceInline
1108     public final VectorShuffle<E> shuffleOffset(int start) {
1109         return VectorShuffle.shuffleOffset(this.species(), start);
1110     }
1111 }
< prev index next >