/// <summary> /// Finds the node sensitivity. /// </summary> /// <param name="pp"> the <seealso cref="PiecewisePolynomialResultsWithSensitivity"/> </param> /// <param name="xKey"> the key </param> /// <returns> Node sensitivity value at x=xKey </returns> public virtual DoubleArray nodeSensitivity(PiecewisePolynomialResultsWithSensitivity pp, double xKey) { ArgChecker.notNull(pp, "null pp"); ArgChecker.isFalse(double.IsNaN(xKey), "xKey containing NaN"); ArgChecker.isFalse(double.IsInfinity(xKey), "xKey containing Infinity"); if (pp.Dimensions > 1) { throw new System.NotSupportedException(); } DoubleArray knots = pp.Knots; int nKnots = knots.size(); int interval = FunctionUtils.getLowerBoundIndex(knots, xKey); if (interval == nKnots - 1) { interval--; // there is 1 less interval that knots } double s = xKey - knots.get(interval); DoubleMatrix a = pp.getCoefficientSensitivity(interval); int nCoefs = a.rowCount(); DoubleArray res = a.row(0); for (int i = 1; i < nCoefs; i++) { res = (DoubleArray)MA.scale(res, s); res = (DoubleArray)MA.add(res, a.row(i)); } return(res); }
public virtual DoubleMatrix getUpdatedMatrix(System.Func <DoubleArray, DoubleMatrix> g, DoubleArray x, DoubleArray deltaX, DoubleArray deltaY, DoubleMatrix matrix) { ArgChecker.notNull(deltaX, "deltaX"); ArgChecker.notNull(deltaY, "deltaY"); ArgChecker.notNull(matrix, "matrix"); DoubleArray v1 = (DoubleArray)_algebra.multiply(deltaX, matrix); double length = _algebra.getInnerProduct(v1, deltaY); if (length == 0) { return(matrix); } v1 = (DoubleArray)_algebra.scale(v1, 1.0 / length); DoubleArray v2 = (DoubleArray)_algebra.subtract(deltaX, _algebra.multiply(matrix, deltaY)); DoubleMatrix m = _algebra.getOuterProduct(v2, v1); return((DoubleMatrix)_algebra.add(matrix, m)); }