Exemplo n.º 1
0
static void add_ref_u_p_a(double **AXX, double **R23, double *S32_a, double *S31_a, int n, double atran, double *v1, double *v2, double **w1) {

     dmat_trans(AXX, w1, n, n);
     dm_v_mul(w1, S31_a, n, n, v1);
     dvec_scale(atran, v1, v1, n);
     dvec_add(S32_a, v1, S32_a, n);

     dvec_zero(S31_a, n);
}
Exemplo n.º 2
0
static void add_ref_l_p_a(double **PXX, int *i1, double **AXX, double **BXX, double *CXX, double **DXX, double **R23, double *S32, double **R12_a, double **T12_a, double *S12_a, double **R21_a, double **T21_a, double *S21_a, double *S32_a, double **R13_a, double *S31_a, int n, double atran, double *atran_a, double *v1, double *v2, double **w1, double **w2, work_data work) {
/*
     double **w3;
*/
     double **EXX_a;
/*
     w3    = get_work1(&work, WORK_DXX);
*/
     EXX_a = get_work1(&work, WORK_DXX);

     dmat_add(R12_a, R13_a, R12_a, n, n);
/*
     dmat_trans(BXX, w1, n, n);
     dmat_mul(R13_a, w1, n, n, n, EXX_a);
*/
     dmat_gxgxmx(0, R13_a, 1, BXX, 1., EXX_a, 0., n, n, n);
/*
     dmat_trans(DXX, w1, n, n);
     dmat_mul(w1, R13_a, n, n, n, w2);
     dmat_add(T12_a, w2, T12_a, n, n);
*/
     dmat_gxgxmx(1, DXX, 0, R13_a, 1., T12_a, 1., n, n, n);

     dvec_add(S21_a, S31_a, S21_a, n);

     dmat_vxvtmx(S31_a, CXX, 1., EXX_a, 1., n, n);
/*
     dmat_trans(AXX, w1, n, n);
     dm_v_mul(w1, S31_a, n, n, v1);
*/
     dmat_gxvxmx(1, AXX, S31_a, 1., v1, 0., n, n);

     dvec_scale(atran, v1, v2, n);
     dvec_add(S32_a, v2, S32_a, n);

     *atran_a += dvec_dot(S32, v1, n);
/*
     dmat_trans(R23, w1, n, n);
     dm_v_mul(w1, v1, n, n, v2);
     dvec_add(S12_a, v2, S12_a, n);
*/
     dmat_gxvxmx(1, R23, v1, 1., S12_a, 1., n, n);

     dmat_copy(w1, EXX_a, n, n);
     dmat_getrs2('t', PXX, w1, n, n, i1);

     dmat_add(T21_a, w1, T21_a, n, n);
/*
     dmat_trans(DXX, w2, n, n);
     dmat_mul(w2, w1, n, n, n, w3);
     dmat_add(R21_a, w3, R21_a, n, n);
*/
     dmat_gxgxmx(1, DXX, 0, w1, 1., R21_a, 1., n, n, n);

     dmat_zero(R13_a, n, n);
     dvec_zero(S31_a, n);
}
Exemplo n.º 3
0
void build_global_source_a2(int n_quad_v, double atran, double *atran_a,
                       double **R_p, double **T_p, double **R_m, double **T_m,
                       double *F_p, double *F_m, double *S_p, double *S_m,
                       double **R_p_a, double **T_p_a, double **R_m_a, double **T_m_a,
                       double *F_p_a, double *F_m_a, double *S_p_a, double *S_m_a,
                       work_data work) {

     double *v1;
     double *v2;

     v1 = get_work1(&work, WORK_DX);
     v2 = get_work1(&work, WORK_DX);

     dvec_scale(atran, S_m_a, v1, n_quad_v);
     dvec_add(F_m_a, v1, F_m_a, n_quad_v);

     *atran_a += dvec_dot(F_m, S_m_a, n_quad_v);

     dmat_vxvtmx(S_m_a, F_m, -1., T_m_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, T_m, S_m_a, -1., F_m_a, 1., n_quad_v, n_quad_v);

     dmat_vxvtmx(S_m_a, F_p, -atran, R_p_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, R_p, S_m_a, -1., v1, 0., n_quad_v, n_quad_v);

     dvec_add(F_p_a, S_p_a, F_p_a, n_quad_v);

     dmat_vxvtmx(S_p_a, F_p, -atran, T_p_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, T_p, S_p_a, -1., v1, 1., n_quad_v, n_quad_v);

     dmat_vxvtmx(S_p_a, F_m, -1., R_m_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, R_m, S_p_a, -1., F_m_a, 1., n_quad_v, n_quad_v);

     dvec_scale(atran, v1, v2, n_quad_v);
     dvec_add(F_p_a, v2, F_p_a, n_quad_v);

     *atran_a += dvec_dot(F_p, v1, n_quad_v);

     dvec_zero(S_p_a, n_quad_v);
     dvec_zero(S_m_a, n_quad_v);
}
Exemplo n.º 4
0
/*
 * --- initialize OTF Control Block -----------------------------------------
 */
