org.apache.sysds.runtime.compress.utils

## Class LinearAlgebraUtils

- java.lang.Object
- - org.apache.sysds.runtime.compress.utils.LinearAlgebraUtils

    public class LinearAlgebraUtils
    extends Object

This library contains all vector primitives that are used in compressed linear algebra. For primitives that exist in LibMatrixMult, these calls are simply forwarded to ensure consistency in performance and result correctness.

### Constructor Summary

Constructors
Constructor and Description
`LinearAlgebraUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `copyNonZerosToUpperTriangle(MatrixBlock ret, MatrixBlock tmp, int ix)`
`static long` `copyUpperToLowerTriangle(MatrixBlock ret)`
`static double` `dotProduct(double[] a, double[] b, int len)`
`static double` `dotProduct(double[] a, double[] b, int ai, int bi, int len)`
`static int` `getClosestK(int[] a, int x)` Obtain the index of the closest element in a to the value x.
`static void` `vectAdd(double[] a, double[] c, int ai, int ci, int len)`
`static void` `vectAdd(double aval, double[] c, char[] bix, int bi, int ci, int len)` Add aval to a series of indexes in c.
`static void` `vectAdd(double aval, double[] c, int ci, int len)`
`static void` `vectListAdd(double[] values, double[] c, byte[] bix, int rl, int ru)`
`static void` `vectListAdd(double[] values, double[] c, byte[] bix, int rl, int ru, int off)`
`static void` `vectListAdd(double[] values, double[] c, char[] bix, int rl, int ru)`
`static void` `vectListAdd(double[] values, double[] c, char[] bix, int rl, int ru, int off)`
`static void` `vectListAdd(double[] preAggregatedValues, double[] c, int rl, int ru, int[] outputColumns, int cut, int n)`
`static void` `vectListAdd(double[] values, double[] c, int rl, int ru, int cl, int cu, int cut, int valOff)` Adds the values list into all rows of c within row and col range.
`static void` `vectMultiplyAdd(double aval, double[] b, double[] c, int[] bix, int bi, int ci, int len)`
`static void` `vectMultiplyAdd(double aval, double[] b, double[] c, int bi, int ci, int len)`
`static double` `vectSum(double[] a, char[] bix, int ai, int bi, int len)`
`static double` `vectSum(double[] a, int ai, int len)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### LinearAlgebraUtils

    public LinearAlgebraUtils()

### Method Detail

#### dotProduct

    public static double dotProduct(double[] a,
                                    double[] b,
                                    int len)

#### dotProduct

    public static double dotProduct(double[] a,
                                    double[] b,
                                    int ai,
                                    int bi,
                                    int len)

#### vectMultiplyAdd

    public static void vectMultiplyAdd(double aval,
                                       double[] b,
                                       double[] c,
                                       int bi,
                                       int ci,
                                       int len)

#### vectMultiplyAdd

    public static void vectMultiplyAdd(double aval,
                                       double[] b,
                                       double[] c,
                                       int[] bix,
                                       int bi,
                                       int ci,
                                       int len)

#### vectAdd

    public static void vectAdd(double[] a,
                               double[] c,
                               int ai,
                               int ci,
                               int len)

#### vectAdd

    public static void vectAdd(double aval,
                               double[] c,
                               char[] bix,
                               int bi,
                               int ci,
                               int len)

Add aval to a series of indexes in c.

Parameters:
  `aval` - the value to add
  `c` - The output vector to add on
  `bix` - The indexes. Note that it is char so it only supports adding to a block at a time.
  `bi` - The index to start at inside bix.
  `ci` - An Offset into c, to enable adding values to indexes that are higher than char size.
  `len` - The number of indexes to take.

#### vectListAdd

    public static void vectListAdd(double[] values,
                                   double[] c,
                                   char[] bix,
                                   int rl,
                                   int ru,
                                   int off)

#### vectListAdd

    public static void vectListAdd(double[] values,
                                   double[] c,
                                   char[] bix,
                                   int rl,
                                   int ru)

#### vectListAdd

    public static void vectListAdd(double[] values,
                                   double[] c,
                                   byte[] bix,
                                   int rl,
                                   int ru,
                                   int off)

#### vectListAdd

    public static void vectListAdd(double[] values,
                                   double[] c,
                                   int rl,
                                   int ru,
                                   int cl,
                                   int cu,
                                   int cut,
                                   int valOff)

Adds the values list into all rows of c within row and col range.

Parameters:
  `values` - The values to Add
  `c` - The double array to add into
  `rl` - The row lower index
  `ru` - The row upper index
  `cl` - The column lower index
  `cu` - The column upper index
  `cut` - The total number of columns in c.
  `valOff` - The offset into the values list to start reading from.

#### vectListAdd

    public static void vectListAdd(double[] preAggregatedValues,
                                   double[] c,
                                   int rl,
                                   int ru,
                                   int[] outputColumns,
                                   int cut,
                                   int n)

#### vectListAdd

    public static void vectListAdd(double[] values,
                                   double[] c,
                                   byte[] bix,
                                   int rl,
                                   int ru)

#### vectAdd

    public static void vectAdd(double aval,
                               double[] c,
                               int ci,
                               int len)

#### vectSum

    public static double vectSum(double[] a,
                                 char[] bix,
                                 int ai,
                                 int bi,
                                 int len)

#### vectSum

    public static double vectSum(double[] a,
                                 int ai,
                                 int len)

#### copyUpperToLowerTriangle

    public static long copyUpperToLowerTriangle(MatrixBlock ret)

#### copyNonZerosToUpperTriangle

    public static void copyNonZerosToUpperTriangle(MatrixBlock ret,
                                                   MatrixBlock tmp,
                                                   int ix)

#### getClosestK

    public static int getClosestK(int[] a,
                                  int x)

Obtain the index of the closest element in a to the value x.

Parameters:
  `a` - array of ints
  `x` - value
Returns:
  the index of the closest element in a to the value x