Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster initialize Node_FC #16

Open
colinlin1982 opened this issue Sep 1, 2023 · 0 comments
Open

Faster initialize Node_FC #16

colinlin1982 opened this issue Sep 1, 2023 · 0 comments

Comments

@colinlin1982
Copy link

code:
//nodeMat[0] = pow(double(x), 4) / pow(scale, 4); // x^4
//nodeMat[1] = 2 * pow(double(x), 3)y / pow(scale, 4); // 2 * x^3 * y = 2xy * x^2 = [5][8]
//nodeMat[2] = double(x)xyy / pow(scale, 4); // x^2 * y^2 = [5] * [11]
//nodeMat[3] = 2 * pow(double(x), 3) / pow(scale, 3); // 2 * x^3 = [12]
[5]
//nodeMat[4] = 2 * double(x)xy / pow(scale, 3); // 2 * x^2 * y = [13][5]
//nodeMat[5] = double(x)x / (scalescale); // x^2
//nodeMat[6] = 2 * double(x)yy
y / pow(scale, 4); // 2 * x * y^3 = [10]x
//nodeMat[7] = 4 * double(x)yy / pow(scale, 3); // 4 * x * y^2 = 2 * x * y * 2 * y = [13]
[8]
//nodeMat[8] = 2 * double(x)y / (scalescale); // 2 * x * y = [13]x
//nodeMat[9] = pow(double(y), 4) / pow(scale, 4); // y^4 = [11]
[11]
//nodeMat[10] = 2 * pow(double(y), 3) / pow(scale, 3); // 2 * y^3 = [13]*[11]
//nodeMat[11] = double(y)y / (scalescale); // y^2
//nodeMat[12] = 2 * double(x) / scale; // 2x
//nodeMat[13] = 2 * double(y) / scale; // 2y
//nodeMat[14] = 1;

	double xs = double(x) / scale;
	double ys = double(y) / scale;
	nodeMat[14] = 1;
	nodeMat[13] = 2 * ys;
	nodeMat[12] = 2 * xs;
	nodeMat[11] = ys * ys;
	nodeMat[10] = nodeMat[13] * nodeMat[11];
	nodeMat[9] = nodeMat[11] * nodeMat[11];
	nodeMat[8] = nodeMat[13] * xs;
	nodeMat[7] = nodeMat[13] * nodeMat[8];
	nodeMat[6] = nodeMat[10] * xs;
	nodeMat[5] = xs * xs;
	nodeMat[4] = nodeMat[5] * nodeMat[13];
	nodeMat[3] = nodeMat[5] * nodeMat[12];
	nodeMat[2] = nodeMat[5] * nodeMat[11];
	nodeMat[1] = nodeMat[5] * nodeMat[8];
	nodeMat[0] = nodeMat[5] * nodeMat[5];

About 4 times faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant