module type NVECTOR_OPS =sig
..end
Basic operations underlying an nvector.
type
t
The vector type.
val clone : t -> t
Create a new, distinct vector from an existing one.
val linearsum : float ->
t ->
float -> t -> t -> unit
linearsum a x b y z
calculates z = a*x + b*y
.
val const : float -> t -> unit
const c z
sets all of z
to c
.
val prod : t ->
t -> t -> unit
prod x y z
calculates z = x * y
(pointwise).
val div : t ->
t -> t -> unit
div x y z
calculates z = x / y
(pointwise).
val scale : float -> t -> t -> unit
scale c x z
calculates z = c *. x
.
val abs : t -> t -> unit
abs x z
calculates z = abs(x)
.
val inv : t -> t -> unit
inv x z
calculates z = 1/x
(pointwise).
val addconst : t -> float -> t -> unit
addconst x b z
calculates z = x + b
.
val dotprod : t -> t -> float
dotprod x y
returns the dot product of x
and y
.
val maxnorm : t -> float
maxnorm x
returns the maximum absolute value in x.
val wrmsnorm : t -> t -> float
wrmsnorm x w
returns the weighted root-mean-square norm of x
with weight vector w
.
val min : t -> float
min x
returns the smallest element in x
.
val compare : float -> t -> t -> unit
compare c x z
calculates
z(i) = if abs x(i) >= c then 1 else 0
.
val invtest : t -> t -> bool
invtest x z
calculates z(i) = 1 / x(i)
with prior testing for
zero values. This routine returns true
if all components of x
are
nonzero (successful inversion) and false
otherwise (not all elements
inverted).
val wl2norm : t -> t -> float
wl2norm x w
returns the weighted (w
) Euclidean l2 norm of x
.
val l1norm : t -> float
l1norm x
returns the l1 norm of x
.
val wrmsnormmask : t ->
t -> t -> float
maxnormmask x w id
returns the weighted root-mean-square norm
of x
using only elements where the corresponding id
is non-zero.
val constrmask : t ->
t -> t -> bool
constrmask c x m
calculates m(i) = Pi x(i)
returning the
conjunction. The value of Pi
depends on c(i)
: 2: x(i) > 0
,
1: x(i) >= 0
, 0: true
, -1: x(i) <= 0
, and -2: x(i) < 0
.
val minquotient : t -> t -> float
minquotient num denom
returns the minimum of num(i) / denom(i)
.
Zero denom
elements are skipped.
val space : t -> int * int
lrw, liw = space c
returns the number of realtype words lrw
and
integer words liw
required to store c
.
val getlength : t -> int
Returns the number of "active" entries. This value is cumulative across all processes in a parallel environment.
val print : ?logfile:Sundials.Logfile.t -> t -> unit
Prints to the given logfile (stdout, by default).
val linearcombination : Sundials.RealArray.t ->
t array -> t -> unit
linearcombination c x z
calculates
$z_i = \sum_{j=0}^{n_v-1} c_j (x_j)_i$ .
The sum is over the $n_v$ elements of c
and x
.
val scaleaddmulti : Sundials.RealArray.t ->
t ->
t array -> t array -> unit
scaleaddmulti c x y z
scales x
and adds it to the
$n_v$ vectors in y
.
That is,
$\forall j=0,\ldots,n_v-1, (z_j)_i = c_j x_i + (y_j)_i}$ .
val dotprodmulti : t ->
t array -> Sundials.RealArray.t -> unit
dotprodmulti x y d
calculates the dot product of x
with
the $n_v$ elements of y
.
That is, $\forall j=0,\ldots,n_v-1,
d_j = \sum_{i=0}^{n-1} x_i (y_j)_i$ .
val linearsumvectorarray : float ->
t array ->
float -> t array -> t array -> unit
linearsumvectorarray a x b y z
computes the linear sum of the
$n_v$ elements of x
and y
.
That is,
$\forall j=0,\ldots,n_v-1, (z_j)_i = a (x_j)_i + b (y_j)_i$ .
val scalevectorarray : Sundials.RealArray.t ->
t array -> t array -> unit
scalevectorarray c x z
scales each of the $n_v$ vectors
of x
.
That is, $\forall j=0,\ldots,n_v-1, (z_j)_i = c_j (x_j)_i$ .
val constvectorarray : float -> t array -> unit
constvectorarray c x
sets all elements of the $n_v$ nvectors
in x
to c
.
That is, $\forall j=0,\ldots,n_v, (z_j)_i = c$ .
val wrmsnormvectorarray : t array ->
t array -> Sundials.RealArray.t -> unit
wrmsnormvectorarray x w m
computes the weighted root mean
square norm of the $n_v$ vectors in x
and w
.
That is,
$\forall j=0,\ldots,n_v,
m_j = \left( \frac{1}{n}
\sum_{i=0}^{n-1} ((x_j)_i (w_j)_i)^2
\right)^\frac{1}{2}$ ,
where $n$ is the number of elements in each nvector.
val wrmsnormmaskvectorarray : t array ->
t array ->
t -> Sundials.RealArray.t -> unit
wrmsnormmaskvectorarray x w id m
computes the weighted root mean
square norm of the $n_v$ vectors in x
and w
.
That is,
$\forall j=0,\ldots,n_v,
m_j = \left( \frac{1}{n}
\sum_{i=0}^{n-1} ((x_j)_i (w_j)_i H(\mathit{id}_i))^2
\right)^\frac{1}{2}$ ,
where $H(x) = \begin{cases} 1 & \text{if } x > 0 \ 0 & \text{otherwise}
\end{cases}$ and
$n$ is the number of elements in each nvector.
val scaleaddmultivectorarray : Sundials.RealArray.t ->
t array ->
t array array ->
t array array -> unit
scaleaddmultivectorarray a x yy zz
scales and adds $n_v$
vectors in x
across the $n_s$ vector arrays in yy
.
That is, $\forall j=0,\ldots,n_s-1,
\forall k=0,\ldots,n_v-1,
(\mathit{zz}_{j,k})_i = a_k (x_k)_i + (\mathit{yy}_{j,k})_i$ .
val linearcombinationvectorarray : Sundials.RealArray.t ->
t array array -> t array -> unit
linearcombinationvectorarray c xx z
computes the linear
combinations of $n_s$ vector arrays containing $n_v$
vectors.
That is, $\forall k=0,\ldots,n_v-1,
(z_k)_i = \sum_{j=0}^{n_s-1} c_j (x_{j,k})_i$ .
module Local:sig
..end
Compute the task-local portions of certain operations.