void initOTFHandle(VTOTF_Control* fha) {
  fha->num = 0;
  fha->ticksPerSecond = 0;
  fha->elgout = 0;
  fha->stringid = 0;
  fha->numloc = 0;
  fha->udata = 0;
  dvec_create(fha->funcgrouptab, elg_ui4, 10);
  dvec_create(fha->scltab, SCL, 10);
  dvec_zero(fha->comtab, 10);
  dvec_create(fha->vtapitab, elg_ui4, 10);
}
Exemplo n.º 5
0
void brdf_build_ref_vec(int i_four, int i_offset, int n_quad, int j_offset, int n_stokes, double qf, double *qx_v, double *qw_v, int n_kernels, int n_kernel_quad, enum xrtm_kernel_type *kernels, double *kernel_qx, double *kernel_qw, double **kernel_f, double *R_s, work_data work) {

     int i;
     int ii;
     int j;
     int jj;

     int flag;

     int n_quad_v;

     double a;

     double *azmfac;

     n_quad_v = n_quad * n_stokes;

     flag = brdf_needs_fourier(kernels, n_kernels);

     a = (2. - (i_four == 0 ? 1. : 0.));

     if (i_four > 0 || n_stokes > 1)
          dvec_zero(R_s, n_quad_v);

     if (! flag) {
          for (i = 0, ii = 0; i < n_quad; ++i, ii += n_stokes) {
               R_s[ii] = kernel_f[0][i];
          }
     }
     else {
          azmfac = get_work_d1(&work, n_kernel_quad * 2);

          for (i = 0, ii = n_kernel_quad; i < n_kernel_quad; ++i, ++ii) {
               azmfac[i ] = kernel_qw[i] * cos(i_four *  kernel_qx[i]) / 2.;
               azmfac[ii] = kernel_qw[i] * cos(i_four * -kernel_qx[i]) / 2.;
          }

          for (i = 0, ii = 0; i < n_quad; ++i, ii += n_stokes) {
               if (i_four == 0)
                    R_s[ii] = kernel_f[0][i];

               for (j = 0, jj = n_kernel_quad; j < n_kernel_quad; ++j, ++jj) {
                    R_s[ii] += kernel_f[j +1][i] * azmfac[j ];
                    R_s[ii] += kernel_f[jj+1][i] * azmfac[jj];
               }
          }
     }

     for (i = 0, ii = 0; i < n_quad; ++i, ii += n_stokes)
          R_s[ii] *= a;
}
Exemplo n.º 6
0
void scale_source_vectors_a(int n_quad_v,
                            double btran, double *btran_a,
                            double *F_p1, double *F_m1,
                            double *F_p2, double *F_m2,
                            double *F_p_a1, double *F_m_a1,
                            double *F_p_a2, double *F_m_a2, work_data work) {

     double *v1;

     v1 = get_work1(&work, WORK_DX);

     *btran_a += dvec_dot(F_p1, F_p_a2, n_quad_v);

     dvec_scale(btran, F_p_a2, v1, n_quad_v);
     dvec_add(F_p_a1, v1, F_p_a1, n_quad_v);

     *btran_a += dvec_dot(F_m1, F_m_a2, n_quad_v);

     dvec_scale(btran, F_m_a2, v1, n_quad_v);
     dvec_add(F_m_a1, v1, F_m_a1, n_quad_v);

     dvec_zero(F_p_a2, n_quad_v);
     dvec_zero(F_m_a2, n_quad_v);
}
Exemplo n.º 7
0
static void add_ref_p_l_a(double **PXX, int *i1, double **AXX, double **BXX, double *CXX, double **T12, double *S12, double **R21, double **R23, double *S12_a, double *S21_a, double **R23_a, double *S32_a, double **R13_a, double *S31_a, int n, double atran, double *v1, double *v2, double **w1, double **w2, work_data work) {

     double **w3;

     double **DXX_a;
     double **EXX_a;

     w3    = get_work1(&work, WORK_DXX);

     DXX_a = get_work1(&work, WORK_DXX);
     EXX_a = get_work1(&work, WORK_DXX);

     dmat_trans(BXX, w1, n, n);
     dmat_mul(R13_a, w1, n, n, n, EXX_a);

     dmat_trans(T12, w1, n, n);
     dmat_mul(R13_a, w1, n, n, n, DXX_a);

     dvec_add(S21_a, S31_a, S21_a, n);

     dmat_vxvtmx(S31_a, CXX, 1., EXX_a, 1., n, n);

     dmat_trans(AXX, w1, n, n);
     dm_v_mul(w1, S31_a, n, n, v1);

     dvec_scale(atran, v1, v2, n);
     dvec_add(S32_a, v2, S32_a, n);

     dmat_vxvtmx(v1, S12, 1., R23_a, 1., n, n);

     dmat_trans(R23, w1, n, n);
     dm_v_mul(w1, v1, n, n, v2);
     dvec_add(S12_a, v2, S12_a, n);

     dmat_copy(w1, EXX_a, n, n);
     dmat_getrs2('t', PXX, w1, n, n, i1);
     dmat_trans(R21, w2, n, n);
     dmat_mul(w1, w2, n, n, n, w3);
     dmat_add(DXX_a, w3, DXX_a, n, n);

     dmat_trans(AXX, w1, n, n);
     dmat_mul(w1, DXX_a, n, n, n, w2);
     dmat_add(R23_a, w2, R23_a, n, n);

     dmat_zero(R13_a, n, n);
     dvec_zero(S31_a, n);
}
Exemplo n.º 8
0
void build_source_vectors_1n_a(int n_quad, int n_stokes, double *qx_v,
                               double F_0, double omega, double *omega_a,
                               double as_0, double *as_0_a,
                               double  *P_q0_mm, double  *P_q0_pm,
                               double  **tpr, double  **tmr, double  **gamma,
                               double  *F_p, double  *F_m,
                               double *P_q0_mm_a, double *P_q0_pm_a,
                               double **tpr_a, double **tmr_a, double **gamma_a,
                               double *F_p_a, double *F_m_a,
                               save_tree_data save_tree, work_data work) {

     int i;

     int n_quad_v;

     double *v1;

     double *a_a;
     double *b_a;
     double *c_a;
     double *d_a;
     double *e_a;
     double *p_a;
     double *h_a;

     double **w1;

     forward_save_build_source_vectors_1n_data *save;


     n_quad_v = n_quad * n_stokes;


     /*-------------------------------------------------------------------------
      *
      *-----------------------------------------------------------------------*/
     save_tree_encode_s(&save_tree, "build_source_vectors_1n");

     save_tree_retrieve_data(&save_tree, forward_save_build_source_vectors_1n_data, &save);


     /*-------------------------------------------------------------------------
      *
      *-----------------------------------------------------------------------*/
     v1  = get_work1(&work, WORK_DX);

     a_a = get_work1(&work, WORK_DX);
     b_a = get_work1(&work, WORK_DX);
     c_a = get_work1(&work, WORK_DX);
     d_a = get_work1(&work, WORK_DX);
     e_a = get_work1(&work, WORK_DX);
     p_a = get_work1(&work, WORK_DX);
     h_a = get_work1(&work, WORK_DX);

     w1  = get_work1(&work, WORK_DXX);


     /*-------------------------------------------------------------------------
      *
      *-----------------------------------------------------------------------*/
     dm_v_mul_D_A(n_quad, n_stokes, F_m_a, F_m_a);

     dvec_add(F_p_a, F_m_a, F_p_a, n_quad_v);

     dvec_scale(-1., F_m_a, p_a, n_quad_v);

     *as_0_a += -dvec_dot(save->h, F_p_a, n_quad_v) / (2. * as_0 * as_0);

     dvec_scale(1. / (2. * as_0), F_p_a, h_a, n_quad_v);

     dvec_scale(1. / 2., F_p_a, v1, n_quad_v);
     dvec_add(p_a, v1, p_a, n_quad_v);

     dmat_vxvtmx(h_a, save->p, 1., tpr_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, tpr, h_a, 1., p_a, 1., n_quad_v, n_quad_v);

     dvec_copy(e_a, h_a, n_quad_v);

     dvec_copy(v1, p_a,  n_quad_v);
     dmat_getrs2('t', save->f, &v1, n_quad_v, 1, save->ip);

     dmat_vxvtmx(v1, save->p, -1., w1, 0., n_quad_v, n_quad_v);

     dmat_add(gamma_a, w1, gamma_a, n_quad_v, n_quad_v);

     for (i = 0; i < n_quad_v; ++i)
          *as_0_a += -2. * as_0 * w1[i][i];

     dmat_vxvtmx(v1, save->e, -1., tmr_a, 1., n_quad_v, n_quad_v);

     dmat_gxvxmx(1, tmr, v1, -1., e_a, 1., n_quad_v, n_quad_v);

     *as_0_a -= dvec_dot(v1, save->d, n_quad_v);

     dvec_scale(-as_0, v1, d_a, n_quad_v);

     dvec_copy(b_a, e_a, n_quad_v);
     dvec_scale(-1., e_a, c_a, n_quad_v);

     dvec_add(b_a, d_a, b_a, n_quad_v);
     dvec_add(c_a, d_a, c_a, n_quad_v);

     dm_v_mul_D_A(n_quad, n_stokes, c_a, c_a);

     for (i = 0; i < n_quad_v; ++i)
          a_a[i]  = c_a[i] * P_q0_mm[i];

     for (i = 0; i < n_quad_v; ++i)
          P_q0_mm_a[i] += F_0 * omega / (4. * PI) / qx_v[i] * c_a[i];
     
     for (i = 0; i < n_quad_v; ++i)
          a_a[i] += b_a[i] * P_q0_pm[i];

     for (i = 0; i < n_quad_v; ++i)
          P_q0_pm_a[i] += F_0 * omega / (4. * PI) / qx_v[i] * b_a[i];

     for (i = 0; i < n_quad_v; ++i)
          *omega_a += F_0 / (4. * PI) / qx_v[i] * a_a[i];

     dvec_zero(F_p_a, n_quad_v);
     dvec_zero(F_m_a, n_quad_v);
}
Exemplo n.º 9
0
static void add_all_u_l_up_a(double **PXX, int *i1, double **AXX, double **BXX, double *CXX, double **T12, double *S12, double **R21, double **T32, double **R23_a, double **T32_a, double *S32_a, double **R13_a, double **T31_a, double *S31_a, int n, double atran, double *v1, double *v2, double **w1, double **w2, work_data work) {
/*
     double **w3;
*/
     double **DXX_a;
     double **EXX_a;
/*
     w3    = get_work1(&work, WORK_DXX);
*/
     DXX_a = get_work1(&work, WORK_DXX);
     EXX_a = get_work1(&work, WORK_DXX);
/*
     dmat_trans(T32, w1, n, n);
     dmat_mul(T31_a, w1, n, n, n, EXX_a);
*/
     dmat_gxgxmx(0, T31_a, 1, T32, 1., EXX_a, 0., n, n, n);
/*
     dmat_trans(AXX, w1, n, n);
     dmat_mul(w1, T31_a, n, n, n, w2);
     dmat_add(T32_a, w2, T32_a, n, n);
*/
     dmat_gxgxmx(1, AXX, 0, T31_a, 1., T32_a, 1., n, n, n);
/*
     dmat_trans(BXX, w1, n, n);
     dmat_mul(R13_a, w1, n, n, n, w2);
     dmat_add(EXX_a, w2, EXX_a, n, n);
*/
     dmat_gxgxmx(0, R13_a, 1, BXX, 1., EXX_a, 1., n, n, n);
/*
     dmat_trans(T12, w1, n, n);
     dmat_mul(R13_a, w1, n, n, n, DXX_a);
*/
     dmat_gxgxmx(0, R13_a, 1, T12, 1., DXX_a, 0., n, n, n);

     dmat_vxvtmx(S31_a, CXX, 1., EXX_a, 1., n, n);
/*
     dmat_trans(AXX, w1, n, n);
     dm_v_mul(w1, S31_a, n, n, v1);
*/
     dmat_gxvxmx(1, AXX, S31_a, 1., v1, 0., n, n);

     dvec_scale(atran, v1, v2, n);
     dvec_add(S32_a, v2, S32_a, n);

     dmat_vxvtmx(v1, S12, 1., R23_a, 1., n, n);

     dmat_copy(w1, EXX_a, n, n);
     dmat_getrs2('t', PXX, w1, n, n, i1);
/*
     dmat_trans(R21, w2, n, n);
     dmat_mul(w1, w2, n, n, n, w3);
     dmat_add(DXX_a, w3, DXX_a, n, n);
*/
     dmat_gxgxmx(0, w1, 1, R21, 1., DXX_a, 1., n, n, n);
/*
     dmat_trans(AXX, w1, n, n);
     dmat_mul(w1, DXX_a, n, n, n, w2);
     dmat_add(R23_a, w2, R23_a, n, n);
*/
     dmat_gxgxmx(1, AXX, 0, DXX_a, 1., R23_a, 1., n, n, n);

     dmat_zero(R13_a, n, n);
     dmat_zero(T31_a, n, n);
     dvec_zero(S31_a, n);
}
Exemplo n.º 10
0
static void add_ref_p_u_a(double **AXX, double **R23, double *S12_a, double *S21_a, double *S31_a, int n, double atran, double *v1, double *v2) {

     dvec_zero(S31_a, n);
}
Exemplo n.º 11
0
static void add_ref_l_u_a(double **PXX, int *i1, double **AXX, double **BXX, double *CXX, double **R23, double *S32, double **R12_a, double **T12_a, double *S12_a, double **R21_a, double **T21_a, double *S21_a, double **R13_a, double *S31_a, int n, double atran, double *atran_a, double *v1, double *v2, double **w1, double **w2, work_data work) {

     dmat_zero(R13_a, n, n);
     dvec_zero(S31_a, n);
}