private void getElementInfo(double dTimeFraction, out double dStartTime, out double dEndTime, out double dStartValue, out double dEndValue, out InterpolationMethod eInterpolationMethod) { int count; for (count = m_Elements.Count; m_iCurrentElement < count; ++m_iCurrentElement) { var num = m_Elements[m_iCurrentElement].EndTime / 100.0; if (dTimeFraction < num) { break; } } if (m_iCurrentElement == count) { m_iCurrentElement = count - 1; } dStartTime = 0.0; dStartValue = 0.0; if (m_iCurrentElement > 0) { var element = m_Elements[m_iCurrentElement - 1]; dStartTime = element.EndTime / 100.0; dStartValue = element.EndValue / 100.0; } var element1 = m_Elements[m_iCurrentElement]; dEndTime = element1.EndTime / 100.0; dEndValue = element1.EndValue / 100.0; eInterpolationMethod = element1.InterpolationMethod; }
public static InterpolationMethod Parse(string methodName) { InterpolationMethod interpolationMethod = new InterpolationMethod(); interpolationMethod.Value = methodName; return(interpolationMethod); }
public Rotate(float angle, InterpolationMethod method) { this.method = InterpolationMethod.Bilinear; this.fillColor = Color.FromArgb(0, 0, 0); this.angle = angle; this.method = method; }
internal TermCurve SetConfigurationData() { // The bootstrapper to use if (Holder != null) { var bootstrapper = Holder.GetValue("Bootstrapper"); if (bootstrapper != null) { BootstrapperName = Holder.GetValue("Bootstrapper"); } var extrapolationPermitted = Holder.GetValue("ExtrapolationPermitted"); if (extrapolationPermitted != null) { ExtrapolationPermitted = bool.Parse(extrapolationPermitted); } var interpolation = InterpolationMethodHelper.Parse( Holder.GetValue("BootstrapperInterpolation")); if (interpolation != null) { InterpolationMethod = interpolation; } } var termCurve = new TermCurve { extrapolationPermitted = ExtrapolationPermitted, extrapolationPermittedSpecified = true, interpolationMethod = InterpolationMethod }; return(termCurve); }
internal void CreatePipe(GameObject newCube, Material pipeMaterial, InterpolationMethod interpolationMethod) { var dynamicMesh = new GameObject(); var meshRenderer = dynamicMesh.AddComponent <MeshRenderer>(); meshRenderer.sharedMaterial = pipeMaterial; MeshFilter meshFilter = dynamicMesh.AddComponent <MeshFilter>(); Mesh mesh = GeneratePipe(newCube.transform.position, interpolationMethod); //Vector3[] normals = new Vector3[4] //{ // -Vector3.forward, // -Vector3.forward, // -Vector3.forward, // -Vector3.forward //}; //mesh.normals = normals; //Vector2[] uv = new Vector2[4] //{ // new Vector2(0, 0), // new Vector2(1, 0), // new Vector2(0, 1), // new Vector2(1, 1) //}; //mesh.uv = uv; meshFilter.mesh = mesh; dynamicMesh.transform.SetParent(transform); dynamicMesh.transform.localPosition = Vector3.zero; dynamicMesh.transform.rotation = Quaternion.identity; }
public Rotate(float angle, InterpolationMethod method) { this.method = InterpolationMethod.Bilinear; this.fillColor = Color.FromArgb(0, 0, 0); this.angle = angle; this.method = method; }
/// <summary> /// Create a new instance of the Image2DTransform /// </summary> internal Image2DTransforms() { _transfCoeffMatrix = new Matrix2D(); _transformList = new ArrayList(); _unassignedColor = ColorByte.Empty; _interpolationMethod = new InterpolationMethod(BilinearInterpolator.ProcessPoint); }
public unsafe void SetViewportScaling(int width, int height, InterpolationMethod iMethod) { throw new Exception("feature broken"); if (width <= 2 | height <= 2) { throw new Exception("Invalid Scaling Size"); } lock (ThreadLock) { scaleHeight = height; scaleWidth = width; scaleBufferInitialized = true; ScaleBuffer = Marshal.AllocHGlobal(width * height * 4); BINFO = new BITMAPINFO(); BINFO.bmiHeader.biBitCount = 32; //BITS PER PIXEL BINFO.bmiHeader.biWidth = width; BINFO.bmiHeader.biHeight = height; BINFO.bmiHeader.biPlanes = 1; unsafe { BINFO.bmiHeader.biSize = (uint)sizeof(BITMAPINFOHEADER); } // isScaling = !(width == RenderWidth & height == RenderHeight); } }
public Resize(int newWidth, int newHeight, InterpolationMethod method) { this.method = InterpolationMethod.Bilinear; this.newWidth = newWidth; this.newHeight = newHeight; this.method = method; }
private Point Interpolate(Point pt, InterpolationMethod method) { if (pt.IsMissing) { return(new Point(pt.DateTime, Point.MissingValueFlag)); } if (pt.Value > MaxXValue()) { return(new Point(pt.DateTime, Point.MissingValueFlag)); } if (pt.Value < MinXValue()) { // if first value in table computes zero, then extrapolate a zero. if (System.Math.Abs(MinYValue()) < 0.01) { return(new Point(pt.DateTime, 0, PointFlag.Edited)); } return(new Point(pt.DateTime, Point.MissingValueFlag)); } var d = Math.Interpolate(this, pt.Value, this.columnx.ColumnName, this.columny.ColumnName, method); return(new Point(pt.DateTime, d)); }
/// <summary> /// Applies the appropriate transformation to the t parameter based on the interpolation method. /// </summary> private static float TimeScale(float t, InterpolationMethod method) { float tPrime = Mathf.Clamp01(t); switch (method) { case InterpolationMethod.Linear: return(tPrime); case InterpolationMethod.Quadratic: return(tPrime * tPrime); case InterpolationMethod.SquareRoot: return(Mathf.Sqrt(Mathf.Clamp01(t))); case InterpolationMethod.Sinusoidal: tPrime *= Mathf.PI; return((1f - Mathf.Cos(tPrime)) / 2); case InterpolationMethod.Cubic: tPrime = (2 * tPrime - 1); tPrime = tPrime * tPrime * tPrime + 1; return(tPrime / 2); default: return(tPrime); } }
/// <summary> /// Compute values using a RatingTableDataTable /// for example compute flows based on gage height input series /// </summary> /// <param name="s"></param> /// <param name="fileName">rating table filename</param> /// <returns></returns> public static Series ComputeSeries(Series s, string fileName, InterpolationMethod method = InterpolationMethod.None) { var rval = new Series(); Logger.WriteLine("RatingTableDataTable.ComputeSeries(" + s.Table.TableName + "," + fileName + ")"); var fn = RatingTableUtility.GetRatingTableAsLocalFile(fileName); if (!File.Exists(fn)) { string msg = "Error: File not found " + fn; Console.WriteLine(msg); Logger.WriteLine(msg); rval.TimeInterval = s.TimeInterval; return(rval); } var rt = new RatingTableDataTable(); rt.ReadFile(fn); rval = rt.Lookup(s, method); rval.TimeInterval = s.TimeInterval; return(rval); }
public Resize(int newWidth, int newHeight, InterpolationMethod method) { this.method = InterpolationMethod.Bilinear; this.newWidth = newWidth; this.newHeight = newHeight; this.method = method; }
public TrackingData CloneDataWithConstantInterval(double interval, InterpolationMethod interpolationMethod = InterpolationMethod.Cubic) { if (interval <= 0.0) { throw new ArgumentException("Interval must be a positive value."); } int capacity = (int)(Duration / interval); TrackingData newData = new TrackingData(capacity); double time = 0.0; int index = 0; while (time < Duration) { // update index to the correct entry we should work off of at the given time while (index < NumberOfEntries && time >= m_entries[index].TimeStamp) { index++; } // build entry and add it to new data TrackingEntry entry = GetDataAtTimeAndIndex(time, index, interpolationMethod); newData.PushEntry(interval, entry.Position, entry.Rotation); // advance time to next interval time += interval; } return(newData); }
/// <summary> /// Bootstraps the specified priceable assets. /// </summary> /// <param name="priceableAssets">The priceable assets.</param> /// <param name="baseDate">The base date.</param> /// <param name="extrapolationPermitted">The extrapolationPermitted flag.</param> /// <param name="interpolationMethod">The interpolationMethod.</param> /// <param name="tolerance">Solver tolerance to use.</param> /// <returns></returns> public static TermPoint[] Bootstrap(List <IPriceableBondAssetController> priceableAssets, DateTime baseDate, Boolean extrapolationPermitted, InterpolationMethod interpolationMethod, Double tolerance) { priceableAssets.Sort ( (priceableAssetController1, priceableAssetController2) => priceableAssetController1.GetRiskMaturityDate().CompareTo(priceableAssetController2.GetRiskMaturityDate()) ); var points = new Dictionary <DateTime, double>(); var items = new Dictionary <DateTime, Pair <string, decimal> >(); foreach (var priceableAsset in priceableAssets) { var assetMaturityDate = priceableAsset.GetRiskMaturityDate(); if (points.Keys.Contains(assetMaturityDate)) { continue; } decimal guess = priceableAsset.QuoteValue; //decimal dfam; //only works for linear on zero. //var interp = InterpolationMethodHelper.Parse("LinearInterpolation"); //var curve = new SimpleBondCurve(baseDate, interp, extrapolationPermitted, points); //var dfam = priceableAsset.CalculateImpliedQuote(curve); points.Add(assetMaturityDate, (double)guess);//dfam items.Add(assetMaturityDate, new Pair <string, decimal>(priceableAsset.Id, (decimal)points[assetMaturityDate])); } return(TermPointsFactory.Create(items)); }
public AttributeAnimation(XmlElement elem) { name_ = elem.GetAttribute("name"); speed_ = float.Parse(elem.GetAttribute("speed")); splineTension_ = float.Parse(elem.GetAttribute("splinetension")); string interp = elem.GetAttribute("interpolation").ToLowerInvariant(); string wrapmode = elem.GetAttribute("wrapmode").ToLowerInvariant(); if (interp.Equals("linear")) { interp_ = InterpolationMethod.Linear; } else if (interp.Equals("linear")) { interp_ = InterpolationMethod.Spline; } if (wrapmode.Equals("clamp")) { wrap_ = AnimWrapMode.Clamp; } else if (wrapmode.Equals("loop")) { wrap_ = AnimWrapMode.Loop; } else if (wrapmode.Equals("once")) { wrap_ = AnimWrapMode.Once; } foreach (XmlElement keyelem in elem.GetElementsByTagName("keyframe")) { Keyframes.Add(new Keyframe(keyelem)); } }
/// <summary> /// Bootstraps the specified priceable assets. /// </summary> /// <param name="priceableAssets">The priceable assets.</param> /// <param name="baseDate">The base date.</param> /// <param name="extrapolationPermitted">The extrapolationPermitted flag.</param> /// <param name="interpolationMethod">The interpolationMethod.</param> /// <param name="tolerance">Solver tolerance to use.</param> /// <returns></returns> public static TermPoint[] Bootstrap(IEnumerable <IPriceableRateAssetController> priceableAssets, DateTime baseDate, Boolean extrapolationPermitted, InterpolationMethod interpolationMethod, Double tolerance) { const double defaultGuess = 0.9; const double min = 0.000000001; const double max = 2; //only works for linear on zero. InterpolationMethod interp = InterpolationMethodHelper.Parse("LogLinearInterpolation"); // Add the first element (date : discount factor) to the list var points = new Dictionary <DateTime, double> { { baseDate, 1d } }; var items = new Dictionary <DateTime, Pair <string, decimal> > { { baseDate, new Pair <string, decimal>("", 1m) } }; var solver = new Brent(); bool first = true; // Add the rest foreach (IPriceableRateAssetController priceableAsset in priceableAssets) { DateTime assetMaturityDate = priceableAsset.GetRiskMaturityDate(); if (points.Keys.Contains(assetMaturityDate)) { continue; } if (assetMaturityDate < points.Keys.Last()) { throw new InvalidOperationException("The maturity dates of the assets must be consecutive order"); } if (first) { first = false; // Add the first point points.Add(assetMaturityDate, defaultGuess); var curve = new SimpleDiscountFactorCurve(baseDate, interp, extrapolationPermitted, points); points[assetMaturityDate] = (double)priceableAsset.CalculateDiscountFactorAtMaturity(curve); } else { //This now should automatically extrapolate the required discount factor on a flat rate basis. var curve = new SimpleDiscountFactorCurve(baseDate, interp, extrapolationPermitted, points); //The first guess, which should be correct for all priceable assets with analytical solutions that have been implemented. points.Add(assetMaturityDate, (double)priceableAsset.CalculateDiscountFactorAtMaturity(curve)); } var objectiveFunction = new RateAssetQuote(priceableAsset, baseDate, interpolationMethod, extrapolationPermitted, points, tolerance); // Check whether the guess was close enough if (!objectiveFunction.InitialValue()) { double guess = Math.Max(min, points[assetMaturityDate]); points[assetMaturityDate] = solver.Solve(objectiveFunction, tolerance, guess, min, max); } items.Add(assetMaturityDate, new Pair <string, decimal>(priceableAsset.Id, (decimal)points[assetMaturityDate])); } return(TermPointsFactory.Create(items)); }
private void OnQuaternionClick() { Vector3 euler = new Vector3(CurXSlider.value, CurYSlider.value, CurZSlider.value); quaternionCache = Quaternion.Euler(euler); curMethod = InterpolationMethod.QuaternionRotation; Play(); }
public override float GetValue(float x, float z, float length, InterpolationMethod method) { float xT = x / length; float x0 = LinearInterpolation(values[0, 0], values[1, 0], xT); float x1 = LinearInterpolation(values[0, 1], values[1, 1], xT); return(LinearInterpolation(x0, x1, z / length)); }
/// <summary> /// Bootstraps the specified priceable assets. /// </summary> /// <param name="priceableAssets">The priceable assets.</param> /// <param name="baseDate">The base date.</param> /// <param name="extrapolationPermitted">The extrapolationPermitted flag.</param> /// <param name="interpolationMethod">The interpolationMethod.</param> /// <param name="tolerance">Solver tolerance to use.</param> /// <returns></returns> public static TermPoint[] Bootstrap(List <IPriceableFxAssetController> priceableAssets, DateTime baseDate, Boolean extrapolationPermitted, InterpolationMethod interpolationMethod, Double tolerance) { const Double solveRateGap = 0.015d;//should we need more precising perhaps??? const Decimal dfamMinThreshold = 0.0m; const Decimal defaultGuess = 0.9m; const Double accuracy = 0.000001d; InterpolationMethod interp = InterpolationMethodHelper.Parse("LinearInterpolation"); //only works for linear on zero. priceableAssets = priceableAssets.OrderBy(a => a.GetRiskMaturityDate()).ToList(); var dates = new List <DateTime>(); var discountFactors = new List <double>(); var items = new Dictionary <DateTime, Pair <string, decimal> >(); bool firstTime = true; foreach (var asset in priceableAssets) { DateTime assetMaturityDate = asset.GetRiskMaturityDate(); //check if the maturity date is already in the list. If not contimue. if (items.ContainsKey(assetMaturityDate)) { continue; } decimal guess = asset.ForwardAtMaturity > dfamMinThreshold ? asset.ForwardAtMaturity : defaultGuess; decimal dfam; if (firstTime) { firstTime = false; dates.Add(assetMaturityDate); discountFactors.Add(Convert.ToDouble(guess)); dfam = asset.CalculateImpliedQuote(new SimpleFxCurve(baseDate, interp, extrapolationPermitted, dates, discountFactors)); discountFactors[0] = (double)dfam; } else { //The first guess, which should be correct for all priceable assets with analytical solutions that have been implemented. //So far this is only wrt Depos and Futures...This now should automatically extrapolate the required discount factor on a flat rate basis. dfam = asset.CalculateImpliedQuote(new SimpleFxCurve(baseDate, interp, extrapolationPermitted, dates, discountFactors)); discountFactors.Add((double)dfam); dates.Add(assetMaturityDate); } //Add a check on the dfam so that the solver is only called if outside the tolerance. var objectiveFunction = new FxAssetQuote(asset, baseDate, interpolationMethod, extrapolationPermitted, dates, discountFactors, tolerance); if (!objectiveFunction.InitialValue()) { var timeInterval = Actual365.Instance.YearFraction(baseDate, assetMaturityDate); var solveInterval = Math.Exp(-solveRateGap * timeInterval); var min = Math.Max(0, (double)dfam * solveInterval); var max = (double)dfam / solveInterval; var solver = new Brent(); dfam = (decimal)solver.Solve(objectiveFunction, accuracy, (double)dfam, min, max); } items.Add(assetMaturityDate, new Pair <string, decimal>(asset.Id, dfam)); } return(TermPointsFactory.Create(items)); }
/// <summary> /// Create a series of CapFloor engines from a raw volatility grid and a DF curve /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The client namespace</param> /// <param name="properties">The properties of the engine, including the reference handle to access this engine collection</param> /// <param name="instruments">An array of instrument types.</param> /// <param name="rawVolatilityGrid">The raw grid used to build the engines. Assume that all volatility and strike values are 100x true</param> /// <param name="dfDataTimeGrid">The discount factor dates array.</param> /// <param name="dfGrid">The discount factors required for bootstrapping</param> /// <returns>The engine handle or an error message</returns> public string CreateCapFloorATMCurve(ILogger logger, ICoreCache cache, string nameSpace, NamedValueSet properties, String[] instruments, Decimal[] rawVolatilityGrid, DateTime[] dfDataTimeGrid, Decimal[] dfGrid) { var volatilityCheck = CheckVolatilities(rawVolatilityGrid); if (volatilityCheck != null) { throw new ArgumentException(volatilityCheck); } var id = properties.GetString("EngineHandle", true); var baseDate = properties.GetValue <DateTime>("BaseDate", true); var valuationDate = properties.GetValue("ValuationDate", DateTime.MinValue); if (valuationDate == DateTime.MinValue) { properties.Set("ValuationDate", baseDate); } properties.Set("PricingStructureType", PricingStructureTypeEnum.CapVolatilityCurve.ToString()); var strikeQuoteUnits = properties.GetString("StrikeQuoteUnits", null); if (strikeQuoteUnits == null) { properties.Set("StrikeQuoteUnits", StrikeQuoteUnitsEnum.ATMFlatMoneyness.ToString()); } var measureType = properties.GetString("MeasureType", null); if (measureType == null) { properties.Set("MeasureType", MeasureTypesEnum.Volatility.ToString()); } var quoteUnits = properties.GetString("QuoteUnits", null); if (quoteUnits == null) { properties.Set("QuoteUnits", QuoteUnitsEnum.LogNormalVolatility.ToString()); } var algorithm = properties.GetString("Algorithm", null); if (algorithm == null) { properties.Set("Algorithm", "Default"); } InterpolationMethod interp = InterpolationMethodHelper.Parse("LogLinearInterpolation"); // Check there are valid strikes IRateCurve discountCurve = new SimpleDiscountFactorCurve(baseDate, interp, true, dfDataTimeGrid, dfGrid); // Create the engines and either add to, or overwrite the existing, collection if (_capFloorEngine.ContainsKey(id)) { _capFloorEngine[id] = CreateCurves(logger, cache, nameSpace, properties, discountCurve, discountCurve, instruments, rawVolatilityGrid); } else { _capFloorEngine.Add(id, CreateCurves(logger, cache, nameSpace, properties, discountCurve, discountCurve, instruments, rawVolatilityGrid)); } return(id); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Interpolator() { lock (_syncRoot) { _count = 10; _interpolationMethod = InterpolationMethod.Linear; Recalculate(); } }
/// <summary> /// Initializes a new instance of the <see cref="Interpolator"/> class. /// </summary> /// <param name="count">The count.</param> /// <param name="mode">The mode.</param> public Interpolator(int count, InterpolationMethod mode) { lock (_syncRoot) { _count = count; _interpolationMethod = mode; Recalculate(); } }
public override float GetValue(float x, float z, float length, InterpolationMethod method) { float xT = (float)x / length; float x0 = SmootherSplineInterpolation(values[0, 0], values[1, 0], values[2, 0], xT); float x1 = SmootherSplineInterpolation(values[0, 1], values[1, 1], values[2, 1], xT); float x2 = SmootherSplineInterpolation(values[0, 2], values[1, 2], values[2, 2], xT); return(SmootherSplineInterpolation(x0, x1, x2, (float)z / length)); }
public Interpolator(int count, InterpolationMethod mode) { lock(SyncRoot) { _Count = count; _InterpolationMethod = mode; Recalculate(); } }
public Interpolator() { lock(SyncRoot) { _Count = 10; _InterpolationMethod = InterpolationMethod.Linear; Recalculate(); } }
public ZipfDistribution(int n, double alpha, int k, double epsilon, InterpolationMethod interpolateBy = InterpolationMethod.Hyperbolic) { N = n; Alpha = alpha; K = Max(2, k); C = Normalize(); Epsilon = epsilon; InterpolateBy = interpolateBy; InitInterpolation(); }
public TrackingEntry GetDataAtTime(double time, InterpolationMethod interpolationMethod = InterpolationMethod.Cubic) { if (IsEmpty) { return(null); } int index = FindIndexAtTimeRec(time, 0, NumberOfEntries); return(GetDataAtTimeAndIndex(time, index, interpolationMethod)); }
private static TermCurve ConvertTermCurve(TermCurve termCurve, DateTime baseDate, DateTime[] turnDates, IDayCounter dayCounter) { var interpolationMethod = new InterpolationMethod { Value = "PiecewiseConstantRateInterpolation" }; termCurve.interpolationMethod = interpolationMethod; return(InterpolateTurnPoints(termCurve, turnDates, baseDate, dayCounter));//Add the extra points.. }
/// <summary> /// Initializes a new instance of the <see cref="RateAssetQuote"/> class. /// </summary> /// <param name="priceableAsset">The priceable asset.</param> /// <param name="baseDate">The base date.</param> /// <param name="interpolation">The interpolation.</param> /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param> /// <param name="dfs">The discount factors.</param> /// <param name="tolerance">The tolerance.</param> public CommodityAssetQuote(IPriceableCommodityAssetController priceableAsset, DateTime baseDate, InterpolationMethod interpolation, bool extrapolation, IDictionary <DateTime, double> dfs, double tolerance) { PriceableAsset = priceableAsset; BaseDate = baseDate; Dfs = dfs; InterpolationMethod = interpolation; Extrapolation = extrapolation; Tolerance = tolerance; }
public Image <Rgba32> ScaleTo(Image <Rgba32> image, float scale, InterpolationMethod im) { var scaledImage = new Image <Rgba32>((int)Math.Ceiling(scale * image.Width), (int)Math.Ceiling(scale * image.Height)); for (var y = 0; y < scaledImage.Height; ++y) { for (var x = 0; x < scaledImage.Width; ++x) { var sourceX = (int)Math.Round(x / scale); var sourceY = (int)Math.Round(y / scale); switch (im) { case InterpolationMethod.NearestNeighbour: scaledImage[x, y] = image[sourceX, sourceY]; break; case InterpolationMethod.Billinear: var floorX = (int)Math.Floor(x / scale); var floorY = (int)Math.Floor(y / scale); var ceilX = (int)Math.Ceiling(x / scale); var ceilY = (int)Math.Ceiling(y / scale); var fractionX = x / scale - floorX; var fractionY = y / scale - floorY; var fractionXRev = 1 - fractionX; var fractionYRev = 1 - fractionY; var c1 = image[floorX, floorY]; var c2 = image[ceilX, floorY]; var c3 = image[floorX, ceilY]; var c4 = image[ceilX, ceilY]; // Red var red1 = (byte)(fractionXRev * c1.R + fractionX * c2.R); var red2 = (byte)(fractionXRev * c3.R + fractionX * c4.R); var r = (byte)(fractionYRev * red1 + fractionY * red2); // Green var green1 = (byte)(fractionXRev * c1.G + fractionX * c2.G); var green2 = (byte)(fractionXRev * c3.G + fractionX * c4.G); var g = (byte)(fractionYRev * green1 + fractionY * green2); // Blue var blue1 = (byte)(fractionXRev * c1.B + fractionX * c2.B); var blue2 = (byte)(fractionXRev * c3.B + fractionX * c4.B); var b = (byte)(fractionYRev * blue1 + fractionY * blue2); scaledImage[x, y] = new Rgba32(r, g, b); break; } } } return(scaledImage); }
public override float GetValue(float x, float z, float length, InterpolationMethod method) { float xT = (float)x / length; float x0 = LinearSplineInterpolation(values[0, 0], values[1, 0], values[2, 0], values[3, 0], xT); float x1 = LinearSplineInterpolation(values[0, 1], values[1, 1], values[2, 1], values[3, 1], xT); float x2 = LinearSplineInterpolation(values[0, 2], values[1, 2], values[2, 2], values[3, 2], xT); float x3 = LinearSplineInterpolation(values[0, 3], values[1, 3], values[2, 3], values[3, 3], xT); return(LinearSplineInterpolation(x0, x1, x2, x3, z / length)); }
/// <summary> /// Initializes a new instance of the <see cref="Interpolator"/> class. /// </summary> /// <param name="minimum">The minimum.</param> /// <param name="maximum">The maximum.</param> /// <param name="count">The count.</param> /// <param name="mode">The mode.</param> public Interpolator(double minimum, double maximum, int count, InterpolationMethod mode) { lock (_syncRoot) { _minimum = minimum; _maximum = maximum; _count = count; _interpolationMethod = mode; Recalculate(); } }
/// <summary> /// Initializes a new instance of the <see cref="RateAssetQuote"/> class. /// </summary> /// <param name="priceableAsset">The priceable asset.</param> /// <param name="baseDate">The base date.</param> /// <param name="interpolation">The interpolation.</param> /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param> /// <param name="dfs">The discount factors.</param> /// <param name="tolerance">The tolerance.</param> public RateAssetQuote(IPriceableRateAssetController priceableAsset, DateTime baseDate, InterpolationMethod interpolation, bool extrapolation, IDictionary <DateTime, double> dfs, double tolerance) { PriceableAsset = priceableAsset; BaseDate = baseDate; Dfs = dfs; InterpolationMethod = interpolation; Extrapolation = extrapolation; Tolerance = tolerance; Quote = MarketQuoteHelper.NormalisePriceUnits(PriceableAsset.MarketQuote, "DecimalRate").value; }
/// <summary> /// 1D interpolation /// </summary> /// <param name="x">Vector of X values of the function to interpolate</param> /// <param name="y">Vector of Y values of the function to interpolate</param> /// <param name="xi">Vector of X values at which interpolated Y values are required</param> /// <param name="method">Interpolation method: InterpolationMethod.Linear, HermiteCubic or MonotoneHermiteCubicSpline</param> /// <returns>Numeric array with specified inner element type</returns> public static ILArray<double> interp1(ILArray<double> x, ILArray<double> y, ILArray<double> xi, InterpolationMethod method) { ILCurve<double> curve = new ILCurve<double>(x, y); switch (method) { case InterpolationMethod.Linear: return curve.GetValuesLinear(xi); case InterpolationMethod.CubicSpline: return curve.GetValuesCubicSpline(xi); case InterpolationMethod.MonotoneHermiteCubicSpline: return curve.GetValuesCubicSpline(xi); default: return curve.GetValuesLinear(xi); } }
public Rotate(float angle, InterpolationMethod method) { this.angle = angle; this.method = method; }
/// <summary> /// Creates a new instance using the specified end points, count, and interpolation technique. /// </summary> /// <param name="minimum">The starting point of the interpolated series.</param> /// <param name="maximum">The ending point of the interpolated series.</param> /// <param name="count">The number of points to calculate between the start and end.</param> /// <param name="mode">The interpolation technique to use for calculating intermediate points.</param> ////[CLSCompliant(false)] public Interpolator2D(Position minimum, Position maximum, int count, InterpolationMethod mode) : this(minimum, maximum, count) { _InterpolationMethod = mode; Recalculate(); }
public Interpolator2D(int count, InterpolationMethod mode) { _Count = count; _InterpolationMethod = mode; Recalculate(); }
public static extern IntPtr imaqInterpolatePoints(IntPtr image, ref Point points, int numPoints, InterpolationMethod method, int subpixel, ref int interpCount);
/// <summary> /// Returns the element info for the time-fraction passed in. /// </summary> private void getElementInfo(double dTimeFraction, out double dStartTime, out double dEndTime, out double dStartValue, out double dEndValue, out InterpolationMethod eInterpolationMethod) { // We need to return the start and end values for the current element. So this // means finding the element for the time passed in as well as the previous element. // We hold the 'current' element as a hint. This was in fact the // element used the last time this function was called. In most cases // it will be the same one again, but it may have moved to a subsequent // on (maybe even skipping elements if enough time has passed)... int iCount = m_Elements.Count; for (; m_iCurrentElement < iCount; ++m_iCurrentElement) { TransitionElement element = m_Elements[m_iCurrentElement]; double dElementEndTime = element.EndTime / 100.0; if (dTimeFraction < dElementEndTime) { break; } } // If we have gone past the last element, we just use the last element... if (m_iCurrentElement == iCount) { m_iCurrentElement = iCount - 1; } // We find the start values. These come from the previous element, except in the // case where we are currently in the first element, in which case they are zeros... dStartTime = 0.0; dStartValue = 0.0; if (m_iCurrentElement > 0) { TransitionElement previousElement = m_Elements[m_iCurrentElement - 1]; dStartTime = previousElement.EndTime / 100.0; dStartValue = previousElement.EndValue / 100.0; } // We get the end values from the current element... TransitionElement currentElement = m_Elements[m_iCurrentElement]; dEndTime = currentElement.EndTime / 100.0; dEndValue = currentElement.EndValue / 100.0; eInterpolationMethod = currentElement.InterpolationMethod; }
public Interpolator(double minimum, double maximum, int count, InterpolationMethod mode) { lock(SyncRoot) { _Minimum = minimum; _Maximum = maximum; _Count = count; _InterpolationMethod = mode; Recalculate(); } }
/// <summary> /// Creates an interpolator that interpolates from the specified 'startValue' to /// the 'endValue' in the specified duration of time using the specified interpolation /// method. /// </summary> /// <param name="startValue">The start value</param> /// <param name="endValue">The end value</param> /// <param name="duration">The duration of time in milliseconds</param> /// <param name="method">The interpolation method</param> public Interpolator(double startValue, double endValue, long duration, InterpolationMethod method) { this.startValue = startValue; this.endValue = endValue; this.duration = duration; this.method = method; done = false; started = false; logBase = Math.E; }
public static extern int imaqUnwrapImage(IntPtr dest, IntPtr source, Annulus annulus, RectOrientation orientation, InterpolationMethod method);
public Rotate() { this.method = InterpolationMethod.Bilinear; this.fillColor = Color.FromArgb(0, 0, 0); }
public Resize() { this.method = InterpolationMethod.Bilinear; }
public Rotate(float angle, InterpolationMethod method, bool keepSize) { this.angle = angle; this.method = method; this.keepSize = keepSize; }
/// <summary> /// Specifies a gradient fill used by subsequent calls to other Graphics methods (such as <see cref="lineTo"/>() or <see cref="drawCircle"/>()) for the object. /// </summary> public void beginGradientFill(string type, uint[] colors, float[] alphas, int[] ratios, Matrix matrix, SpreadMethod spreadMethod, InterpolationMethod interpolationMethod) { return; }
public ImageTransformer(InterpolationMethod method = InterpolationMethod.Linear, int r = 1) { UsedInterpolationMethod = method; InterpolationRadius = r; }
/// <summary> /// Creats a new InterpolationController. /// </summary> /// <param name="game">The game.</param> /// <param name="source">The source animation.</param> /// <param name="interpMethod">The interpolation method.</param> public InterpolationController(Game game, AnimationInfo source, InterpolationMethod interpMethod) : base(game, source) { this.interpMethod = interpMethod; }
/// <summary> /// Constructor. /// </summary> public TransitionElement(double endTime, double endValue, InterpolationMethod interpolationMethod) { EndTime = endTime; EndValue = endValue; InterpolationMethod = interpolationMethod; }
public static extern int imaqResample(IntPtr dest, IntPtr source, int newWidth, int newHeight, InterpolationMethod method, Rect rect);