de.jtem.jpetsc
Class Vec

java.lang.Object
  extended by de.jtem.jpetsc.PrimitivNative
      extended by de.jtem.jpetsc.Native
          extended by de.jtem.jpetsc.Vec

public class Vec
extends Native


Nested Class Summary
static class Vec.GetOwnershipRangeResult
          Result class for getOwnershipRange()
static class Vec.MaxResult
          Result class for max()
static class Vec.MinResult
          Result class for min()
static class Vec.StashGetInfoResult
          Result class for stashGetInfo()
static class Vec.StrideMaxAllResult
          Result class for strideMaxAll()
static class Vec.StrideMaxResult
          Result class for strideMax(int)
static class Vec.StrideMinAllResult
          Result class for strideMinAll()
static class Vec.StrideMinResult
          Result class for strideMin(int)
 
Field Summary
 
Fields inherited from class de.jtem.jpetsc.PrimitivNative
destroyNative
 
Constructor Summary
Vec(int n)
           
 
Method Summary
 void abs()
          Replaces every element in a vector with its absolute value.
 void add(int i, double val)
          native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, INSERT_VALUES)
 void addLocal(int i, double val)
          native (faster) abbreviation for setValueLocal(1, i, val, INSERT_VALUES)
 void appendOptionsPrefix(java.lang.String prefix)
          Appends to the prefix used for searching for all
Vec options in the database.
 void assemble()
          abbreviation to: assemblyBegin(); assemblyEnd();
 void assemblyBegin()
          Begins assembling the vector.
 void assemblyEnd()
          Completes assembling the vector.
 void aXPBY(double alpha, double beta, Vec x)
          Computes y = alpha x + beta y.
 void aXPY(double alpha, Vec x)
          Computes y = alpha x + y.
 void aYPX(double alpha, Vec x)
          Computes y = x + alpha y.
 void conjugate()
          Conjugates a vector.
 void contourScale(double vmin, double vmax)
          Prepares a vector of values to be plotted using
the PetscDrawTriangle() contour plotter.
 void copy(Vec y)
          Copies a vector.
static Vec create(int comm)
          Creates an empty vector object.
static Vec createMPI(int comm, int n, int N)
          Creates a parallel vector.
static Vec createMPIWithArray(int comm, int n, int N, double[] array)
          Creates a parallel, array-style vector,
static Vec createSeq(int n)
          Creates a standard, sequential array-style vector.
static Vec createSeqWithArray(int n, double[] array)
          Creates a standard,sequential array-style vector,
static Vec createShared(int comm, int n, int N)
          Creates a parallel vector that uses shared memory.
 double dot(Vec y)
          Computes the vector dot product.
 void dotBegin(Vec y, double[] result)
          Starts a split phase dot product computation.
 void dotEnd(Vec y, double[] result)
          Ends a split phase dot product computation.
 Vec duplicate()
          Creates a new vector of the same type as an existing vector.
 boolean equal(Vec vec2)
          Compares two vectors.
 boolean equals(java.lang.Object obj)
           
 double[] getArray()
          Returns a pointer to a contiguous array that contains this
processor's portion of the vector data.
 int getBlockSize()
          Gets the blocksize for the vector, i.e. what is used for VecSetValuesBlocked()
and VecSetValuesBlockedLocal().
 double[] getGlobalArray(int comm, int root, double[] data)
          gets the whole vector as java array using mpi_gatherv to collect the data and returns it on root and null otherwise.
 int getLocalSize()
          Returns the number of elements of the vector stored
in local memory.
 Vec.GetOwnershipRangeResult getOwnershipRange()
          Returns the range of indices owned by
this processor, assuming that the vectors are laid out with the
first n1 elements on the first processor, next n2 elements on the
second, etc.
 int getRefcount()
           
 int getSize()
          Returns the global number of elements of the vector.
 java.lang.String getType()
          Gets the vector type name (as a string) from the Vec.
 double getValue(int i)
          native (faster) abbreviation for getValues(1, new int[]{i}, ret)
 void getValues(int ni, int[] ix, double[] y)
          Gets values from certain locations of a vector.
 Vec ghostGetLocalForm()
          Obtains the local ghosted representation of
a parallel vector created with VecCreateGhost().
 Vec ghostRestoreLocalForm()
          Restores the local ghosted representation of
a parallel vector obtained with VecGhostGetLocalForm().
 void insert(int i, double val)
          native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, ADD_VALUES)
 void insertLocal(int i, double val)
          native (faster) abbreviation for setValueLocal(1, i, val, ADD_VALUES)
 void loadIntoVector()
          Loads a vector that has been stored in binary format
with VecView().
static Vec loadVec(java.lang.String outtype)
          Loads a vector that has been stored in binary format
