Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/charisee/ertest/vispaper/tensor-field-ops/tensor-field-ops.c
ViewVC logotype

View of /branches/charisee/ertest/vispaper/tensor-field-ops/tensor-field-ops.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2925 - (download) (as text) (annotate)
Tue Mar 3 22:00:11 2015 UTC (4 years, 7 months ago) by cchiw
File size: 15257 byte(s)
example of inner prod
#define DIDEROT_SINGLE_PRECISION
#define DIDEROT_INT
#define DIDEROT_TARGET_C
#include "Diderot/diderot.h"
static char *ProgramName = "tensor-field-ops";
Diderot_image2D_t *G__t_0;
Diderot_real_t G__t_1[2];
int32_t G_grid_2;
Diderot_vec2_t loadAligned2 (Diderot_real_t *a, int i)
{
    return *(Diderot_vec2_t* )&(a[i]);
}
Diderot_vec2_t load2 (Diderot_real_t *a, int i)
{
    return (Diderot_vec2_t){a[i],a[1+i]};
}
void store2 (Diderot_real_t *a, int i, Diderot_vec2_t v)
{
    Diderot_union2_t u = __extension__ (Diderot_union2_t)v;
    a[i] = u.r[0];
    a[1+i] = u.r[1];
    return;
}
Diderot_vec2_t V_ConsVec2 (Diderot_real_t r0, Diderot_real_t r1)
{
    return __extension__ (Diderot_vec2_t){r0,r1};
}
Diderot_vec4_t V_ConsVec4 (Diderot_real_t r0, Diderot_real_t r1, Diderot_real_t r2, Diderot_real_t r3)
{
    return __extension__ (Diderot_vec4_t){r0,r1,r2,r3};
}
void V_ConsArr2 (Diderot_real_t *a, Diderot_real_t r0, Diderot_real_t r1)
{
    a[0] = r0;
    a[1] = r1;
    return;
}
void V_CopyArr2 (Diderot_real_t *a, Diderot_real_t *b, int i)
{
    a[i] = b[0];
    a[1+i] = b[1];
}
void V_CopyArr4 (Diderot_real_t *a, Diderot_real_t *b, int i)
{
    a[i] = b[0];
    a[1+i] = b[1];
    a[2+i] = b[2];
    a[3+i] = b[3];
}
Diderot_real_t V_SumVec2 (Diderot_vec2_t v_0)
{
    Diderot_union2_t u_0 = __extension__ (Diderot_union2_t)v_0;
    return u_0.r[0]+u_0.r[1];
}
Diderot_real_t V_SumVec4 (Diderot_vec4_t v_0)
{
    Diderot_union4_t u_0 = __extension__ (Diderot_union4_t)v_0;
    return u_0.r[0]+u_0.r[1]+u_0.r[2]+u_0.r[3];
}
Diderot_vec2_t V_FloorVec2 (Diderot_vec2_t v)
{
    Diderot_union2_t u = __extension__ (Diderot_union2_t)v;
    return __extension__ (Diderot_vec2_t){FLOOR(u.r[0]),FLOOR(u.r[1])};
}
void Diderot_RegisterGlobalOpts (Diderot_Options_t *opts)
{
    return;
}
void Diderot_InitGlobals ()
{
    Status_t sts_0 = Diderot_LoadImage2D("parab0.nrrd", &G__t_0);
    if (DIDEROT_OK!=sts_0) exit(1);
    V_ConsArr2(G__t_1, 0.1e1f, 0.0f);
    G_grid_2 = 30;
    return;
}
void Diderot_Shutdown (Diderot_World_t *wrld)
{
}
typedef struct {
    float y;
    int32_t steps;
    Diderot_real_t x[2];
} Strand_RootFind_t;
void RootFind_InitState (Strand_RootFind_t *selfOut, float p_xi_3, float p_xj_4)
{
    Diderot_vec2_t l_x_5;
    Diderot_vec2_t l_2x_6;
    Diderot_real_t l_M_0_7[4];
    Diderot_vec2_t l_Proj_0__8;
    Diderot_vec2_t l_prodV_9;
    float l_sumVec_10;
    Diderot_vec2_t l_Proj_1__11;
    Diderot_vec2_t l_prodV_12;
    float l_sumVec_13;
    Diderot_vec2_t l_cons__14;
    Diderot_vec2_t l_mult_2_15;
    Diderot_vec2_t l_2mult_2_16;
    Diderot_vec2_t l_cons__17;
    Diderot_vec2_t l_cons__18;
    Diderot_real_t l_cons__19[4];
    Diderot_vec2_t l_nd_20;
    Diderot_vec2_t l_2nd_21;
    Diderot_vec2_t l_subVec_22;
    Diderot_vec2_t l_2subVec_23;
    vec2i_t l_n_24;
    float *l_baseAddr_25;
    int32_t l_addInt_26;
    int32_t l_Indx_1__27;
    float *l_rp_imgLoad_28;
    Diderot_vec4_t l_4imgLoad_29;
    float *l_rp_imgLoad_30;
    Diderot_vec4_t l_4imgLoad_31;
    float *l_rp_imgLoad_32;
    Diderot_vec4_t l_4imgLoad_33;
    float *l_rp_imgLoad_34;
    Diderot_vec4_t l_4imgLoad_35;
    float l_Indx_0__36;
    float l_cast_37;
    float l_cast_38;
    float l_cast_39;
    float l_Indx_1__40;
    Diderot_vec4_t l_cons__41;
    Diderot_vec4_t l_4cons__42;
    Diderot_vec4_t l_cons__43;
    Diderot_vec4_t l_4cons__44;
    Diderot_vec4_t l_P0_45;
    Diderot_vec4_t l_4P0_46;
    Diderot_vec4_t l_P1_47;
    Diderot_vec4_t l_4P1_48;
    Diderot_vec4_t l_P2_49;
    Diderot_vec4_t l_4P2_50;
    Diderot_vec4_t l_prodV_51;
    Diderot_vec4_t l_addV_52;
    Diderot_vec4_t l_prodV_53;
    Diderot_vec4_t l_addV_54;
    Diderot_vec4_t l_4addV_55;
    Diderot_vec4_t l_P0_56;
    Diderot_vec4_t l_4P0_57;
    Diderot_vec4_t l_P2_58;
    Diderot_vec4_t l_4P2_59;
    Diderot_vec4_t l_P3_60;
    Diderot_vec4_t l_4P3_61;
    Diderot_vec4_t l_prodV_62;
    Diderot_vec4_t l_addV_63;
    Diderot_vec4_t l_prodV_64;
    Diderot_vec4_t l_addV_65;
    Diderot_vec4_t l_prodV_66;
    Diderot_vec4_t l_addV_67;
    Diderot_vec4_t l_4addV_68;
    Diderot_vec4_t l_prodV_69;
    float l_sumVec_70;
    Diderot_vec4_t l_prodV_71;
    float l_sumVec_72;
    Diderot_vec4_t l_prodV_73;
    float l_sumVec_74;
    Diderot_vec4_t l_prodV_75;
    float l_sumVec_76;
    Diderot_vec4_t l_cons__77;
    Diderot_vec4_t l_4cons__78;
    Diderot_vec4_t l_prodV_79;
    float l_sumVec_80;
    float l_sumVec_81;
    float l_Indx_00__82;
    Diderot_vec4_t l_prodV_83;
    Diderot_vec4_t l_addV_84;
    Diderot_vec4_t l_prodV_85;
    Diderot_vec4_t l_addV_86;
    Diderot_vec4_t l_prodV_87;
    Diderot_vec4_t l_addV_88;
    Diderot_vec4_t l_4addV_89;
    Diderot_vec4_t l_prodV_90;
    Diderot_vec4_t l_addV_91;
    Diderot_vec4_t l_prodV_92;
    Diderot_vec4_t l_addV_93;
    Diderot_vec4_t l_4addV_94;
    Diderot_vec4_t l_prodV_95;
    float l_sumVec_96;
    Diderot_vec4_t l_prodV_97;
    float l_sumVec_98;
    Diderot_vec4_t l_prodV_99;
    float l_sumVec_100;
    Diderot_vec4_t l_prodV_101;
    float l_sumVec_102;
    Diderot_vec4_t l_cons__103;
    Diderot_vec4_t l_4cons__104;
    Diderot_vec4_t l_prodV_105;
    float l_sumVec_106;
    float l_sumVec_107;
    float l_Indx_01__108;
    float l_Indx_10__109;
    float l_Indx_11__110;
    Diderot_vec2_t l_cons__111;
    Diderot_vec2_t l_subVec_112;
    Diderot_vec2_t l_2subVec_113;
    Diderot_vec2_t l_prodV_114;
    float l_sumVec_115;
    Diderot_vec4_t l_P1_116;
    Diderot_vec4_t l_4P1_117;
    Diderot_vec4_t l_prodV_118;
    Diderot_vec4_t l_addV_119;
    Diderot_vec4_t l_4addV_120;
    Diderot_vec4_t l_prodV_121;
    float l_sumVec_122;
    Diderot_vec4_t l_prodV_123;
    float l_sumVec_124;
    Diderot_vec4_t l_prodV_125;
    float l_sumVec_126;
    Diderot_vec4_t l_prodV_127;
    float l_sumVec_128;
    Diderot_vec4_t l_cons__129;
    Diderot_vec4_t l_prodV_130;
    float l_sumVec_131;
    float l_sumVec_132;
    float l_mult_3_133;
    Diderot_vec4_t l_prodV_134;
    float l_sumVec_135;
    float l_sumVec_136;
    float l_mult_3_137;
    float l_mult_3_138;
    Diderot_vec4_t l_prodV_139;
    Diderot_vec4_t l_addV_140;
    Diderot_vec4_t l_prodV_141;
    float l_sumVec_142;
    float l_sumVec_143;
    float l_mult_3_144;
    Diderot_vec2_t l_cons__145;
    float l_mult_3_146;
    float l_mult_3_147;
    float l_mult_3_148;
    float l_mult_3_149;
    Diderot_vec2_t l_cons__150;
    Diderot_real_t l_cons__151[4];
    float l_cast_152;
    Diderot_vec2_t l_cons__153;
    Diderot_vec2_t l_cons__154;
    Diderot_real_t l_cons__155[4];
    float l_Indx_0__156;
    float l_Indx_1__157;
    Diderot_vec2_t l_cons__158;
    Diderot_vec2_t l_2cons__159;
    Diderot_vec2_t l_mult_2_160;
    Diderot_vec2_t l_2mult_2_161;
    float l_divSca_162;
    Diderot_vec2_t l_cons__163;
    Diderot_vec2_t l_2cons__164;
    Diderot_vec2_t l_prodV_165;
    float l_sumVec_166;
    l_2x_6 = V_ConsVec2(p_xi_3, p_xj_4);
    store2(l_M_0_7, 0, G__t_0->w2i[0].v);
    store2(l_M_0_7, 2, G__t_0->w2i[1].v);
    l_2mult_2_16 = V_ConsVec2(V_SumVec2(load2(l_M_0_7, 0)*l_2x_6), V_SumVec2(load2(l_M_0_7, 2)*l_2x_6))+G__t_0->tVec;
    store2(l_cons__19, 0, V_ConsVec2(l_M_0_7[0], l_M_0_7[2]));
    store2(l_cons__19, 2, V_ConsVec2(l_M_0_7[1], l_M_0_7[3]));
    l_2nd_21 = V_FloorVec2(l_2mult_2_16);
    l_2subVec_23 = l_2mult_2_16-l_2nd_21;
    l_n_24 = vec2rtoi(l_2nd_21);
    l_baseAddr_25 = (float *)G__t_0->data;
    l_addInt_26 = ((Diderot_iunion2_t)l_n_24).i[0]+-1;
    l_Indx_1__27 = ((Diderot_iunion2_t)l_n_24).i[1];
    l_rp_imgLoad_28 = l_baseAddr_25+1*(l_addInt_26+80*(l_Indx_1__27+-1));
    l_4imgLoad_29 = V_ConsVec4(l_rp_imgLoad_28[0], l_rp_imgLoad_28[1], l_rp_imgLoad_28[2], l_rp_imgLoad_28[3]);
    l_rp_imgLoad_30 = l_baseAddr_25+1*(l_addInt_26+80*l_Indx_1__27);
    l_4imgLoad_31 = V_ConsVec4(l_rp_imgLoad_30[0], l_rp_imgLoad_30[1], l_rp_imgLoad_30[2], l_rp_imgLoad_30[3]);
    l_rp_imgLoad_32 = l_baseAddr_25+1*(l_addInt_26+80*(l_Indx_1__27+1));
    l_4imgLoad_33 = V_ConsVec4(l_rp_imgLoad_32[0], l_rp_imgLoad_32[1], l_rp_imgLoad_32[2], l_rp_imgLoad_32[3]);
    l_rp_imgLoad_34 = l_baseAddr_25+1*(l_addInt_26+80*(l_Indx_1__27+2));
    l_4imgLoad_35 = V_ConsVec4(l_rp_imgLoad_34[0], l_rp_imgLoad_34[1], l_rp_imgLoad_34[2], l_rp_imgLoad_34[3]);
    l_Indx_0__36 = ((Diderot_union2_t)l_2subVec_23).r[0];
    l_cast_37 = (float)2;
    l_cast_38 = (float)1;
    l_cast_39 = (float)-1;
    l_Indx_1__40 = ((Diderot_union2_t)l_2subVec_23).r[1];
    l_4cons__42 = V_ConsVec4(l_Indx_0__36-l_cast_39, l_Indx_0__36, l_Indx_0__36-l_cast_38, l_Indx_0__36-l_cast_37);
    l_4cons__44 = V_ConsVec4(l_Indx_1__40-l_cast_39, l_Indx_1__40, l_Indx_1__40-l_cast_38, l_Indx_1__40-l_cast_37);
    l_4P0_46 = V_ConsVec4(-0.2e1f, 0.0f, 0.0f, 0.2e1f);
    l_4P1_48 = V_ConsVec4(0.2e1f, -0.2e1f, -0.2e1f, 0.2e1f);
    l_4P2_50 = V_ConsVec4(-0.5e0f, 0.15e1f, -0.15e1f, 0.5e0f);
    l_4addV_55 = l_4P0_46+l_4cons__42*(l_4P1_48+l_4cons__42*l_4P2_50);
    l_4P0_57 = V_ConsVec4(0.133333333333e1f, 0.666666666667e0f, 0.666666666667e0f, 0.133333333333e1f);
    l_4P2_59 = V_ConsVec4(0.1e1f, -0.1e1f, -0.1e1f, 0.1e1f);
    l_4P3_61 = V_ConsVec4(-0.166666666667e0f, 0.5e0f, -0.5e0f, 0.166666666667e0f);
    l_4addV_68 = l_4P0_57+l_4cons__44*(l_4P0_46+l_4cons__44*(l_4P2_59+l_4cons__44*l_4P3_61));
    l_4cons__78 = V_ConsVec4(V_SumVec4(l_4imgLoad_29*l_4addV_55), V_SumVec4(l_4imgLoad_31*l_4addV_55),
        V_SumVec4(l_4imgLoad_33*l_4addV_55), V_SumVec4(l_4imgLoad_35*l_4addV_55));
    l_sumVec_81 = V_SumVec4(l_4cons__78*l_4addV_68);
    l_Indx_00__82 = l_cons__19[0];
    l_4addV_89 = l_4P0_57+l_4cons__42*(l_4P0_46+l_4cons__42*(l_4P2_59+l_4cons__42*l_4P3_61));
    l_4addV_94 = l_4P0_46+l_4cons__44*(l_4P1_48+l_4cons__44*l_4P2_50);
    l_4cons__104 = V_ConsVec4(V_SumVec4(l_4imgLoad_29*l_4addV_89), V_SumVec4(l_4imgLoad_31*l_4addV_89),
        V_SumVec4(l_4imgLoad_33*l_4addV_89), V_SumVec4(l_4imgLoad_35*l_4addV_89));
    l_sumVec_107 = V_SumVec4(l_4cons__104*l_4addV_94);
    l_Indx_01__108 = l_cons__19[1];
    l_Indx_10__109 = l_cons__19[2];
    l_Indx_11__110 = l_cons__19[3];
    l_2subVec_113 = V_ConsVec2(l_sumVec_81*l_Indx_00__82+l_sumVec_107*l_Indx_01__108,
        l_sumVec_81*l_Indx_10__109+l_sumVec_107*l_Indx_11__110)-loadAligned2(G__t_1, 0);
    l_4P1_117 = V_ConsVec4(-0.1e1f, 0.3e1f, -0.3e1f, 0.1e1f);
    l_4addV_120 = l_4P1_48+l_4cons__42*l_4P1_117;
    l_sumVec_132 = V_SumVec4(
        V_ConsVec4(V_SumVec4(l_4imgLoad_29*l_4addV_120), V_SumVec4(l_4imgLoad_31*l_4addV_120),
            V_SumVec4(l_4imgLoad_33*l_4addV_120), V_SumVec4(l_4imgLoad_35*l_4addV_120))*l_4addV_68);
    l_mult_3_133 = l_sumVec_132*l_Indx_00__82;
    l_sumVec_136 = V_SumVec4(l_4cons__78*l_4addV_94);
    l_mult_3_137 = l_sumVec_136*l_Indx_00__82;
    l_mult_3_138 = l_sumVec_136*l_Indx_01__108;
    l_sumVec_143 = V_SumVec4(l_4cons__104*(l_4P1_48+l_4cons__44*l_4P1_117));
    l_mult_3_144 = l_sumVec_143*l_Indx_01__108;
    l_mult_3_146 = l_sumVec_132*l_Indx_10__109;
    l_mult_3_147 = l_sumVec_136*l_Indx_10__109;
    l_mult_3_148 = l_sumVec_136*l_Indx_11__110;
    l_mult_3_149 = l_sumVec_143*l_Indx_11__110;
    store2(l_cons__151, 0,
        V_ConsVec2(
            l_mult_3_133*l_Indx_00__82+l_mult_3_137*l_Indx_01__108+l_mult_3_138*l_Indx_00__82+l_mult_3_144*l_Indx_01__108,
            l_mult_3_133*l_Indx_10__109+l_mult_3_137*l_Indx_11__110+l_mult_3_138*l_Indx_10__109+l_mult_3_144*l_Indx_11__110));
    store2(l_cons__151, 2,
        V_ConsVec2(
            l_mult_3_146*l_Indx_00__82+l_mult_3_147*l_Indx_01__108+l_mult_3_148*l_Indx_00__82+l_mult_3_149*l_Indx_01__108,
            l_mult_3_146*l_Indx_10__109+l_mult_3_147*l_Indx_11__110+l_mult_3_148*l_Indx_10__109+l_mult_3_149*l_Indx_11__110));
    l_cast_152 = (float)0;
    store2(l_cons__155, 0, V_ConsVec2(l_cons__151[0]-l_cast_152, l_cons__151[1]-l_cast_152));
    store2(l_cons__155, 2, V_ConsVec2(l_cons__151[2]-l_cast_152, l_cons__151[3]-l_cast_152));
    l_Indx_0__156 = ((Diderot_union2_t)l_2subVec_113).r[0];
    l_Indx_1__157 = ((Diderot_union2_t)l_2subVec_113).r[1];
    l_2cons__159 = V_ConsVec2(l_Indx_0__156*l_cons__155[0]+l_Indx_1__157*l_cons__155[2],
        l_Indx_0__156*l_cons__155[1]+l_Indx_1__157*l_cons__155[3]);
    l_2mult_2_161 = l_2cons__159+l_2cons__159;
    l_divSca_162 = l_cast_38/(l_cast_37*SQRT(V_SumVec2(l_2subVec_113*l_2subVec_113)));
    l_2cons__164 = V_ConsVec2(l_divSca_162*((Diderot_union2_t)l_2mult_2_161).r[0],
        l_divSca_162*((Diderot_union2_t)l_2mult_2_161).r[1]);
    store2(selfOut->x, 0, l_2x_6);
    selfOut->steps = 0;
    selfOut->y = SQRT(V_SumVec2(l_2cons__164*l_2cons__164));
    return;
}
static void RootFind_Stabilize (Strand_RootFind_t *selfIn, Strand_RootFind_t *selfOut)
{
    Diderot_vec2_t l_x_170;
    int32_t l_steps_171;
    float l_y_172;
    store2(selfOut->x, 0, load2(selfIn->x, 0));
    return;
}
static StrandStatus_t RootFind_Update (Strand_RootFind_t *selfIn, Strand_RootFind_t *selfOut)
{
    int32_t l_steps_167;
    float l_y_168;
    Diderot_vec2_t l_x_169;
    store2(selfOut->x, 0, V_ConsVec2(selfIn->y, 0.6e1f));
    return DIDEROT_STABILIZE;
}
static void RootFind_Output (void *outS, Strand_RootFind_t *self)
{
    memcpy(outS, &self->x, sizeof(Diderot_real_t));
}
static void RootFind_Print (FILE *outS, Strand_RootFind_t *self)
{
    fprintf(outS, "%f %f\n", self->x[0], self->x[1]);
}
Strand_t Strand_RootFind = {.name = "RootFind",.stateSzb = sizeof(Strand_RootFind_t),.outputSzb = 8,.nrrdSzb = 8,.nrrdType = 9,.update = (update_method_t)RootFind_Update,.stabilize = (stabilize_method_t)RootFind_Stabilize,.print = (print_method_t)RootFind_Print,.output = (output_method_t)RootFind_Output,};
int32_t Diderot_NumStrands = 1;
Strand_t *Diderot_Strands[1] = {[0] = &Strand_RootFind,};
Diderot_World_t *Diderot_Initially ()
{
    int32_t l__t_173;
    l__t_173 = G_grid_2-1;
    // allocate initial block of strands
    
    int32_t base[2] = {[0] = 0,[1] = 0,};
    uint32_t size[2] = {[0] = l__t_173-0+1,[1] = l__t_173-0+1,};
    Diderot_World_t *wrld = Diderot_AllocInitially(ProgramName, &Strand_RootFind, false, 2, base, size);
    // initially
    
    uint32_t ix = 0;
    for (int32_t i_vi_175 = 0; i_vi_175<=l__t_173; i_vi_175++)
        for (int32_t i_ui_174 = 0; i_ui_174<=l__t_173; i_ui_174++) {
            float l__t_176;
            float l__t_177;
            float l_cast_178;
            float l__t_179;
            float l__t_180;
            float l__t_181;
            float l__t_182;
            float l_t1_183;
            float l_t2_184;
            float l__t_185;
            float l_t1_186;
            l__t_176 = (float)-2;
            l__t_177 = (float)2;
            l_cast_178 = (float)-1;
            l__t_179 = l_cast_178*0.5e0f;
            l__t_180 = (float)i_ui_174;
            l__t_181 = (float)G_grid_2;
            l__t_182 = l__t_181-0.5e0f;
            l_t1_183 = l__t_180-l__t_179;
            l_t2_184 = l__t_182-l__t_179;
            l__t_185 = (float)i_vi_175;
            l_t1_186 = l__t_185-l__t_179;
            Strand_RootFind_t *sp = (Strand_RootFind_t *)Diderot_InState(wrld, ix);
            RootFind_InitState(sp, lerp(l__t_176, l__t_177, l_t1_183/l_t2_184),
                lerp(l__t_176, l__t_177, l_t1_186/l_t2_184));
            ix = ix+1;
        }
    return wrld;
}

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0