Report a bug
		
				If you spot a problem with this page, click here to create a GitHub issue.
		
			Improve this page
		
			Quickly fork, edit online, and submit a pull request for this page.
			Requires a signed-in GitHub account. This works well for small changes.
			If you'd like to make larger changes you may want to consider using
			a local clone.
		
	mir.random.flex.internal.types
- structInterval(S) if (isFloatingPoint!S);
- Major data unit of the Flex algorithm. It is used to store - (cached) values of the transformation (and its derivatives) - area below the hat and squeeze function - linked-list like reference to the right part of the interval (there will always be exactly one interval with right = 0)- Slx;
- left position of the interval
- Srx;
- right position of the interval
- Sc;
- T_c family of the interval
- Sltx;
- transformed left value of lx
- Slt1x;
- transformed value of the first derivate of the left lx value
- Slt2x;
- transformed value of the second derivate of the left lx value
- Srtx;
- transformed right value of rx
- Srt1x;
- transformed value of the first derivate of the right rx value
- Srt2x;
- transformed value of the second derivate of the right rx value
- LinearFun!Shat;
- hat function of the interval
- LinearFun!Ssqueeze;
- squeeze function of the interval
- ShatArea;
- calculated area of the integrated hat function
- SsqueezeArea;
- calculated area of the integrated squeeze function
- stringlogHex();
 
- enumFunType: int;
- Notations of different function types according to Botts et al. (2013). It is based on this naming scheme:- a: concAve - b: convex - Type 4 is the pure case without any inflection point
- FunTypedetermineType(S)(in Interval!Siv);
- Determine the function type of an interval. Based on Theorem 1 of the Flex paper.Parameters:Interval!S ivinterval 
- structLinearFun(S);
- Representation of linear function of the form:y = slope * (x - y) + a This representation allows a bit higher precision than the typical representation y = slope * x + a.- Sslope;
- direction and steepness (aka beta)
- Sy;
- boundary point where f obtains it's maximum
- Sa;
- constant intercept
- this(Sslope, Sy, Sa);
- Parameters:S slopedirection and steepness S yboundary point, often f(x) S aconstant intercept 
- const voidtoString(W)(auto ref Ww, ref const FormatSpec!charfmt);
- textual representation of the function
- const SopCall(in Sx);
- call the linear function with x
- const Sinverse(Sx);
- calculate inverse of x
- stringlogHex();
 
- LinearFun!SlinearFun(S)(Sslope, Sy, Sa);
- Constructs a linear function of the formy=slope* (x -y) +a.Parameters:S slopedirection and steepness S yboundary point, often f(x) S aconstant intercept Returns:A linear function constructed with the given parameters.Examples:tangent of a pointimport std.format : format; auto f = (double x) => x * x + 1; auto df = (double x) => 2 * x; auto buildTan = (double x) => linearFun(df(x), x, f(x)); auto t0 = buildTan(0); assert("%l".format(t0)== "1"); assert(t0(0) == 1); assert(t0(42) == 1); auto t1 = buildTan(1); assert("%l".format(t1) == "2x"); assert(t1(1) == 2); assert(t1(2) == 4); auto t2 = buildTan(2); assert("%l".format(t2) == "4x - 3"); assert(t2(1) == 1); assert(t2(2) == 5); Examples:secant of two pointsimport std.format : format; auto f = (double x) => x * x + 1; auto lx = 1, rx = 3; // compute the slope between lx and rx auto lf = linearFun((f(rx) - f(lx)) / (rx - lx), lx, f(lx)); assert("%l".format(lf) == "4x - 2"); assert(lf(1) == 2); // f(1) assert(lf(3) == 10); // f(3) Examples:construct an arbitrary linear functionimport std.format : format; // 2 * x + 1 auto t = linearFun!double(2, 0, 1); assert("%l".format(t) == "2x + 1"); assert(t(1) == 3); assert(t(-2) == -3); 
- boolapproxEqual(S)(LinearFun!Sx, LinearFun!Sy, SmaxRelDiff= 0.01, SmaxAbsDiff= 1e-05);
- Compares whether to linear functions are approximately equal.Parameters:LinearFun!S xfirst linear function to compare LinearFun!S ysecond linear function to compare S maxRelDiffmaximum relative difference S maxAbsDiffmaximum absolute difference Returns:True if both linear functions are approximately equal.Examples:auto x = linearFun!double(2, 0, 1); auto x2 = linearFun!double(2, 0, 1); assert(x.approxEqual(x2)); auto y = linearFun!double(2, 1e-9, 1); assert(x.approxEqual(y)); auto z = linearFun!double(2, 4, 1); assert(!x.approxEqual(z)); 
Copyright © 2016-2021 by Ilya Yaroshenko | Page generated by
Ddoc on Tue Mar 23 21:30:38 2021