with VecView().
 Vec.MaxResult max()
          Determines the maximum vector component and its location.
 double maxPointwiseDivide(Vec y)
          Computes the maximum of the componentwise division max = max_i abs(x_i/y_i).
 Vec mAXPY(int nv, double[] alpha)
          Computes y = y + sum alpha[j] x[j]
 Vec.MinResult min()
          Determines the minimum vector component and its location.
protected  void nativeCreate()
           
 double norm(NormType type)
          Computes the vector norm.
 double normalize()
          Normalizes a vector by 2-norm.
 void normBegin(NormType ntype, double[] result)
          Starts a split phase norm computation.
 void normEnd(NormType ntype, double[] result)
          Ends a split phase norm computation.
 void pointwiseDivide(Vec x, Vec y)
          Computes the componentwise division w = x/y.
 void pointwiseMax(Vec x, Vec y)
          Computes the componentwise maximum w_i = max(x_i, y_i).
 void pointwiseMaxAbs(Vec x, Vec y)
          Computes the componentwise maximum of the absolute values w_i = max(abs(x_i), abs(y_i)).
 void pointwiseMin(Vec x, Vec y)
          Computes the componentwise minimum w_i = min(x_i, y_i).
 void pointwiseMult(Vec x, Vec y)
          Computes the componentwise multiplication w = x*y.
 void reciprocal()
          Replaces each component of a vector by its reciprocal.
static void registerAll(java.lang.String path)
          Registers all of the vector components in the Vec package.
static void registerDestroy()
          Frees the list of Vec methods that were registered by VecRegister()/VecRegisterDynamic().
 void restoreArray()
          Restores a vector after VecGetArray() has been called.
 void scale(double alpha)
          Scales a vector.
 void set(double alpha)
          Sets all components of a vector to a single scalar value.
 void setBlockSize(int bs)
          Sets the blocksize for future calls to VecSetValuesBlocked()
and VecSetValuesBlockedLocal().
 void setFromOptions()
          Configures the vector from the options database.
 void setOptionsPrefix(java.lang.String prefix)
          Sets the prefix used for searching for all
Vec options in the database.
 void setSizes(int n, int N)
          Sets the local and global sizes, and checks to determine compatibility
 void setType(java.lang.String method)
          Builds a vector, for a particular vector implementation.
 void setUp()
          Sets up the internal vector data structures for the later use.
 void setValue(int i, double val, InsertMode mode)
          native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, mode)
 void setValueLocal(int i, double val, InsertMode mode)
          native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, mode)
 void setValues(int ni, int[] ix, double[] y, InsertMode iora)
          Inserts or adds values into certain locations of a vector.
 void setValuesBlocked(int ni, int[] ix, double[] y, InsertMode iora)
          Inserts or adds blocks of values into certain locations of a vector.
 void setValuesBlockedLocal(int ni, int[] ix, double[] y, InsertMode iora)
          Inserts or adds values into certain locations of a vector,
using a local ordering of the nodes.
 void setValuesLocal(int ni, int[] ix, double[] y, InsertMode iora)
          Inserts or adds values into certain locations of a vector,
using a local ordering of the nodes.
 void shift(double shift)
          Shifts all of the components of a vector by computing
x[i] = x[i] + shift.
 void sqrt()
          Replaces each component of a vector by the square root of its magnitude.
 Vec.StashGetInfoResult stashGetInfo()
          Gets how many values are currently in the vector stash, i.e. need
to be communicated to other processors during the VecAssemblyBegin/End() process
Not collective
 void stashSetInitialSize(int size, int bsize)
          sets the sizes of the vec-stash, that is
used during the assembly process to store values that belong to
other processors.
 void stashView()
          Prints the entries in the vector stash and block stash.
 void strideGather(int start, Vec s, InsertMode addv)
          Gathers a single component from a multi-component vector into
another vector.
 Vec strideGatherAll(InsertMode addv)
          Gathers all the single components from a multi-component vector into
separate vectors.
 Vec.StrideMaxResult strideMax(int start)
          Computes the maximum of subvector of a vector defined
by a starting point and a stride and optionally its location.
 Vec.StrideMaxAllResult strideMaxAll()
          Computes the maximums of subvectors of a vector defined
by a starting point and a stride and optionally its location.
 Vec.StrideMinResult strideMin(int start)
          Computes the minimum of subvector of a vector defined
by a starting point and a stride and optionally its location.
 Vec.StrideMinAllResult strideMinAll()
          Computes the minimum of subvector of a vector defined
by a starting point and a stride and optionally its location.
 double strideNorm(int start, NormType ntype)
          Computes the norm of subvector of a vector defined
by a starting point and a stride.
 double strideNormAll(NormType ntype)
          Computes the norms subvectors of a vector defined
by a starting point and a stride.
 void strideScale(int start, double scale)
          Scales a subvector of a vector defined
by a starting point and a stride.
 void strideScaleAll(double[] scales)
          Scales the subvectors of a vector defined
