numericalMethods.algebra.linear
Class VectorOperations

java.lang.Object
  |
  +--numericalMethods.algebra.linear.VectorOperations

public final class VectorOperations
extends java.lang.Object

This class handles the basic operations with vectors. A vector is a one dimensional array (double, int ). All methods assume that the passed data have sensible sizes, which, due to performance reasons, is never checked. So be careful!


Method Summary
static void assign(double[] a, double v)
          Assign vector a to scalar v.
static void assign(double[] a, double[] b)
          Assign vector a to scalar b.
static void assign(int[] a, double[] b)
          Assign vector b to vector a.
static void assign(int[] a, int v)
          Assign vector a to scalar v.
(package private) static void assign(int[] a, int[] b)
          Assign vector b to vector a.
static void assignZero(double[] a)
          Assign vector a to zero.
static void assignZero(int[] a)
          Assign vector a to zero.
static void checkShape(double[] v, double[] w)
          Throw IllegalArgumentException if v' length does not equal w' length.
static void checkShape(double[] v, int[] w)
          Throw IllegalArgumentException if v' length does not equal w' length.
static void checkShape(int[] v, double[] w)
          Throw IllegalArgumentException if v' length does not equal w' length.
static void checkShape(int[] v, int[] w)
          Throw IllegalArgumentException if v' length does not equal w' length.
static double[] copy(double[] a)
          Returns a clone of vector a.
(package private) static int[] copy(int[] a)
          Returns a copy of vector a.
static void divide(double[] VRe, double[] VIm, double bRe, double bIm, double[] WRe, double[] WIm)
          Scales vector.
static void divide(double[] a, double b, double[] c)
          Scales vector a / b = c.
static void divide(double a, double[] b, double[] c)
          Scales vector: a / b = c .
static void divide(double a, double[] re, double[] im, double[] resRe, double[] resIm)
          Scales vector: a / (re+i*im) = (resRe+i*resIm) .
static void divide(double a, int[] b, double[] c)
          Scales vector: a / b = c .
static void divide(int[] a, double b, double[] c)
          scales vector a /b = c.
static void divide(int[] a, int b, int[] c)
          Scales vector.
static void divide(int a, int[] b, int[] c)
          Scales vector: a / b = c .
static double dot(double[] VRe, double[] VIm, double[] WRe, double[] WIm)
          Performs dot product
static void floor(double[] a, double[] b)
          Rounds vector a and stores result in b .
static void floor(double[] a, int[] b)
          Rounds vector a and stores result in b .
static void minus(double[] a, double[] b, double[] c)
          Performs a - b = c.
static void minus(double[] a, double b, double[] c)
          Performs a - b = c .
static void minus(double[] a, int[] b, double[] c)
          Performs a - b = c .
static void minus(double a, double[] b, double[] c)
          Performs a - b = c.
static void minus(int[] a, double[] b, double[] c)
          Performs a - b = c.
static void minus(int[] a, int[] b, int[] c)
          Performs a - b = c .
static void minus(int[] a, int b, int[] c)
          Performs a - b = c .
static void minus(int a, int[] b, int[] c)
          Performs a - b = c .
static void neg(double[] a, double[] b)
          Negates vector a and stores result in b.
static void neg(int[] a, double[] b)
          Negates vector a and stores result in b.
static void neg(int[] a, int[] b)
          Negates vector a and stores result in b.
static double normSqr(double[] re)
           
static double normSqr(int[] re)
           
static void plus(double[] a, double[] b, double[] c)
          Performs a + b = c.
static void plus(double[] a, double b, double[] c)
          Performs a + b = c .
static void plus(double[] a, int[] b, double[] c)
          Performs a + b = c.
static void plus(int[] a, double[] b, double[] c)
          Performs a + b = c.
static void plus(int[] a, int[] b, int[] c)
          Performs a + b = c.
static void plus(int[] a, int b, int[] c)
          Performs a + b = c.
static void random(double[] v)
          Assigns random all entries of v.
static void random(int[] v, int range)
          Assigns random all entries of v.
static void round(double[] a, double[] b)
          Rounds vector a and stores result in b .
static void round(double[] a, int[] b)
          Rounds vector a and stores result in b .
static double times(double[] a, double[] b)
          Performs dot product.
static void times(double[] VRe, double[] VIm, double bRe, double bIm, double[] WRe, double[] WIm)
          Scales vector.
