From 55386cb28e2512804f1c09097be8348f64ca8c00 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 27 May 2015 21:54:45 +0200 Subject: variations: Fully vectorize pdj --- flam3.c | 14 ++++++-------- flam3.h | 6 ++---- genome.c | 8 ++++---- interpolation.c | 8 ++++---- math.h | 13 +++++++++++++ parser.c | 8 ++++---- variations.c | 8 ++------ 7 files changed, 35 insertions(+), 30 deletions(-) diff --git a/flam3.c b/flam3.c index 0a6f59b..ea8a51f 100644 --- a/flam3.c +++ b/flam3.c @@ -297,10 +297,8 @@ void flam3_copy_params(flam3_xform * restrict dest, flam3_xform * restrict src, dest->blob_waves = src->blob_waves; } else if (varn==VAR_PDJ) { /* PDJ */ - dest->pdj_a = src->pdj_a; - dest->pdj_b = src->pdj_b; - dest->pdj_c = src->pdj_c; - dest->pdj_d = src->pdj_d; + dest->pdj_ac = src->pdj_ac; + dest->pdj_bd = src->pdj_bd; } else if (varn==VAR_FAN2) { /* Fan2 */ dest->fan2_x = src->fan2_x; @@ -1028,10 +1026,10 @@ static void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, break; case VAR_PDJ: - fprintf(f, "pdj_a=\"%g\" ", x->pdj_a); - fprintf(f, "pdj_b=\"%g\" ", x->pdj_b); - fprintf(f, "pdj_c=\"%g\" ", x->pdj_c); - fprintf(f, "pdj_d=\"%g\" ", x->pdj_d); + fprintf(f, "pdj_a=\"%g\" ", x->pdj_ac[0]); + fprintf(f, "pdj_b=\"%g\" ", x->pdj_bd[0]); + fprintf(f, "pdj_c=\"%g\" ", x->pdj_ac[1]); + fprintf(f, "pdj_d=\"%g\" ", x->pdj_bd[1]); break; case VAR_FAN2: diff --git a/flam3.h b/flam3.h index e5127fc..488c963 100644 --- a/flam3.h +++ b/flam3.h @@ -175,10 +175,8 @@ typedef struct xform { double blob_waves; /* PDJ */ - double pdj_a; - double pdj_b; - double pdj_c; - double pdj_d; + double2 pdj_ac; + double2 pdj_bd; /* Fan2 */ double fan2_x; diff --git a/genome.c b/genome.c index 547a6a8..3ee13e0 100644 --- a/genome.c +++ b/genome.c @@ -35,10 +35,10 @@ static void random_xform_param (flam3_xform * const xform, const unsigned int i, break; case VAR_PDJ: - xform->pdj_a = 3.0 * rand_d11(rc); - xform->pdj_b = 3.0 * rand_d11(rc); - xform->pdj_c = 3.0 * rand_d11(rc); - xform->pdj_d = 3.0 * rand_d11(rc); + xform->pdj_ac[0] = 3.0 * rand_d11(rc); + xform->pdj_bd[0] = 3.0 * rand_d11(rc); + xform->pdj_ac[1] = 3.0 * rand_d11(rc); + xform->pdj_bd[1] = 3.0 * rand_d11(rc); break; case VAR_FAN2: diff --git a/interpolation.c b/interpolation.c index c2b245c..5fa1e07 100644 --- a/interpolation.c +++ b/interpolation.c @@ -366,10 +366,10 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, INTERP(xform[i].blob_low); INTERP(xform[i].blob_high); INTERP(xform[i].blob_waves); - INTERP(xform[i].pdj_a); - INTERP(xform[i].pdj_b); - INTERP(xform[i].pdj_c); - INTERP(xform[i].pdj_d); + INTERP(xform[i].pdj_ac[0]); + INTERP(xform[i].pdj_bd[0]); + INTERP(xform[i].pdj_ac[1]); + INTERP(xform[i].pdj_bd[1]); INTERP(xform[i].fan2_x); INTERP(xform[i].fan2_y); INTERP(xform[i].rings2_val); diff --git a/math.h b/math.h index a7a658e..2c94b0b 100644 --- a/math.h +++ b/math.h @@ -151,3 +151,16 @@ inline double4 nearbyint_d4 (const double4 in) { nearbyint (in[3]), }; } + +inline double2 sin_d2 (const double2 in) { + return (double2) { sin (in[0]), sin (in[1]) }; +} + +inline double2 cos_d2 (const double2 in) { + return (double2) { cos (in[0]), cos (in[1]) }; +} + +inline double2 swap_d2 (const double2 in) { + return (double2) { in[1], in[0] }; +} + diff --git a/parser.c b/parser.c index 89467bd..1c8e060 100644 --- a/parser.c +++ b/parser.c @@ -861,13 +861,13 @@ static int parse_xform_xml(xmlNode *chld_node,flam3_xform *this_xform, int *num_ } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"blob_waves")) { this_xform->blob_waves = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"pdj_a")) { - this_xform->pdj_a = flam3_atof(att_str); + this_xform->pdj_ac[0] = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"pdj_b")) { - this_xform->pdj_b = flam3_atof(att_str); + this_xform->pdj_bd[0] = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"pdj_c")) { - this_xform->pdj_c = flam3_atof(att_str); + this_xform->pdj_ac[1] = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"pdj_d")) { - this_xform->pdj_d = flam3_atof(att_str); + this_xform->pdj_bd[1] = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"fan2_x")) { this_xform->fan2_x = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"fan2_y")) { diff --git a/variations.c b/variations.c index ed10d41..f42c623 100644 --- a/variations.c +++ b/variations.c @@ -558,12 +558,8 @@ static double2 var24_pdj (const double2 in, const flam3_iter_helper * const f, d p[0] += v * (ny1 - nx1); p[1] += v * (nx2 - ny2); */ - const double2 a = (double2) { - sin(f->xform->pdj_a * in[1]), - sin(f->xform->pdj_c * in[0]) }; - const double2 b = (double2) { - cos(f->xform->pdj_b * in[0]), - cos(f->xform->pdj_d * in[1]) }; + const double2 a = sin_d2 (f->xform->pdj_ac * swap_d2 (in)); + const double2 b = cos_d2 (f->xform->pdj_bd * in); return weight * (a - b); } -- cgit v1.2.3