by a starting point and a stride.
 void strideScatter(int start, Vec v, InsertMode addv)
          Scatters a single component from a vector into a multi-component vector.
 Vec strideScatterAll(InsertMode addv)
          Scatters all the single components from separate vectors into
a multi-component vector.
 double sum()
          Computes the sum of all the components of a vector.
 void swap(Vec y)
          Swaps the vectors x and y.
 double tDot(Vec y)
          Computes an indefinite vector dot product.
 void tDotBegin(Vec y, double[] result)
          Starts a split phase transpose dot product computation.
 void tDotEnd(Vec y, double[] result)
          Ends a split phase transpose dot product computation.
 java.lang.String toString()
           
 void view()
          Views a vector object.
 void viewFromOptions(java.lang.String title)
          This function visualizes the vector based upon user options.
 void wAXPY(double alpha, Vec x, Vec y)
          Computes w = alpha x + y.
 void zeroEntries()
          puts a 0.0 in each element of a vector
 
Methods inherited from class de.jtem.jpetsc.PrimitivNative
finalize, getNativeObjectToString, load
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vec

public Vec(int n)
Method Detail

nativeCreate

protected void nativeCreate()
Specified by:
nativeCreate in class Native

getGlobalArray

public double[] getGlobalArray(int comm,
                               int root,
                               double[] data)
gets the whole vector as java array using mpi_gatherv to collect the data and returns it on root and null otherwise.

Parameters:
root - rank where the array is returned
comm - the communicator of the vector (same as used with createMPI)
data - the array where to store the data. If null, it will be allocated
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class PrimitivNative

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getRefcount

public int getRefcount()

getValue

public double getValue(int i)
native (faster) abbreviation for getValues(1, new int[]{i}, ret)

See Also:
getValues(int, int[], double[])

setValue

public void setValue(int i,
                     double val,
                     InsertMode mode)
native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, mode)

See Also:
setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), add(int, double), insert(int, double)

insert

public void insert(int i,
                   double val)
native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, ADD_VALUES)

See Also:
setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), add(int, double)

add

public void add(int i,
                double val)
native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, INSERT_VALUES)

See Also:
setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), insert(int, double)

setValueLocal

public void setValueLocal(int i,
                          double val,
                          InsertMode mode)
native (faster) abbreviation for setValues(1, new int[]{i}, new double[]{val}, mode)

See Also:
setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), add(int, double), insert(int, double)

insertLocal

public void insertLocal(int i,
                        double val)
native (faster) abbreviation for setValueLocal(1, i, val, ADD_VALUES)

See Also:
setValueLocal(int, double, de.jtem.jpetsc.InsertMode), addLocal(int, double)

addLocal

public void addLocal(int i,
                     double val)
native (faster) abbreviation for setValueLocal(1, i, val, INSERT_VALUES)

See Also:
setValueLocal(int, double, de.jtem.jpetsc.InsertMode), insertLocal(int, double)

assemble

public void assemble()
abbreviation to:
assemblyBegin();
assemblyEnd();

See Also:
assemblyBegin(), assemblyEnd()

createShared

public static Vec createShared(int comm,
                               int n,
                               int N)
Creates a parallel vector that uses shared memory.

Parameters:
comm - the MPI communicator to use
n - local vector length (or PETSC_DECIDE to have calculated if N is given)
N - global vector length (or PETSC_DECIDE to have calculated if n is given)
Returns:
the vector Collective on MPI_Comm
See Also:
createSeq(int), create(int), createMPI(int, int, int), duplicate(), #duplicateVecs, #createGhost, createMPIWithArray(int, int, int, double[]), #createGhostWithArray

createSeq

public static Vec createSeq(int n)
Creates a standard, sequential array-style vector.

Parameters:
n - the vector length
Returns:
the vector
See Also:
createMPI(int, int, int), create(int), duplicate(), #duplicateVecs, #createGhost

createSeqWithArray

public static Vec createSeqWithArray(int n,
                                     double[] array)
Creates a standard,sequential array-style vector,

Parameters:
n - the vector length
array - memory where the vector elements are to be stored.
Returns:
the vector
See Also:
createMPIWithArray(int, int, int, double[]), create(int), duplicate(), #duplicateVecs, #createGhost, createSeq(int), #placeArray

createMPI

public static Vec createMPI(int comm,
                            int n,
                            int N)
Creates a parallel vector.

Parameters:
comm - the MPI communicator to use
n - local vector length (or PETSC_DECIDE to have calculated if N is given)
N - global vector length (or PETSC_DETERMINE to have calculated if n is given)
Returns:
the vector
See Also:
createSeq(int), create(int), duplicate(), #duplicateVecs, #createGhost, createMPIWithArray(int, int, int, double[]), #createGhostWithArray

createMPIWithArray

