public abstract class PenaltyMatrixGenerator extends Object
| Constructor and Description |
|---|
PenaltyMatrixGenerator() |
| Modifier and Type | Method and Description |
|---|---|
static DoubleArray |
flattenMatrix(DoubleMatrix aMatrix)
for a matrix {{A_{0,0}, A_{0,1},...._A_{0,m},{A_{1,0}, A_{1,1},...._A_{1,m},...,{A_{n,0}, A_{n,1},...._A_{n,m}}
flattened to a vector {A_{0,0}, A_{0,1},...._A_{0,m}, A_{1,0}, A_{1,1},...._A_{1,m},...,A_{n,0}, A_{n,1},...._A_{n,m}}.
|
static DoubleMatrix |
getDerivativeMatrix(double[] x,
int k,
boolean includeEnds)
Get the kth order finite difference derivative matrix, D_k(x), for a non-uniform set of points.
|
static DoubleMatrix |
getDifferenceMatrix(int m,
int k)
get the k^th order difference matrix, D, which acts on a vector, x, of length m to produce the k^th order
difference vector.
|
static DoubleMatrix |
getMatrixForFlattened(int[] numElements,
DoubleMatrix m,
int index)
Assume a tensor has been flattened to a vector as
{A_{0,0}, A_{0,1},...._A_{0,m}, A_{1,0}, A_{1,1},...._A_{1,m},...,A_{n,0}, A_{n,1},...._A_{n,m}}
(see
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly. |
static DoubleMatrix |
getPenaltyMatrix(double[][] x,
int[] k,
double[] lambda)
Get a penalty for a non-uniform grid whose values have been flattened to a vector.
|
static DoubleMatrix |
getPenaltyMatrix(double[][] x,
int k,
int index)
Get a kth order penalty matrix for a non-uniform grid whose values have been flattened to a vector.
|
static DoubleMatrix |
getPenaltyMatrix(double[] x,
int k)
get a k^th order penalty matrix,P, for a non-uniform grid, x.
|
static DoubleMatrix |
getPenaltyMatrix(int[] numElements,
int[] k,
double[] lambda)
Assume a tensor has been flattened to a vector as
{A_{0,0}, A_{0,1},...._A_{0,m}, A_{1,0}, A_{1,1},...._A_{1,m},...,A_{n,0}, A_{n,1},...._A_{n,m}}
(see
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly. |
static DoubleMatrix |
getPenaltyMatrix(int[] numElements,
int k,
int index)
Assume a tensor has been flattened to a vector as
{A_{0,0}, A_{0,1},...._A_{0,m}, A_{1,0}, A_{1,1},...._A_{1,m},...,A_{n,0}, A_{n,1},...._A_{n,m}}
(see
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly. |
static DoubleMatrix |
getPenaltyMatrix(int m,
int k)
get the k^th order penalty matrix, P.
|
public static DoubleMatrix getDifferenceMatrix(int m, int k)
For example, for x = {x1,x2,....xn}, D_1 * x = {0, x2-x1, x3-x2,...., xn - x(n-1)} and D_2 * x = {0,0, x3-2*x2+x1,....,xn-2*x(n-1)+x(n-2)} etc
m - Length of the vectork - Difference order. Require m > kpublic static DoubleMatrix getPenaltyMatrix(int m, int k)
m - Length of the vector.k - Difference order. Require m > kpublic static DoubleMatrix getPenaltyMatrix(int[] numElements, int k, int index)
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly.
This produces a penalty matrix that acts on a given set of indexes onlyTo produce a penalty matrix that acts on multiple indexes, produce one for each set of indexes and add them together (scaling if necessary).
numElements - The range of each index. In the example above, this would be {n,m}k - Difference order. Require size[indices] > kindex - Which set of indices does the matrix act onpublic static DoubleMatrix getPenaltyMatrix(int[] numElements, int[] k, double[] lambda)
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly.
This produces the sum of penalty matrices (or order given by k) with each scaled by lambda.numElements - The range of each index. In the example above, this would be {n,m}k - The difference order for each dimensionlambda - The scaling for each dimensionpublic static DoubleMatrix getDerivativeMatrix(double[] x, int k, boolean includeEnds)
K = 0, trivially return the identity matrix; for k = 1 and 2, this is a three point estimate. K > 2 is not implemented
x - A non-uniform set of pointsk - The order Only first and second order are currently implementedincludeEnds - If true the matrix includes an estimate for the derivative at the end points; if false
the first and last rows of the matrix are emptypublic static DoubleMatrix getPenaltyMatrix(double[] x, int k)
Note: In certain applications we may need an estimate of $\frac{1}{b-a}\int_a^b \left(\frac{d^k y}{dx^k}\right)^2 dx$ i.e. the RMS value of the k^th order derivative, between a & b - for a uniform x this forms a crude approximation.
x - A non-uniform set of pointsk - order The order Only first and second order are currently implementedpublic static DoubleMatrix getPenaltyMatrix(double[][] x, int k, int index)
x - the grid positions in each dimensionk - the (finite difference) orderindex - which index to act onpublic static DoubleMatrix getPenaltyMatrix(double[][] x, int[] k, double[] lambda)
x - the grid positions in each dimensionk - the (finite difference) order in each dimensionlambda - the strength of the penalty in each dimensionpublic static DoubleArray flattenMatrix(DoubleMatrix aMatrix)
aMatrix - A matrixpublic static DoubleMatrix getMatrixForFlattened(int[] numElements, DoubleMatrix m, int index)
flattenMatrix(com.opengamma.strata.collect.array.DoubleMatrix)) that is, the last index changes most rapidly.
Given a matrix, M, that acts on the elements of one index only, i.e.
$$y_{i, i_1, i_2, \dots,i_{k-1}, i_{k+1},\dots, i_n} = \sum_{i_k=0}^{N_k-1} M_{i,i_k} x_{i_1, i_2, \dots,i_k,\dots, i_n} $$
form the larger matrix that acts on the flattened vector.numElements - The number of elements in each index. In the example above, this would be {n,m}m - the matrix Mindex - Which index does the matrix act onCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.