static void times(double[] a, double b, double[] c)
          Scales vector.
static double times(double[] a, int[] b)
          Performs dot product.
static double times(int[] a, double[] b)
          Performs dot product.
static void times(int[] a, double b, double[] c)
          Scales vector.
static int times(int[] a, int[] b)
          Performs dot product.
static void times(int[] a, int b, int[] c)
          Scales vector.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

times

public static final int times(int[] a,
                              int[] b)
Performs dot product.
Parameters:
a - The first multiplicand.
b - The second multiplicand.
Returns:
The product.

dot

public static final double dot(double[] VRe,
                               double[] VIm,
                               double[] WRe,
                               double[] WIm)
Performs dot product
Parameters:
VRe - The real part of first multiplicand.
VIm - The imag. part of first multiplicand.
WRe - The real part second multiplicand.
WIm - The imag. part second multiplicand.
Returns:
The product.

times

public static final double times(double[] a,
                                 double[] b)
Performs dot product.
Parameters:
a - The first multiplicand.
b - The second multiplicand.
Returns:
The product.

times

public static final double times(int[] a,
                                 double[] b)
Performs dot product.
Parameters:
a - The first multiplicand.
b - The second multiplicand.
Returns:
The product.

times

public static final double times(double[] a,
                                 int[] b)
Performs dot product.
Parameters:
a - The first multiplicand.
b - The second multiplicand.
Returns:
The product.

times

public static final void times(int[] a,
                               int b,
                               int[] c)
Scales vector.
Parameters:
a - Vector to scale.
b - Scalar.
c - Product.

times

public static final void times(double[] a,
                               double b,
                               double[] c)
Scales vector.
Parameters:
a - Vector to scale.
b - Scalar.
c - Product.

times

public static final void times(int[] a,
                               double b,
                               double[] c)
Scales vector.
Parameters:
a - Vector to scale.
b - Scalar.
c - Product.

times

public static final void times(double[] VRe,
                               double[] VIm,
                               double bRe,
                               double bIm,
                               double[] WRe,
                               double[] WIm)
Scales vector.
Parameters:
VRe - The real part of Vector to scale.
VIm - The imag. part of Vector to scale.
bRe - The real part of Scalar.
bIm - The imag part of Scalar.
WRe - The real part of Product.
WIm - The imag. part of Product.

divide

public static final void divide(double[] VRe,
                                double[] VIm,
                                double bRe,
                                double bIm,
                                double[] WRe,
                                double[] WIm)
Scales vector.
Parameters:
VRe - The real part of Vector to scale.
VIm - The imag. part of Vector to scale.
bRe - The real part of Scalar.
bIm - The imag part of Scalar.
WRe - The real part of Product.
WRe - The imag. part of Product.

divide

public static final void divide(int[] a,
                                int b,
                                int[] c)
Scales vector.
Parameters:
a - The Vector to scale.
b - The Scalar.
c - The Product.

divide

public static final void divide(int a,
                                int[] b,
                                int[] c)
Scales vector: a / b = c .
Parameters:
b - The Vector to scale.
a - The Scalar.
c - The Product.

divide

public static final void divide(double a,
                                int[] b,
                                double[] c)
Scales vector: a / b = c .
Parameters:
b - The Vector to scale.
a - The Scalar.
c - The Product.

divide

public static final void divide(double a,
                                double[] b,
                                double[] c)
Scales vector: a / b = c .
Parameters:
b - The Vector to scale.
a - The Scalar.
c - The Product.

divide

public static final void divide(double a,
                                double[] re,
                                double[] im,
                                double[] resRe,
                                double[] resIm)
Scales vector: a / (re+i*im) = (resRe+i*resIm) .
Parameters:
b - The Vector to scale.

divide

public static final void divide(double[] a,
                                double b,
                                double[] c)
Scales vector a / b = c.
Parameters:
a - The Vector to scale.
b - The Scalar.
c - The Product.

divide

public static final void divide(int[] a,
                                double b,
                                double[] c)
scales vector a /b = c.
Parameters:
a - The Vector to scale.
b - The Scalar.
c - The Product.

plus

public static final void plus(int[] a,
                              int[] b,
                              int[] c)
Performs a + b = c.
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

plus

public static final void plus(double[] a,
                              double[] b,
                              double[] c)
Performs a + b = c.
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

plus