public static Vec createMPIWithArray(int comm,
                                     int n,
                                     int N,
                                     double[] array)
Creates a parallel, array-style vector,

Parameters:
comm - the MPI communicator to use
n - local vector length, cannot be PETSC_DECIDE
N - global vector length (or PETSC_DECIDE to have calculated)
array - the user provided array to store the vector values
Returns:
the vector
See Also:
createSeqWithArray(int, double[]), create(int), duplicate(), #duplicateVecs, #createGhost, createMPI(int, int, int), #createGhostWithArray, #placeArray

ghostGetLocalForm

public Vec ghostGetLocalForm()
Obtains the local ghosted representation of
a parallel vector created with VecCreateGhost().
Not Collective

Returns:
the local (ghosted) representation
See Also:
#createGhost, ghostRestoreLocalForm(), #createGhostWithArray

ghostRestoreLocalForm

public Vec ghostRestoreLocalForm()
Restores the local ghosted representation of
a parallel vector obtained with VecGhostGetLocalForm().
Not Collective

See Also:
#createGhost, ghostGetLocalForm(), #createGhostWithArray

loadVec

public static Vec loadVec(java.lang.String outtype)
Loads a vector that has been stored in binary format
with VecView().

Parameters:
outtype - the type of vector VECSEQ or VECMPI or PETSC_NULL (which indicates
using VECSEQ if the communicator in the Viewer is of size 1; otherwise
use VECMPI).
Returns:
the newly loaded vector
See Also:
#PetscViewerBinaryOpen, view(), #MatLoad, loadIntoVector()

strideScale

public void strideScale(int start,
                        double scale)
Scales a subvector of a vector defined
by a starting point and a stride.

Parameters:
start - starting point of the subvector (defined by a stride)
scale - value to multiply each subvector entry by
See Also:
norm(de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int), strideScale(int, double)

strideNorm

public double strideNorm(int start,
                         NormType ntype)
Computes the norm of subvector of a vector defined
by a starting point and a stride.

Parameters:
start - starting point of the subvector (defined by a stride)
ntype - type of norm, one of NORM_1, NORM_2, NORM_INFINITY
Returns:
the norm
See Also:
norm(de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int)

strideMax

public Vec.StrideMaxResult strideMax(int start)
Computes the maximum of subvector of a vector defined
by a starting point and a stride and optionally its location.

Parameters:
start - starting point of the subvector (defined by a stride)
Returns:
Vec.StrideMaxResult
See Also:
max(), strideNorm(int, de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int)

strideMin

public Vec.StrideMinResult strideMin(int start)
Computes the minimum of subvector of a vector defined
by a starting point and a stride and optionally its location.

Parameters:
start - starting point of the subvector (defined by a stride)
Returns:
Vec.StrideMinResult
See Also:
min(), strideNorm(int, de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMax(int)

strideScaleAll

public void strideScaleAll(double[] scales)
Scales the subvectors of a vector defined
by a starting point and a stride.

Parameters:
scales - values to multiply each subvector entry by
See Also:
norm(de.jtem.jpetsc.NormType), strideScale(int, double), scale(double), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int)

strideNormAll

public double strideNormAll(NormType ntype)
Computes the norms subvectors of a vector defined
by a starting point and a stride.

Parameters:
ntype - type of norm, one of NORM_1, NORM_2, NORM_INFINITY
Returns:
the norms
See Also:
norm(de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int)

strideMaxAll

public Vec.StrideMaxAllResult strideMaxAll()
Computes the maximums of subvectors of a vector defined
by a starting point and a stride and optionally its location.

Returns:
Vec.StrideMaxAllResult
See Also:
max(), strideNorm(int, de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int)

strideMinAll

public Vec.StrideMinAllResult strideMinAll()
Computes the minimum of subvector of a vector defined
by a starting point and a stride and optionally its location.

