Class LibMatrixOuterAgg


  • public class LibMatrixOuterAgg
    extends Object
    ACS: Purpose of this library is to make some of the unary outer aggregate operator more efficient. Today these operators are being handled through common operations. This library will expand per need and priority to include these operators through this support. To begin with, first operator being handled is unary aggregate for less than (<), rowsum operation. Other list will be added soon are rowsum on >, <=, >=, ==, and != operation.
    • Method Detail

      • isRowIndexMax

        public static boolean isRowIndexMax​(AggregateUnaryOperator uaggOp)
        This will return if uaggOp is of type RowIndexMax
        Parameters:
        uaggOp - aggregate unary operator
        Returns:
        true if aggregate unary operator is of type rowIndexMax
      • isRowIndexMin

        public static boolean isRowIndexMin​(AggregateUnaryOperator uaggOp)
        This will return if uaggOp is of type RowIndexMin
        Parameters:
        uaggOp - aggregate unary operator
        Returns:
        true if aggregate unary operator is of type rowIndexMin
      • isCompareOperator

        public static boolean isCompareOperator​(BinaryOperator bOp)
        This will return if uaggOp is of type RowIndexMin
        Parameters:
        bOp - binary operator
        Returns:
        true/false, based on if its one of the six operators (<, <=, >, >=, == and !=)
      • prepareRowIndicesMax

        public static int[] prepareRowIndicesMax​(int iCols,
                                                 double[] vmb,
                                                 BinaryOperator bOp)
        This function will return max indices, based on column vector data. This indices will be computed based on operator. These indices can be used to compute max index for a given input value in subsequent operation. e.g. Right Vector has data (V1) : 6 3 9 7 2 4 4 3 Original indices for this data will be (I1): 1 2 3 4 5 6 7 8 Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 CumMax of I2 will be A: (CumMin(I2)) 5 5 8 8 8 8 8 8 CumMax of I2 in reverse order be B: 8 8 8 7 7 4 4 3 Values from vector A is used to compute RowIndexMax for > & >= operators Values from vector B is used to compute RowIndexMax for < & <= operators Values from I2 is used to compute RowIndexMax for == operator. Original values are directly used to compute RowIndexMax for != operator Shifting values from vector A or B is required to compute final indices. Once indices are shifted from vector A or B, their cell value corresponding to input data will be used.
        Parameters:
        iCols - ?
        vmb - ?
        bOp - binary operator
        Returns:
        array of maximum row indices
      • prepareRowIndicesMin

        public static int[] prepareRowIndicesMin​(int iCols,
                                                 double[] vmb,
                                                 BinaryOperator bOp)
        This function will return min indices, based on column vector data. This indices will be computed based on operator. These indices can be used to compute min index for a given input value in subsequent operation. e.g. Right Vector has data (V1) : 6 3 9 7 2 4 4 3 Original indices for this data will be (I1): 1 2 3 4 5 6 7 8 Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 CumMin of I2 will be A: (CumMin(I2)) 5 2 2 2 2 1 1 1 CumMin of I2 in reverse order be B: 1 1 1 1 1 1 3 3 Values from vector A is used to compute RowIndexMin for > operator Values from vector B is used to compute RowIndexMin for <, <= and >= operators Values from I2 is used to compute RowIndexMax for == operator. Original values are directly used to compute RowIndexMax for != operator Shifting values from vector A or B is required to compute final indices. Once indices are shifted from vector A or B, their cell value corresponding to input data will be used.
        Parameters:
        iCols - ?
        vmb - ?
        bOp - binary operator
        Returns:
        array of minimum row indices
      • resetOutputMatrix

        public static void resetOutputMatrix​(MatrixIndexes in1Ix,
                                             MatrixBlock in1Val,
                                             MatrixIndexes outIx,
                                             MatrixBlock outVal,
                                             AggregateUnaryOperator uaggOp)
        ReSet output matrix
        Parameters:
        in1Ix - input matrix indexes
        in1Val - input matrix block
        outIx - output matrix indexes
        outVal - output matrix block
        uaggOp - aggregate unary operator
      • adjustRowIndicesMax

        public static void adjustRowIndicesMax​(int[] vix,
                                               double[] vmb,
                                               BinaryOperator bOp)
        This function adjusts indices to be leveraged in uarimaxXX functions. Initially vector containing indices are sorted based on value and then CumMax/CumMin per need for <, <=, >, >= operator, where as just sorted indices based on value for ==, and != operators. There is need to shift these indices for different operators, which is handled through this function.
        Parameters:
        vix - ?
        vmb - ?
        bOp - binary operator
      • adjustRowIndicesMin

        public static void adjustRowIndicesMin​(int[] vix,
                                               double[] vmb,
                                               BinaryOperator bOp)
        This function adjusts indices to be leveraged in uariminXX functions. Initially vector containing indices are sorted based on value and then CumMin per need for <, <=, >, >= operator, where as just sorted indices based on value for ==, and != operators. There is need to shift these indices for different operators, which is handled through this function.
        Parameters:
        vix - ?
        vmb - ?
        bOp - binary operator
      • shiftRight

        public static void shiftRight​(int[] vix,
                                      double[] vmb)
        This function will shift indices from one partition to next in right direction. For an example, if there are two sorted vector based on value like following, where V2 is sorted data, and I2 are its corresponding indices. Then this function will shift indices to right by one partition I2". Left most partition remained untouched. Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 Shift Right by one partition (I2") 5 5 2 8 6 7 1 4
        Parameters:
        vix - ?
        vmb - ?
      • shiftLeft

        public static void shiftLeft​(int[] vix,
                                     double[] vmb)
        This function will shift indices from one partition to next in left direction. For an example, if there are two sorted vector based on value like following, where V2 is sorted data, and I2 are its corresponding indices. Then this function will shift indices to right by one partition I2". Right most partition remained untouched. Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 Shift Left by one partition (I2") 2 8 6 7 1 4 3 3
        Parameters:
        vix - ?
        vmb - ?
      • setMinIndexInPartition

        public static void setMinIndexInPartition​(int[] vix,
                                                  double[] vmb)
        This function will set minimum index in the partition to all cells in partition. For an example, if there are two sorted vector based on value like following, where V2 is sorted data, and I2 are its corresponding indices. In this case, for partition with value = 4, has two different indices -- 6, and 7. This function will set indices to both cells to minimum value of 6. Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 Minimum indices set in the partition (I2") 5 2 8 6 6 1 4 3
        Parameters:
        vix - ?
        vmb - ?
      • setMaxIndexInPartition

        public static void setMaxIndexInPartition​(int[] vix,
                                                  double[] vmb)
        This function will set maximum index in the partition to all cells in partition. For an example, if there are two sorted vector based on value like following, where V2 is sorted data, and I2 are its corresponding indices. In this case, for partition with value = 4, has two different indices -- 6, and 7. This function will set indices to both cells to maximum value of 7. Sorting this data based on value will be (V2): 2 3 3 4 4 6 7 9 Then indices will be ordered as (I2): 5 2 8 6 7 1 4 3 Maximum indices set in the partition (I2") 5 2 8 7 7 1 4 3
        Parameters:
        vix - ?
        vmb - ?