public static final void plus(int[] a,
                              double[] b,
                              double[] c)
Performs a + b = c.
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

plus

public static final void plus(double[] a,
                              int[] b,
                              double[] c)
Performs a + b = c.
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

plus

public static final void plus(int[] a,
                              int b,
                              int[] c)
Performs a + b = c.
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

plus

public static final void plus(double[] a,
                              double b,
                              double[] c)
Performs a + b = c .
Parameters:
a - The first summend.
b - The second summend.
c - The Product.

minus

public static final void minus(int[] a,
                               int[] b,
                               int[] c)
Performs a - b = c .
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(double[] a,
                               double[] b,
                               double[] c)
Performs a - b = c.
Parameters:
b - The subtrahend.
c - The difference.

minus

public static final void minus(int[] a,
                               double[] b,
                               double[] c)
Performs a - b = c.
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(double[] a,
                               int[] b,
                               double[] c)
Performs a - b = c .
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(int[] a,
                               int b,
                               int[] c)
Performs a - b = c .
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(int a,
                               int[] b,
                               int[] c)
Performs a - b = c .
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(double[] a,
                               double b,
                               double[] c)
Performs a - b = c .
Parameters:
b - The subtrahend.
c - The product.

minus

public static final void minus(double a,
                               double[] b,
                               double[] c)
Performs a - b = c.
Parameters:
b - The subtrahend.
c - The product.

assign

static final void assign(int[] a,
                         int[] b)
Assign vector b to vector a.

assign

public static final void assign(double[] a,
                                double[] b)
Assign vector a to scalar b.

assign

public static final void assign(int[] a,
                                double[] b)
Assign vector b to vector a.

assign

public static final void assign(int[] a,
                                int v)
Assign vector a to scalar v.

assign

public static final void assign(double[] a,
                                double v)
Assign vector a to scalar v.

assignZero

public static final void assignZero(double[] a)
Assign vector a to zero.

assignZero

public static final void assignZero(int[] a)
Assign vector a to zero.

copy

static final int[] copy(int[] a)
Returns a copy of vector a.
Parameters:
a - The vector to copy.
Returns:
The copy-vector.

copy

public static final double[] copy(double[] a)
Returns a clone of vector a.
Parameters:
a - The vector to copy.
Returns:
The copy-vector.

round

public static final void round(double[] a,
                               double[] b)
Rounds vector a and stores result in b . a and b may coinside.
Parameters:
a - The vector to round.
b - The rounded vector.

floor

public static final void floor(double[] a,
                               double[] b)
Rounds vector a and stores result in b . a and b may coinside.
Parameters:
a - The vector to round.
b - The rounded vector.

round

public static final void round(double[] a,
                               int[] b)
Rounds vector a and stores result in b . a and b may coinside.
Parameters:
a - The vector to round.
b - The rounded vector.

floor

public static final void floor(double[] a,
                               int[] b)
Rounds vector a and stores result in b . a and b may coinside.
Parameters:
a - The vector to round.
b - The rounded vector.

neg

public static final void neg(int[] a,
                             int[] b)
Negates vector a and stores result in b. a and b may coinside.
Parameters:
a - The vector to negate.
b - The negated vector.

neg

public static final void neg(double[] a,
                             double[] b)
Negates vector a and stores result in b. a and b may coinside.
Parameters:
a - The vector to negate.
b - The negated vector.

neg

public static final void neg(int[] a,
                             double[] b)
Negates vector a and stores result in b. a and b may coinside.
Parameters:
a - The vector to negate.
b - The negated vector.

normSqr

public static double normSqr(double[] re)

normSqr

public static double normSqr(int[] re)

checkShape

public static final void checkShape(double[] v,
                                    double[] w)
Throw IllegalArgumentException if v' length does not equal w' length.

checkShape

public static final void checkShape(int[] v,
                                    int[] w)
Throw IllegalArgumentException if v' length does not equal w' length.

checkShape

public static final void checkShape(double[] v,
                                    int[] w)
Throw IllegalArgumentException if v' length does not equal w' length.

checkShape

public static final void checkShape(int[] v,
                                    double[] w)
Throw IllegalArgumentException if v' length does not equal w' length.

random

public static final void random(double[] v)
Assigns random all entries of v.

random

public static final void random(int[] v,
                                int range)
Assigns random all entries of v. all entries are from 0 to range.