Returns:
Vec.StrideMinAllResult
See Also:
min(), strideNorm(int, de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMax(int)

strideGatherAll

public Vec strideGatherAll(InsertMode addv)
Gathers all the single components from a multi-component vector into
separate vectors.

Parameters:
addv - one of ADD_VALUES,INSERT_VALUES,MAX_VALUES
Returns:
the location where the subvectors are stored
See Also:
strideNorm(int, de.jtem.jpetsc.NormType), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatterAll(de.jtem.jpetsc.InsertMode)

strideScatterAll

public Vec strideScatterAll(InsertMode addv)
Scatters all the single components from separate vectors into
a multi-component vector.

Parameters:
addv - one of ADD_VALUES,INSERT_VALUES,MAX_VALUES
See Also:
strideNorm(int, de.jtem.jpetsc.NormType), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideScatterAll(de.jtem.jpetsc.InsertMode)

strideGather

public void strideGather(int start,
                         Vec s,
                         InsertMode addv)
Gathers a single component from a multi-component vector into
another vector.

Parameters:
start - starting point of the subvector (defined by a stride)
s -
addv - one of ADD_VALUES,INSERT_VALUES,MAX_VALUES
See Also:
strideNorm(int, de.jtem.jpetsc.NormType), strideScatter(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int), strideGatherAll(de.jtem.jpetsc.InsertMode), strideScatterAll(de.jtem.jpetsc.InsertMode)

strideScatter

public void strideScatter(int start,
                          Vec v,
                          InsertMode addv)
Scatters a single component from a vector into a multi-component vector.

Parameters:
start - starting point of the subvector (defined by a stride)
v -
addv - one of ADD_VALUES,INSERT_VALUES,MAX_VALUES
See Also:
strideNorm(int, de.jtem.jpetsc.NormType), strideGather(int, de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode), strideMin(int), strideMax(int), strideGatherAll(de.jtem.jpetsc.InsertMode), strideScatterAll(de.jtem.jpetsc.InsertMode)

sqrt

public void sqrt()
Replaces each component of a vector by the square root of its magnitude.
Not collective


sum

public double sum()
Computes the sum of all the components of a vector.

Returns:
the result
See Also:
norm(de.jtem.jpetsc.NormType)

shift

public void shift(double shift)
Shifts all of the components of a vector by computing
x[i] = x[i] + shift.

Parameters:
shift - the shift

abs

public void abs()
Replaces every element in a vector with its absolute value.


equal

public boolean equal(Vec vec2)
Compares two vectors.

Parameters:
vec2 - the second vector
Returns:
PETSC_TRUE if the vectors are equal; PETSC_FALSE otherwise.

dotBegin

public void dotBegin(Vec y,
                     double[] result)
Starts a split phase dot product computation.

Parameters:
y - the second vector
result - where the result will go (can be PETSC_NULL)
See Also:
dotEnd(de.jtem.jpetsc.Vec, double[]), normBegin(de.jtem.jpetsc.NormType, double[]), normEnd(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, tDotBegin(de.jtem.jpetsc.Vec, double[]), tDotEnd(de.jtem.jpetsc.Vec, double[])

dotEnd

public void dotEnd(Vec y,
                   double[] result)
Ends a split phase dot product computation.

Parameters:
y - the second vector (can be PETSC_NULL)
result - where the result will go
See Also:
dotBegin(de.jtem.jpetsc.Vec, double[]), normBegin(de.jtem.jpetsc.NormType, double[]), normEnd(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, tDotBegin(de.jtem.jpetsc.Vec, double[]), tDotEnd(de.jtem.jpetsc.Vec, double[])

tDotBegin

public void tDotBegin(Vec y,
                      double[] result)
Starts a split phase transpose dot product computation.

Parameters:
y - the second vector
result - where the result will go (can be PETSC_NULL)
See Also:
tDotEnd(de.jtem.jpetsc.Vec, double[]), normBegin(de.jtem.jpetsc.NormType, double[]), normEnd(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[])

tDotEnd

public void tDotEnd(Vec y,
                    double[] result)
Ends a split phase transpose dot product computation.

Parameters:
y - the second vector (can be PETSC_NULL)
result - where the result will go
See Also:
tDotBegin(de.jtem.jpetsc.Vec, double[]), normBegin(de.jtem.jpetsc.NormType, double[]), normEnd(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[])

normBegin

public void normBegin(NormType ntype,
                      double[] result)
Starts a split phase norm computation.

Parameters:
ntype - norm type, one of NORM_1, NORM_2, NORM_MAX, NORM_1_AND_2
result - where the result will go (can be PETSC_NULL)
See Also:
normEnd(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[])

normEnd

public void normEnd(NormType ntype,
                    double[] result)
Ends a split phase norm computation.

Parameters:
ntype - norm type, one of NORM_1, NORM_2, NORM_MAX, NORM_1_AND_2
result - where the result will go
See Also:
normBegin(de.jtem.jpetsc.NormType, double[]), norm(de.jtem.jpetsc.NormType), dot(de.jtem.jpetsc.Vec), #mDot, dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[])

contourScale

public void contourScale(double vmin,
                         double vmax)
Prepares a vector of values to be plotted using
the PetscDrawTriangle() contour plotter.

Parameters:
vmin - minimum value (for lowest color)
vmax - maximum value (for highest color)
See Also:
#PetscDrawTensorContour, #PetscDrawTensorContourPatch

registerAll

public static void registerAll(java.lang.String path)
Registers all of the vector components in the Vec package.
Not Collective

Parameters:
path - The dynamic library path
See Also:
#register, registerDestroy(), #registerDynamic

setType

public void setType(java.lang.String method)
Builds a vector, for a particular vector implementation.

Parameters:
method - The name of the vector type
See Also:
getType(), create(int)

getType

public java.lang.String getType()
Gets the vector type name (as a string) from the Vec.
Not Collective

Returns:
The vector type name
See Also:
setType(java.lang.String), create(int)

registerDestroy

public static void registerDestroy()
Frees the list of Vec methods that were registered by VecRegister()/VecRegisterDynamic().
Not Collective

See Also:
#register, registerAll(java.lang.String), #registerDynamic

create

public static Vec create(int comm)
Creates an empty vector object. The type can then be set with VecSetType(),
or VecSetFromOptions().
If you never call VecSetType() or VecSetFromOptions() it will generate an
error when you try to use the vector.

Parameters:
comm - The communicator for the vector object
Returns:
The vector object
See Also:
setType(java.lang.String), setSizes(int, int), createMPIWithArray(int, int, int, double[]), createMPI(int, int, int), duplicate(), #duplicateVecs, #createGhost, createSeq(int), #placeArray

maxPointwiseDivide

public double maxPointwiseDivide(Vec y)
Computes the maximum of the componentwise division max = max_i abs(x_i/y_i).

Parameters:
y - the vectors
Returns:
the result
See Also:
pointwiseDivide(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMax(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMaxAbs(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

dot

public double dot(Vec y)
Computes the vector dot product.

Parameters:
y - the vectors
Returns:
the dot product
See Also:
#mDot, tDot(de.jtem.jpetsc.Vec), norm(de.jtem.jpetsc.NormType), dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[])

norm

public double norm(NormType type)
Computes the vector norm.

Parameters:
type - one of NORM_1, NORM_2, NORM_INFINITY. Also available
NORM_1_AND_2, which computes both norms and stores them
in a two element array.
Returns:
the norm
See Also:
dot(de.jtem.jpetsc.Vec), tDot(de.jtem.jpetsc.Vec), norm(de.jtem.jpetsc.NormType), dotBegin(de.jtem.jpetsc.Vec, double[]), dotEnd(de.jtem.jpetsc.Vec, double[]), normBegin(de.jtem.jpetsc.NormType, double[]), normEnd(de.jtem.jpetsc.NormType, double[])

normalize

public double normalize()
Normalizes a vector by 2-norm.

Returns:
the vector norm before normalization

max

public Vec.MaxResult max()
Determines the maximum vector component and its location.

Returns:
Vec.StrideMaxResult
See Also:
norm(de.jtem.jpetsc.NormType), min()

min

public Vec.MinResult min()
Determines the minimum vector component and its location.

Returns:
Vec.StrideMinResult
See Also:
max()

tDot

public double tDot(Vec y)
Computes an indefinite vector dot product. That is, this
routine does NOT use the complex conjugate.

Parameters:
y - the vectors
Returns:
the dot product
See Also:
dot(de.jtem.jpetsc.Vec), #mTDot

scale

public void scale(double alpha)
Scales a vector.

Parameters:
alpha - the scalar

set

public void set(double alpha)
Sets all components of a vector to a single scalar value.

Parameters:
alpha - the scalar
See Also:
setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), #setRandom

aXPY

public void aXPY(double alpha,
                 Vec x)
Computes y = alpha x + y.

Parameters:
alpha - the scalar
x - the vectors
See Also:
aYPX(double, de.jtem.jpetsc.Vec), mAXPY(int, double[]), wAXPY(double, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

aXPBY

public void aXPBY(double alpha,
                  double beta,
                  Vec x)
Computes y = alpha x + beta y.

Parameters:
alpha - the scalars
beta - the scalars
x - the vectors
See Also:
aYPX(double, de.jtem.jpetsc.Vec), mAXPY(int, double[]), wAXPY(double, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), aXPY(double, de.jtem.jpetsc.Vec)

aYPX

public void aYPX(double alpha,
                 Vec x)
Computes y = x + alpha y.

Parameters:
alpha - the scalar
x - the vectors
See Also:
aXPY(double, de.jtem.jpetsc.Vec), wAXPY(double, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

wAXPY

public void wAXPY(double alpha,
                  Vec x,
                  Vec y)
Computes w = alpha x + y.

Parameters:
alpha - the scalar
x - the vectors
y - the vectors
See Also:
aXPY(double, de.jtem.jpetsc.Vec), aYPX(double, de.jtem.jpetsc.Vec), aXPBY(double, double, de.jtem.jpetsc.Vec)

setValues

public void setValues(int ni,
                      int[] ix,
                      double[] y,
                      InsertMode iora)
Inserts or adds values into certain locations of a vector.
Not Collective

Parameters:
ni - number of elements to add
ix - indices where to add
y - array of values
iora - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(), assemblyEnd(), setValuesLocal(int, int[], double[], de.jtem.jpetsc.InsertMode), setValue(int, double, de.jtem.jpetsc.InsertMode), setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), #InsertMode, #INSERTVALUES, #ADDVALUES, getValues(int, int[], double[])

getValues

public void getValues(int ni,
                      int[] ix,
                      double[] y)
Gets values from certain locations of a vector. Currently
can only get values on the same processor

Parameters:
ni - number of elements to get
ix - indices where to get them from (in global 1d numbering)
y -
See Also:
assemblyBegin(), assemblyEnd(), #getValuesLocal, #getValuesBlocked, #InsertMode, #INSERTVALUES, #ADDVALUES, setValues(int, int[], double[], de.jtem.jpetsc.InsertMode)

setValuesBlocked

public void setValuesBlocked(int ni,
                             int[] ix,
                             double[] y,
                             InsertMode iora)
Inserts or adds blocks of values into certain locations of a vector.
Not Collective

Parameters:
ni - number of blocks to add
ix - indices where to add in block count, rather than element count
y - array of values
iora - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(), assemblyEnd(), setValuesBlockedLocal(int, int[], double[], de.jtem.jpetsc.InsertMode), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode)

setValuesLocal

public void setValuesLocal(int ni,
                           int[] ix,
                           double[] y,
                           InsertMode iora)
Inserts or adds values into certain locations of a vector,
using a local ordering of the nodes.
Not Collective

Parameters:
ni - number of elements to add
ix - indices where to add
y - array of values
iora - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(), assemblyEnd(), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMapping, setValuesBlockedLocal(int, int[], double[], de.jtem.jpetsc.InsertMode)

setValuesBlockedLocal

public void setValuesBlockedLocal(int ni,
                                  int[] ix,
                                  double[] y,
                                  InsertMode iora)
Inserts or adds values into certain locations of a vector,
using a local ordering of the nodes.
Not Collective

Parameters:
ni - number of blocks to add
ix - indices where to add in block count, not element count
y - array of values
iora - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(), assemblyEnd(), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMappingBlock

mAXPY

public Vec mAXPY(int nv,
                 double[] alpha)
Computes y = y + sum alpha[j] x[j]

Parameters:
nv - number of scalars and x-vectors
alpha - array of scalars
See Also:
aXPY(double, de.jtem.jpetsc.Vec), wAXPY(double, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), aYPX(double, de.jtem.jpetsc.Vec)

getArray

public final double[] getArray()
Returns a pointer to a contiguous array that contains this
processor's portion of the vector data. For the standard PETSc
vectors, VecGetArray() returns a pointer to the local data array and
does not use any copies. If the underlying vector data is not stored
in a contiquous array this routine will copy the data to a contiquous
array and return a pointer to that. You MUST call VecRestoreArray()
when you no longer need access to the array.

Returns:
location to put pointer to the array
See Also:
restoreArray(), #getArrays, #getArrayF90, #placeArray, #getArray2d

restoreArray

public void restoreArray()
Restores a vector after VecGetArray() has been called.
Not Collective

See Also:
getArray(), #restoreArrays, #restoreArrayF90, #placeArray, #restoreArray2d

stashGetInfo

public Vec.StashGetInfoResult stashGetInfo()
Gets how many values are currently in the vector stash, i.e. need
to be communicated to other processors during the VecAssemblyBegin/End() process
Not collective

Returns:
Vec.StashGetInfoResult
See Also:
assemblyBegin(), assemblyEnd(), Vec(int), stashSetInitialSize(int, int), stashView()

assemblyBegin

public void assemblyBegin()
Begins assembling the vector. This routine should
be called after completing all calls to VecSetValues().

See Also:
assemblyEnd(), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode)

assemblyEnd

public void assemblyEnd()
Completes assembling the vector. This routine should
be called after VecAssemblyBegin().

See Also:
assemblyBegin(), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode)

pointwiseMax

public void pointwiseMax(Vec x,
                         Vec y)
Computes the componentwise maximum w_i = max(x_i, y_i).

Parameters:
x - the vectors
y - the vectors
See Also:
pointwiseDivide(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMaxAbs(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), maxPointwiseDivide(de.jtem.jpetsc.Vec)

pointwiseMin

public void pointwiseMin(Vec x,
                         Vec y)
Computes the componentwise minimum w_i = min(x_i, y_i).

Parameters:
x - the vectors
y - the vectors
See Also:
pointwiseDivide(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMaxAbs(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), maxPointwiseDivide(de.jtem.jpetsc.Vec)

pointwiseMaxAbs

public void pointwiseMaxAbs(Vec x,
                            Vec y)
Computes the componentwise maximum of the absolute values w_i = max(abs(x_i), abs(y_i)).

Parameters:
x - the vectors
y - the vectors
See Also:
pointwiseDivide(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMax(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), maxPointwiseDivide(de.jtem.jpetsc.Vec)

pointwiseDivide

public void pointwiseDivide(Vec x,
                            Vec y)
Computes the componentwise division w = x/y.

Parameters:
x - the vectors
y - the vectors
See Also:
pointwiseMult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMax(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMaxAbs(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), maxPointwiseDivide(de.jtem.jpetsc.Vec)

duplicate

public Vec duplicate()
Creates a new vector of the same type as an existing vector.

Returns:
location to put new vector
See Also:
destroy(), #duplicateVecs, create(int), copy(de.jtem.jpetsc.Vec)

viewFromOptions

public void viewFromOptions(java.lang.String title)
This function visualizes the vector based upon user options.

Parameters:
title - The title
See Also:
setFromOptions(), view()

view

public void view()
Views a vector object.

See Also:
#PetscViewerASCIIOpen, #PetscViewerDrawOpen, #PetscDrawLGCreate, #PetscViewerSocketOpen, #PetscViewerBinaryOpen, PrimitivNative.load(java.lang.String), #PetscViewerCreate, #PetscRealView, #PetscScalarView, #PetscIntView

getSize

public int getSize()
Returns the global number of elements of the vector.
Not Collective

Returns:
the global length of the vector
See Also:
getLocalSize()

getLocalSize

public int getLocalSize()
Returns the number of elements of the vector stored
in local memory. This routine may be implementation dependent, so use
with care.
Not Collective

Returns:
the length of the local piece of the vector
See Also:
getSize()

getOwnershipRange

public Vec.GetOwnershipRangeResult getOwnershipRange()
Returns the range of indices owned by
this processor, assuming that the vectors are laid out with the
first n1 elements on the first processor, next n2 elements on the
second, etc. For certain parallel layouts this range may not be
well defined.
Not Collective

Returns:
Vec.GetOwnershipRangeResult

loadIntoVector

public void loadIntoVector()
Loads a vector that has been stored in binary format
with VecView().

See Also:
#PetscViewerBinaryOpen, view(), #MatLoad, PrimitivNative.load(java.lang.String)

reciprocal

public void reciprocal()
Replaces each component of a vector by its reciprocal.


stashSetInitialSize

public void stashSetInitialSize(int size,
                                int bsize)
sets the sizes of the vec-stash, that is
used during the assembly process to store values that belong to
other processors.

Parameters:
size - the initial size of the stash.
bsize - the initial size of the block-stash(if used).
See Also:
setBlockSize(int), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), stashView()

conjugate

public void conjugate()
Conjugates a vector.


pointwiseMult

public void pointwiseMult(Vec x,
                          Vec y)
Computes the componentwise multiplication w = x*y.

Parameters:
x - the vectors
y - the vectors
See Also:
pointwiseDivide(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMax(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMin(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), pointwiseMaxAbs(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), maxPointwiseDivide(de.jtem.jpetsc.Vec)

zeroEntries

public void zeroEntries()
puts a 0.0 in each element of a vector

See Also:
create(int), setOptionsPrefix(java.lang.String), set(double), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode)

setFromOptions

public void setFromOptions()
Configures the vector from the options database.

See Also:
create(int), setOptionsPrefix(java.lang.String)

setSizes

public void setSizes(int n,
                     int N)
Sets the local and global sizes, and checks to determine compatibility

Parameters:
n - the local size (or PETSC_DECIDE to have it set)
N - the global size (or PETSC_DECIDE)
See Also:
getSize(), #PetscSplitOwnership

setBlockSize

public void setBlockSize(int bs)
Sets the blocksize for future calls to VecSetValuesBlocked()
and VecSetValuesBlockedLocal().

Parameters:
bs - the blocksize
See Also:
setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMappingBlock, getBlockSize()

getBlockSize

public int getBlockSize()
Gets the blocksize for the vector, i.e. what is used for VecSetValuesBlocked()
and VecSetValuesBlockedLocal().

Returns:
the blocksize
See Also:
setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMappingBlock, setBlockSize(int)

setOptionsPrefix

public void setOptionsPrefix(java.lang.String prefix)
Sets the prefix used for searching for all
Vec options in the database.

Parameters:
prefix - the prefix to prepend to all option names
See Also:
setFromOptions()

appendOptionsPrefix

public void appendOptionsPrefix(java.lang.String prefix)
Appends to the prefix used for searching for all
Vec options in the database.

Parameters:
prefix - the prefix to prepend to all option names
See Also:
#getOptionsPrefix

setUp

public void setUp()
Sets up the internal vector data structures for the later use.

See Also:
create(int), destroy()

copy

public void copy(Vec y)
Copies a vector.

Parameters:
y -
See Also:
duplicate()

swap

public void swap(Vec y)
Swaps the vectors x and y.

Parameters:
y - the vectors

stashView

public void stashView()
Prints the entries in the vector stash and block stash.

See Also:
setBlockSize(int), setValues(int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesBlocked(int, int[], double[], de.jtem.jpetsc.InsertMode)