FINT CINTinit_int3c1e_EnvVars(CINTEnvVars *envs, const FINT *ng, const FINT *shls, const FINT *atm, const FINT natm, const FINT *bas, const FINT nbas, const double *env) { envs->natm = natm; envs->nbas = nbas; envs->atm = atm; envs->bas = bas; envs->env = env; envs->shls = shls; const FINT i_sh = shls[0]; const FINT j_sh = shls[1]; const FINT k_sh = shls[2]; envs->i_l = bas(ANG_OF, i_sh); envs->j_l = bas(ANG_OF, j_sh); envs->k_l = bas(ANG_OF, k_sh); envs->i_prim = bas(NPRIM_OF, i_sh); envs->j_prim = bas(NPRIM_OF, j_sh); envs->k_prim = bas(NPRIM_OF, k_sh); envs->i_ctr = bas(NCTR_OF, i_sh); envs->j_ctr = bas(NCTR_OF, j_sh); envs->k_ctr = bas(NCTR_OF, k_sh); envs->nfi = CINTlen_cart(envs->i_l); envs->nfj = CINTlen_cart(envs->j_l); envs->nfk = CINTlen_cart(envs->k_l); envs->nf = envs->nfi * envs->nfj * envs->nfk; envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh)); envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh)); envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh)); envs->gbits = ng[GSHIFT]; envs->ncomp_e1 = ng[POS_E1]; envs->ncomp_tensor = ng[TENSOR]; envs->li_ceil = envs->i_l + ng[IINC]; envs->lj_ceil = envs->j_l + ng[JINC]; envs->lk_ceil = envs->k_l + ng[KINC]; envs->common_factor = SQRTPI * M_PI * CINTcommon_fac_sp(envs->i_l) * CINTcommon_fac_sp(envs->j_l) * CINTcommon_fac_sp(envs->k_l); FINT dli = envs->li_ceil + 1; FINT dlj = envs->lj_ceil + envs->lk_ceil + 1; FINT dlk = envs->lk_ceil + 1; envs->g_stride_i = 1; envs->g_stride_j = dli; envs->g_stride_k = dli * dlj; FINT nmax = envs->li_ceil + dlj; envs->g_size = MAX(dli*dlj*dlk, dli*nmax); envs->rirj[0] = envs->ri[0] - envs->rj[0]; envs->rirj[1] = envs->ri[1] - envs->rj[1]; envs->rirj[2] = envs->ri[2] - envs->rj[2]; return 0; }
void CINTinit_int1e_EnvVars(CINTEnvVars *envs, FINT *ng, FINT *shls, FINT *atm, FINT natm, FINT *bas, FINT nbas, double *env) { envs->natm = natm; envs->nbas = nbas; envs->atm = atm; envs->bas = bas; envs->env = env; envs->shls = shls; const FINT i_sh = shls[0]; const FINT j_sh = shls[1]; envs->i_l = bas(ANG_OF, i_sh); envs->j_l = bas(ANG_OF, j_sh); envs->x_ctr[0] = bas(NCTR_OF, i_sh); envs->x_ctr[1] = bas(NCTR_OF, j_sh); envs->nfi = (envs->i_l+1)*(envs->i_l+2)/2; envs->nfj = (envs->j_l+1)*(envs->j_l+2)/2; envs->nf = envs->nfi * envs->nfj; envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh)); envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh)); envs->common_factor = 1; envs->gbits = ng[GSHIFT]; envs->ncomp_e1 = ng[POS_E1]; envs->ncomp_tensor = ng[TENSOR]; envs->li_ceil = envs->i_l + ng[IINC]; envs->lj_ceil = envs->j_l + ng[JINC]; envs->nrys_roots =(envs->li_ceil + envs->lj_ceil)/2 + 1; assert(i_sh < SHLS_MAX); assert(j_sh < SHLS_MAX); assert(envs->i_l < ANG_MAX); assert(envs->j_l < ANG_MAX); assert(bas(ATOM_OF,i_sh) >= 0); assert(bas(ATOM_OF,j_sh) >= 0); assert(bas(ATOM_OF,i_sh) < natm); assert(bas(ATOM_OF,j_sh) < natm); assert(envs->nrys_roots < MXRYSROOTS); FINT dli = envs->li_ceil + envs->lj_ceil + 1; FINT dlj = envs->lj_ceil + 1; envs->g_stride_i = 1; envs->g_stride_j = dli; envs->g_stride_k = dli * dlj; envs->g_size = dli * dlj; }
END_TEST ////////////////////////////////////////////////////////////////////// ///////////// atm unit tests ////////////////////////////////////////////////////////////////////// START_TEST(test_atm_invalid_command_status) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int fd[2]; pipe(fd); int atm_read = fd[0]; int bank_write = fd[1]; // The atm message buffer. Command atmcmd; // Create an invalid command (99). cmd_pack(&atmcmd, 99, 0, 1, 2, 3); // Send it to the atm. int status = atm(bank_write, atm_read, 0, &atmcmd); ck_assert_msg(status == ERR_UNKNOWN_CMD, "atm should return ERR_UNKNOWN_CMD, received %d", status); close(atm_read); close(bank_write); }
END_TEST START_TEST(test_atm_unknown_atm) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int fd[2]; pipe(fd); int atm_read = fd[0]; int bank_write = fd[1]; // The atm message buffer. Command atmcmd; // Create a connect message for ATM 0. MSG_CONNECT(&atmcmd, 0); // Send it to the atm with the incorrect ATM id. int status = atm(bank_write, atm_read, 1, &atmcmd); ck_assert_msg(status == ERR_UNKNOWN_ATM, "atm should return ERR_UNKNOWN_ATM, received %d", status); close(atm_read); close(bank_write); }
END_TEST START_TEST(test_atm_invalid_pipe_write_closed) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int fd[2]; pipe(fd); int bank_write = fd[1]; int atm_read = fd[0]; // But, we close the write end of the pipe. close(bank_write); // Closing the write end of the pipe will cause a write to that pipe // to return 0 indicating EOF. The atm function must handle this // case. It will return a status indicating ERR_PIPE_WRITE_ERR. // The atm message buffer. Command atmcmd; MSG_CONNECT(&atmcmd, 0); // Send it to the atm. int status = atm(bank_write, atm_read, 0, &atmcmd); ck_assert_msg(status == ERR_PIPE_WRITE_ERR, "atm should return ERR_PIPE_WRITE_ERR, received %d", status); }
END_TEST START_TEST(test_atm_invalid_pipe_read_signal) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int fd[2]; pipe(fd); int bank_write = fd[1]; int atm_read = fd[0]; // But, we close the read pipe. close(atm_read); // This will create a "broken" pipe. If the ATM tries to write to a // broken pipe it will send a SIGPIPE signal to the process. This is // checked in the test case below. // The atm message buffer. Command atmcmd; MSG_CONNECT(&atmcmd, 0); // Send it to the atm. atm(bank_write, atm_read, 0, &atmcmd); }
void granted(void) { system("clear"); printf("\n * Authentication Successful *"); printf("\n * Welcome to the C.C ATM! *"); printf("\n ----------$$$----------\n\n"); atm(); }
END_TEST START_TEST(test_atm_balance_success) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int bankfd[2]; pipe(bankfd); int atmfd[2]; pipe(atmfd); int bank_read = bankfd[0]; int bank_write = bankfd[1]; int atm_read = atmfd[0]; int atm_write = atmfd[1]; // The command buffer. Command cmd; MSG_BALANCE(&cmd, 0, 1); if (fork() == 0) { // Send it to the atm. int status = atm(bank_write, atm_read, 0, &cmd); ck_assert_msg(status == SUCCESS, "status should be SUCCESS, received %d", status); } else { // Need to set the read end of pipe to non-blocking otherwise // students without an implementation will not be able to run // tests. int flags = fcntl(bank_read, F_GETFL, 0); fcntl(bank_read, F_SETFL, flags | O_NONBLOCK); sleep(1); int status = read(bank_read, &cmd, MESSAGE_SIZE); ck_assert_msg(status != -1, "ATM should have sent data to the bank"); cmd_t c; int i, f, t, a; cmd_unpack(&cmd, &c, &i, &f, &t, &a); ck_assert_msg(c == BALANCE, "received message should be balance, got %d", c); ck_assert_int_eq(i, 0); ck_assert_int_eq(f, 1); ck_assert_int_eq(t, -1); ck_assert_int_eq(a, -1); MSG_OK(&cmd, i, f, t, a); write(atm_write, &cmd, MESSAGE_SIZE); } // Close file descriptors. close(bankfd[0]); close(bankfd[1]); close(atmfd[0]); close(atmfd[1]); }
/* * 1e integrals <i|O|j> with nuclear attraction * TODO: add the gaussian nuclear model */ FINT CINT1e_nuc_drv(double *opij, CINTEnvVars *envs, double fac, void (*const f_c2s)()) { const FINT *shls = envs->shls; const FINT *atm = envs->atm; const FINT *bas = envs->bas; const double *env = envs->env; const FINT i_sh = shls[0]; const FINT j_sh = shls[1]; const FINT i_l = envs->i_l; const FINT j_l = envs->j_l; const FINT i_ctr = envs->i_ctr; const FINT j_ctr = envs->j_ctr; const FINT nfi = envs->nfi; const FINT nfj = envs->nfj; const FINT nc = nfi * nfj * i_ctr * j_ctr * envs->ncomp_e1; FINT has_value = 0, has_value0; FINT ip, jp, nop; FINT n; double *gctr = malloc(sizeof(double) * nc * envs->ncomp_tensor); double *pgctr = gctr; CINTdset0(nc * envs->ncomp_tensor, gctr); for (n = 0; n < envs->natm; n++) { has_value0 = CINT1e_nuc_loop(gctr, envs, -fabs(atm(CHARGE_OF,n))*fac, n); has_value = has_value || has_value0; } if (f_c2s == c2s_sph_1e) { ip = CINTcgto_spheric(i_sh, bas); jp = CINTcgto_spheric(j_sh, bas); nop = ip * jp; } else if (f_c2s == c2s_cart_1e) { ip = CINTcgto_cart(i_sh, bas); jp = CINTcgto_cart(j_sh, bas); nop = ip * jp; } else { ip = CINTcgto_spinor(i_sh, bas); jp = CINTcgto_spinor(j_sh, bas); nop = ip * jp * OF_CMPLX; } if (!has_value) { CINTdset0(nop * envs->ncomp_tensor, opij); } else { for (n = 0; n < envs->ncomp_tensor; n++) { (*f_c2s)(opij, pgctr, shls, bas); opij += nop; pgctr += nc; } } free(gctr); return has_value; }
/* * for given nuclear model, calculate temporary parameter tau * aij = ai + aj */ static double CINTnuc_mod(const double aij, const FINT nuc_id, const FINT *atm, const double *env) { const FINT mass[109] = { \ 1 , 4 , 7 , 9 , 11 , 12 , 14 , 16 , 19 , 20 , \ 23 , 24 , 27 , 28 , 31 , 32 , 35 , 40 , 39 , 40 , \ 45 , 48 , 51 , 52 , 55 , 56 , 59 , 58 , 63 , 64 , \ 69 , 74 , 75 , 80 , 79 , 84 , 85 , 88 , 89 , 90 , \ 93 , 98 , 98 , 102, 103, 106, 107, 114, 115 , 120, \ 121, 130, 127, 132, 133, 138, 139, 140, 141 , 144, \ 145, 152, 153, 158, 159, 162, 162, 168, 169 , 174, \ 175, 180, 181, 184, 187, 192, 193, 195, 197 , 202, \ 205, 208, 209, 209, 210, 222, 223, 226, 227 , 232, \ 231, 238, 237, 244, 243, 247, 247, 251, 252 , 257, \ 258, 259, 262, 261, 262, 263, 262, 265, 266}; /* screened nuclear potential of Gaussian nuclear model: * M. Filatov and D. Cremer, Theor. Chem. Acc. 108, 168 (2002) * M. Filatov and D. Cremer, Chem. Phys. Lett. 351, 259 (2002) r = (-0.263188 * atm(CHARGE_OF, nuc_id) + 106.016974 \ + 138.985999 / atm(CHARGE_OF, nuc_id)) \ / (env[PTR_LIGHT_SPEED] * env[PTR_LIGHT_SPEED]); eta = 1 / (r * r); */ double a, r, eta; switch (atm(NUC_MOD_OF, nuc_id)) { case POINT_NUC: return 1; case GAUSSIAN_NUC: a = pow(mass[atm(CHARGE_OF,nuc_id)], (double)1 / 3); r = (0.836 * a + 0.570) / 52917.7249; eta = 1.5 / (r * r); return sqrt(eta / (aij + eta)); default: return 1; } }
END_TEST START_TEST(test_atm_connect_success) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int bankfd[2]; pipe(bankfd); int atmfd[2]; pipe(atmfd); int bank_read = bankfd[0]; int bank_write = bankfd[1]; int atm_read = atmfd[0]; int atm_write = atmfd[1]; // The command buffer. Command cmd; MSG_CONNECT(&cmd, 0); if (fork() == 0) { // Send it to the atm. int status = atm(bank_write, atm_read, 0, &cmd); ck_assert_msg(status == SUCCESS, "status should be SUCCESS, received %d", status); } else { int flags = fcntl(bank_read, F_GETFL, 0); fcntl(bank_read, F_SETFL, flags | O_NONBLOCK); sleep(1); int status = read(bank_read, &cmd, MESSAGE_SIZE); ck_assert_msg(status != -1, "ATM should have sent data to the bank"); cmd_t c; int i, f, t, a; cmd_unpack(&cmd, &c, &i, &f, &t, &a); ck_assert_msg(c == CONNECT, "received message should be connect, got %d", c); MSG_OK(&cmd, i, f, t, a); write(atm_write, &cmd, MESSAGE_SIZE); } // Close file descriptors. close(bankfd[0]); close(bankfd[1]); close(atmfd[0]); close(atmfd[1]); }
int atm_run(char *trace, int bank_out_fd, int atm_in_fd, int atm_id) { int status = trace_open(trace); if (status == -1) { error_msg(ERR_BAD_TRACE_FILE, "could not open trace file"); return ERR_BAD_TRACE_FILE; } byte cmd[MESSAGE_SIZE]; while (trace_read_cmd(cmd) != 0) { status = atm(bank_out_fd, atm_in_fd, atm_id, cmd); // We continue if the ATM as unknown. This is ok because the trace // file contains commands for all the ATMs. if (status == ERR_UNKNOWN_ATM) { continue; } // We display an error message to the ATM user if the account // is not valid. if (status == ERR_UNKNOWN_ACCOUNT) { printf("ATM error: unknown account! ATM Out of service\n"); continue; } // We display an error message to the ATM user if the account // does not have sufficient funds. if (status == ERR_NOFUNDS) { printf("not enough funds, retry transaction\n"); continue; } // If we receive a status that is not successful we return with // the status. if (status != SUCCESS) { printf("status is %d\n", status); return status; } } trace_close(); return SUCCESS; }
END_TEST START_TEST(test_atm_invalid_pipe_write) { // Invalid pipe descriptors int atm_read = -1; int bank_write = -1; // The atm message buffer. Command atmcmd; MSG_CONNECT(&atmcmd, 0); // Send it to the atm. int status = atm(bank_write, atm_read, 0, &atmcmd); ck_assert_msg(status == ERR_PIPE_WRITE_ERR, "atm should return ERR_PIPE_WRITE_ERR, received %d", status); }
END_TEST START_TEST(test_atm_invalid_pipe_read) { // The file descriptors used for writing to the bank process and // reading in from the atm process. int fd[2]; pipe(fd); int bank_write = fd[1]; // But, we invalidate the read pipe. int atm_read = -1; // The atm message buffer. Command atmcmd; MSG_CONNECT(&atmcmd, 0); // Send it to the atm. int status = atm(bank_write, atm_read, 0, &atmcmd); ck_assert_msg(status == ERR_PIPE_READ_ERR, "atm should return ERR_PIPE_READ_ERR, received %d", status); }
void CINTinit_int2e_stg_EnvVars(CINTEnvVars *envs, int *ng, int *shls, int *atm, int natm, int *bas, int nbas, double *env) { envs->natm = natm; envs->nbas = nbas; envs->atm = atm; envs->bas = bas; envs->env = env; envs->shls = shls; int i_sh = shls[0]; int j_sh = shls[1]; int k_sh = shls[2]; int l_sh = shls[3]; envs->i_l = bas(ANG_OF, i_sh); envs->j_l = bas(ANG_OF, j_sh); envs->k_l = bas(ANG_OF, k_sh); envs->l_l = bas(ANG_OF, l_sh); envs->x_ctr[0] = bas(NCTR_OF, i_sh); envs->x_ctr[1] = bas(NCTR_OF, j_sh); envs->x_ctr[2] = bas(NCTR_OF, k_sh); envs->x_ctr[3] = bas(NCTR_OF, l_sh); envs->nfi = (envs->i_l+1)*(envs->i_l+2)/2; envs->nfj = (envs->j_l+1)*(envs->j_l+2)/2; envs->nfk = (envs->k_l+1)*(envs->k_l+2)/2; envs->nfl = (envs->l_l+1)*(envs->l_l+2)/2; envs->nf = envs->nfi * envs->nfk * envs->nfl * envs->nfj; envs->common_factor = 1; envs->gbits = ng[GSHIFT]; envs->ncomp_e1 = ng[POS_E1]; envs->ncomp_e2 = ng[POS_E2]; envs->ncomp_tensor = ng[TENSOR]; envs->li_ceil = envs->i_l + ng[IINC]; envs->lj_ceil = envs->j_l + ng[JINC]; envs->lk_ceil = envs->k_l + ng[KINC]; envs->ll_ceil = envs->l_l + ng[LINC]; envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh)); envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh)); envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh)); envs->rl = env + atm(PTR_COORD, bas(ATOM_OF, l_sh)); // ceil(L_tot/2) + 1 int nroots = (envs->li_ceil + envs->lj_ceil + envs->lk_ceil + envs->ll_ceil + 3)/2; envs->nrys_roots = nroots; assert(nroots < MXRYSROOTS); int dli, dlj, dlk, dll; int ibase = envs->li_ceil > envs->lj_ceil; int kbase = envs->lk_ceil > envs->ll_ceil; if (kbase) { if (ibase) { envs->f_g0_2d4d = &CINTg0_2e_ik2d4d; envs->f_g0_2d4d_simd1 = &CINTg0_2e_ik2d4d_simd1; } else { envs->f_g0_2d4d = &CINTg0_2e_kj2d4d; envs->f_g0_2d4d_simd1 = &CINTg0_2e_kj2d4d_simd1; } } else { if (ibase) { envs->f_g0_2d4d = &CINTg0_2e_il2d4d; envs->f_g0_2d4d_simd1 = &CINTg0_2e_il2d4d_simd1; } else { envs->f_g0_2d4d = &CINTg0_2e_lj2d4d; envs->f_g0_2d4d_simd1 = &CINTg0_2e_lj2d4d_simd1; } } envs->f_g0_2e = &CINTg0_2e_stg; envs->f_g0_2e_simd1 = &CINTg0_2e_stg_simd1; if (kbase) { dlk = envs->lk_ceil + envs->ll_ceil + 1; dll = envs->ll_ceil + 1; } else { dlk = envs->lk_ceil + 1; dll = envs->lk_ceil + envs->ll_ceil + 1; } if (ibase) { dli = envs->li_ceil + envs->lj_ceil + 1; dlj = envs->lj_ceil + 1; } else { dli = envs->li_ceil + 1; dlj = envs->li_ceil + envs->lj_ceil + 1; } envs->g_stride_i = nroots; envs->g_stride_k = nroots * dli; envs->g_stride_l = nroots * dli * dlk; envs->g_stride_j = nroots * dli * dlk * dll; envs->g_size = nroots * dli * dlk * dll * dlj; if (kbase) { envs->g2d_klmax = envs->g_stride_k; envs->rx_in_rklrx = envs->rk; envs->rkrl[0] = envs->rk[0] - envs->rl[0]; envs->rkrl[1] = envs->rk[1] - envs->rl[1]; envs->rkrl[2] = envs->rk[2] - envs->rl[2]; } else { envs->g2d_klmax = envs->g_stride_l; envs->rx_in_rklrx = envs->rl; envs->rkrl[0] = envs->rl[0] - envs->rk[0]; envs->rkrl[1] = envs->rl[1] - envs->rk[1]; envs->rkrl[2] = envs->rl[2] - envs->rk[2]; } if (ibase) { envs->g2d_ijmax = envs->g_stride_i; envs->rx_in_rijrx = envs->ri; envs->rirj[0] = envs->ri[0] - envs->rj[0]; envs->rirj[1] = envs->ri[1] - envs->rj[1]; envs->rirj[2] = envs->ri[2] - envs->rj[2]; } else { envs->g2d_ijmax = envs->g_stride_j; envs->rx_in_rijrx = envs->rj; envs->rirj[0] = envs->rj[0] - envs->ri[0]; envs->rirj[1] = envs->rj[1] - envs->ri[1]; envs->rirj[2] = envs->rj[2] - envs->ri[2]; } }
void CINTOpt_setij(CINTOpt *opt, FINT *ng, const FINT *atm, const FINT natm, const FINT *bas, const FINT nbas, const double *env) { FINT i, j, ip, jp, io, jo, off; if (!opt->prim_offset) { opt->prim_offset = (FINT *)malloc(sizeof(FINT) * nbas); opt->tot_prim = 0; for (i = 0; i < nbas; i++) { opt->prim_offset[i] = opt->tot_prim; opt->tot_prim += bas(NPRIM_OF, i); } } FINT ik_inc, jl_inc; if ((ng[IINC]+ng[JINC]) > (ng[KINC]+ng[LINC])) { ik_inc = ng[IINC]; jl_inc = ng[JINC]; } else { ik_inc = ng[KINC]; jl_inc = ng[LINC]; } FINT iprim, ictr, jprim, jctr, il, jl; double eij, aij, rr, maxci, maxcj, rirj_g4d; const double *ai, *aj, *ri, *rj, *ci, *cj; double *expij, *rij; FINT *cceij; opt->expij = (double **)malloc(sizeof(double *) * opt->tot_prim); opt->rij = (double **)malloc(sizeof(double *) * opt->tot_prim); opt->cceij = (FINT **)malloc(sizeof(FINT *) * opt->tot_prim); for (i = 0; i < nbas; i++) { ri = env + atm(PTR_COORD,bas(ATOM_OF,i)); ai = env + bas(PTR_EXP,i); io = opt->prim_offset[i]; iprim = bas(NPRIM_OF,i); ictr = bas(NCTR_OF,i); ci = env + bas(PTR_COEFF,i); // For derivative/dipole operator, the l-value in g2e is virtually increased il = bas(ANG_OF,i) + ik_inc; for (ip = 0; ip < bas(NPRIM_OF,i); ip++) { maxci = max_pgto_coeff(ci, iprim, ictr, ip); maxci = maxci / CINTgto_norm(il, ai[ip]); expij = (double *)malloc(sizeof(double)*opt->tot_prim); rij = (double *)malloc(sizeof(double)*opt->tot_prim*3); cceij = (FINT *)malloc(sizeof(FINT) * opt->tot_prim); opt->expij[io+ip] = expij; opt->rij[io+ip] = rij; opt->cceij[io+ip] = cceij; for (j = 0; j < nbas; j++) { rj = env + atm(PTR_COORD,bas(ATOM_OF,j)); aj = env + bas(PTR_EXP,j); jo = opt->prim_offset[j]; jprim = bas(NPRIM_OF,j); jctr = bas(NCTR_OF,j); cj = env + bas(PTR_COEFF,j); jl = bas(ANG_OF,j) + jl_inc; rr = (ri[0]-rj[0])*(ri[0]-rj[0]) + (ri[1]-rj[1])*(ri[1]-rj[1]) + (ri[2]-rj[2])*(ri[2]-rj[2]); for (jp = 0; jp < bas(NPRIM_OF,j); jp++) { maxcj = max_pgto_coeff(cj, jprim, jctr, jp); maxcj = maxcj/CINTgto_norm(jl, aj[jp]); aij = ai[ip] + aj[jp]; off = jo + jp; eij = rr * ai[ip] * aj[jp] / aij; expij[off] = exp(-eij); rij[off*3+0] = (ai[ip]*ri[0] + aj[jp]*rj[0]) / aij; rij[off*3+1] = (ai[ip]*ri[1] + aj[jp]*rj[1]) / aij; rij[off*3+2] = (ai[ip]*ri[2] + aj[jp]*rj[2]) / aij; /* estimation of the value, based on g0_2e_2d and g0_xx2d_4d, * value ~< exp(-eij)*(il+jl+2)!*(aij/2)^(il+jl)*(ri_or_rj-rij)^(ij+jl)*rirj^max(il,jl) * ~< * exp(-eij)*(il+jl+2)!*(aij/2)^(il+jl)*rirj^((il+jl)+max(il,jl)) * But in practice, rirj^((il+jl)/2) is usually large enough to cover all other factors */ /* rr+1 to prevent log() diverge when i,j on same center */ rirj_g4d = pow((rr+1), (il+jl+1)/2); /*cceij[off] =-log(expij[off]*maxci*maxcj*rirj_g4d); when eij is big, expij == 0, singular value in cceij */ cceij[off] = eij - log(maxci*maxcj*rirj_g4d); } } } } }
int test() { std::vector<std::string> neutrals; std::vector<std::string> ions; neutrals.push_back("N2"); neutrals.push_back("CH4"); ions.push_back("N2+"); ions.push_back("e"); Scalar chi(100.L); std::vector<Scalar> lambda_ref,phy1AU,phy_on_top; std::ifstream flux_1AU("./input/hv_SSI.dat"); std::string line; getline(flux_1AU,line); while(!flux_1AU.eof()) { Scalar wv,ir,dirr; flux_1AU >> wv >> ir >> dirr; if(!lambda_ref.empty() && wv == lambda_ref.back())continue; lambda_ref.push_back(wv);//nm phy1AU.push_back(ir);//W/m2/nm phy_on_top.push_back(ir/std::pow(Planet::Constants::Saturn::d_Sun<Scalar>(),2)); } flux_1AU.close(); Planet::Chapman<Scalar> chapman(chi); Planet::PhotonFlux<Scalar,std::vector<Scalar>, std::vector<std::vector<Scalar> > > photon(chapman); photon.set_photon_flux_top_atmosphere(lambda_ref,phy1AU,Planet::Constants::Saturn::d_Sun<Scalar>()); std::vector<Scalar> molar_frac = {0.96,0.04,0.,0.}; Scalar dens_tot(1e12); Planet::Atmosphere<Scalar, std::vector<Scalar>, std::vector<std::vector<Scalar> > > atm(neutrals,ions,photon); atm.make_altitude_grid(600.,1400.,10.); std::ifstream temp("input/temperature.dat"); std::vector<Scalar> T0,Tz; getline(temp,line); while(!temp.eof()) { Scalar t,tz,dt,dtz; temp >> t >> tz >> dt >> dtz; T0.push_back(t); Tz.push_back(tz); } temp.close(); atm.set_temperature(T0,Tz); std::vector<Scalar> T = atm.temperature_top_to_bottom(); std::vector<std::vector<Scalar> > MatrixTotalDensity; std::vector<Scalar> tot_dens = atm.total_density_top_to_bottom(); std::vector<Scalar> lambda_N2,sigma_N2; std::vector<std::vector<Scalar> > sigma_rate_N2; sigma_rate_N2.resize(3); std::ifstream sig_N2("./input/N2_hv_cross-sections.dat"); std::ifstream sig_CH4("./input/CH4_hv_cross-sections.dat"); getline(sig_N2,line); getline(sig_CH4,line); while(!sig_N2.eof()) { Scalar wv,sigt,sig1,sig2,sig3; sig_N2 >> wv >> sigt >> sig1 >> sig2 >> sig3; lambda_N2.push_back(wv/10.);//A -> nm sigma_N2.push_back(sigt*10.);//cm-2/A -> cm-2/nm sigma_rate_N2[0].push_back(sig1*10.); sigma_rate_N2[1].push_back(sig2*10.); sigma_rate_N2[2].push_back(sig3*10.); } sig_N2.close(); atm.add_photoabsorption("N2",lambda_N2,sigma_N2); std::vector<Scalar> lambda_CH4,sigma_CH4; std::vector<std::vector<Scalar> > sigma_rate_CH4; sigma_rate_CH4.resize(9); while(!sig_CH4.eof()) { Scalar wv,sigt,sig1,sig2,sig3,sig4,sig5,sig6,sig7,sig8,sig9; sig_CH4 >> wv >> sigt >> sig1 >> sig2 >> sig3 >> sig4 >> sig5 >> sig6 >> sig7 >> sig8 >> sig9; lambda_CH4.push_back(wv/10.);//A -> nm sigma_CH4.push_back(sigt*10.);//cm-2/A -> cm-2/nm sigma_rate_CH4[0].push_back(sig1*10.); sigma_rate_CH4[1].push_back(sig2*10.); sigma_rate_CH4[2].push_back(sig3*10.); sigma_rate_CH4[3].push_back(sig4*10.); sigma_rate_CH4[4].push_back(sig5*10.); sigma_rate_CH4[5].push_back(sig6*10.); sigma_rate_CH4[6].push_back(sig7*10.); sigma_rate_CH4[7].push_back(sig8*10.); sigma_rate_CH4[8].push_back(sig9*10.); } sig_CH4.close(); atm.add_photoabsorption("CH4",lambda_CH4,sigma_CH4); atm.init_composition(molar_frac,dens_tot); int return_flag(0); //Phy at top std::vector<Scalar> phy_top; phy_top.resize(lambda_ref.size(),0.L); for(unsigned int il = 0; il < lambda_ref.size(); il++) { phy_top[il] = phy1AU[il]/(Planet::Constants::Saturn::d_Sun<Scalar>() * Planet::Constants::Saturn::d_Sun<Scalar>()); if(check_test(phy_top[il],photon.phy_at_top()[il],"Photon flux at top"))return_flag = 1; } std::ofstream out("phy_z.dat"); std::ofstream out_the("phy_z_the.dat"); out_the << "z N_N N+_N N2+ sCH2_H2 CH3_H CH2_H_H CH4+ CH3+_H CH2+_H2 CH+_H2_H H+_CH3 CH_H2_H" << std::endl; std::vector<Scalar> lamb = atm.hv_flux().lambda(); std::vector<Scalar> sum_over_neutral; sum_over_neutral.resize(2,0.L); std::vector<Scalar> tau_theo; std::vector<Scalar> rate_N2,rate_CH4; rate_N2.resize(3); rate_CH4.resize(9); Scalar MN(14.008L), MC(12.011), MH(1.008L); Scalar MN2 = 2.L*MN , MCH4 = MC + 4.L*MH; unsigned int ialt(0); for(Scalar z = 1400.; z >= 600.; z -= 10.) { Scalar M_the = molar_frac[0] * MN2 + molar_frac[1] * MCH4; Scalar n_tot_the = dens_tot * std::exp(-(z - 600.) / ( (z + Planet::Constants::Titan::radius<Scalar>()) * (600. + Planet::Constants::Titan::radius<Scalar>()) * 1e3L * //to m ( (Planet::Constants::Universal::kb<Scalar>() * Antioch::Constants::Avogadro<Scalar>() * T[ialt]) / (Planet::Constants::Universal::G<Scalar>() * Planet::Constants::Titan::mass<Scalar>() * M_the * 1e-3L) //to kg/mol ) )); tau_theo.clear(); tau_theo.resize(lambda_ref.size(),0.L); for(unsigned int i = 0; i < 2; i++) { sum_over_neutral[i] += molar_frac[i] * n_tot_the; for(unsigned int il = 0; il < lambda_ref.size(); il++) { tau_theo[il] += sum_over_neutral[i] * atm.photon_sigma(i).y_on_custom()[il]; //filtering } } std::vector<Scalar> tau_cal = photon.tau(z,sum_over_neutral); for(unsigned int il = 0; il < lambda_ref.size(); il++) { tau_theo[il] *= chapman.chapman(atm.a(z)); if(check_test(tau_theo[il],tau_cal[il],"tau at altitude z"))return_flag = 1; } for(unsigned int ir = 0; ir < 3; ir++) { rate_N2[ir] = 0.L; for(unsigned int il = 0; il < lamb.size(); il++) { rate_N2[ir] += sigma_rate_N2[ir][il] * phy_on_top[il] * std::exp(-tau_theo[il]); } } for(unsigned int ir = 0; ir < 9; ir++) { rate_CH4[ir] = 0.L; for(unsigned int il = 0; il < lamb.size(); il++) { rate_CH4[ir] += sigma_rate_CH4[ir][il] * phy_on_top[il] * std::exp(-tau_theo[il]); } } std::vector<Scalar> phy_flux = atm.hv_flux().phy(z); for(unsigned int il = 0; il < phy_flux.size(); il++) { if(check_test(phy_on_top[il] * std::exp(-tau_theo[il]),phy_flux[il],"phy at altitude z and lambda"))return_flag = 1; out << lamb[il] << " " << phy_flux[il] << std::endl; } out_the << z << " "; for(unsigned int ir = 0; ir < 3; ir++) { out_the << rate_N2[ir] << " "; } for(unsigned int ir = 0; ir < 9; ir++) { out_the << rate_CH4[ir] << " "; } out_the << std::endl; out << std::endl; ialt++; } out.close(); out_the.close(); return return_flag; }
void CINTOpt_setij(CINTOpt *opt, FINT *ng, FINT *atm, FINT natm, FINT *bas, FINT nbas, double *env) { FINT i, j, ip, jp, io, jo, off; if (opt->prim_offset == NULL) { opt->prim_offset = (FINT *)malloc(sizeof(FINT) * nbas); opt->tot_prim = 0; for (i = 0; i < nbas; i++) { opt->prim_offset[i] = opt->tot_prim; opt->tot_prim += bas(NPRIM_OF, i); } } FINT ijkl_inc; if ((ng[IINC]+ng[JINC]) > (ng[KINC]+ng[LINC])) { ijkl_inc = ng[IINC] + ng[JINC]; } else { ijkl_inc = ng[KINC] + ng[LINC]; } FINT iprim, ictr, jprim, jctr, il, jl; double eij, aij, rr, maxci, maxcj, rirj_g4d; double *ai, *aj, *ri, *rj, *ci, *cj; double *expij, *rij; FINT *cceij; opt->expij = (double **)malloc(sizeof(double *) * opt->tot_prim); opt->rij = (double **)malloc(sizeof(double *) * opt->tot_prim); opt->cceij = (FINT **)malloc(sizeof(FINT *) * opt->tot_prim); for (i = 0; i < nbas; i++) { ri = env + atm(PTR_COORD,bas(ATOM_OF,i)); ai = env + bas(PTR_EXP,i); io = opt->prim_offset[i]; iprim = bas(NPRIM_OF,i); ictr = bas(NCTR_OF,i); ci = env + bas(PTR_COEFF,i); // For derivative/dipole operator, the l-value in g2e is virtually increased il = bas(ANG_OF,i); for (ip = 0; ip < bas(NPRIM_OF,i); ip++) { maxci = max_pgto_coeff(ci, iprim, ictr, ip); maxci = maxci / CINTgto_norm(bas(ANG_OF,i), ai[ip]); expij = (double *)malloc(sizeof(double)*opt->tot_prim); rij = (double *)malloc(sizeof(double)*opt->tot_prim*3); cceij = (FINT *)malloc(sizeof(FINT) * opt->tot_prim); opt->expij[io+ip] = expij; opt->rij[io+ip] = rij; opt->cceij[io+ip] = cceij; for (j = 0; j < nbas; j++) { rj = env + atm(PTR_COORD,bas(ATOM_OF,j)); aj = env + bas(PTR_EXP,j); jo = opt->prim_offset[j]; jprim = bas(NPRIM_OF,j); jctr = bas(NCTR_OF,j); cj = env + bas(PTR_COEFF,j); jl = bas(ANG_OF,j); rr = (ri[0]-rj[0])*(ri[0]-rj[0]) + (ri[1]-rj[1])*(ri[1]-rj[1]) + (ri[2]-rj[2])*(ri[2]-rj[2]); for (jp = 0; jp < bas(NPRIM_OF,j); jp++) { maxcj = max_pgto_coeff(cj, jprim, jctr, jp); maxcj = maxcj / CINTgto_norm(bas(ANG_OF,j), aj[jp]); aij = ai[ip] + aj[jp]; off = jo + jp; eij = rr * ai[ip] * aj[jp] / aij; expij[off] = exp(-eij); rij[off*3+0] = (ai[ip]*ri[0] + aj[jp]*rj[0]) / aij; rij[off*3+1] = (ai[ip]*ri[1] + aj[jp]*rj[1]) / aij; rij[off*3+2] = (ai[ip]*ri[2] + aj[jp]*rj[2]) / aij; if (maxci*maxcj == 0) { cceij[off] = 750; } else if (rr > 1e-12) { /* value estimation based on g0_2e_2d and g0_xx2d_4d, * value/exp(-eij) ~< (il+jl+2)!*(aij/2)^(il+jl)*(ri_or_rj-rij)^(ij+jl)*rirj^max(il,jl) * ~< (il+jl+2)!*(aij/2)^(il+jl)*|rirj|^((il+jl)+max(il,jl)) * But in practice, |rirj|^((il+jl)/2) is large enough to cover all other factors */ rirj_g4d = pow(rr+0.5, (il+jl+ijkl_inc+1)/2); cceij[off] = eij - log(maxci*maxcj*rirj_g4d); } else { /* If basis on the same center, include the (ss|ss)^{1/2} contribution * (ss|ss) = 2\sqrt{aij/pi} */ cceij[off] = -log(maxci*maxcj) - log(aij)/4; } } } } } }
int test() { std::vector<std::string> neutrals; std::vector<std::string> ions; neutrals.push_back("N2"); neutrals.push_back("CH4"); ions.push_back("N2+"); ions.push_back("e"); //photons std::vector<Scalar> lambda,phy1AU; read_hv_flux<Scalar>(lambda,phy1AU,"./input/hv_SSI.dat"); Scalar chi(100.); Planet::Chapman<Scalar> chapman(chi); Planet::PhotonFlux<Scalar,std::vector<Scalar>, std::vector<std::vector<Scalar> > > photon(chapman); photon.set_photon_flux_top_atmosphere(lambda,phy1AU,Planet::Constants::Saturn::d_Sun<Scalar>()); //densities std::vector<Scalar> molar_frac = {0.96,0.04,0.,0.}; Scalar dens_tot(1e12); //diffusion Planet::BinaryDiffusion<Scalar> N2N2( Antioch::Species::N2, Antioch::Species::N2 , 5.09e+16,0.81, Planet::DiffusionType::Massman); Planet::BinaryDiffusion<Scalar> N2CH4( Antioch::Species::N2, Antioch::Species::CH4, 7.34e+16,0.75, Planet::DiffusionType::Massman); Planet::BinaryDiffusion<Scalar> CH4CH4( Antioch::Species::CH4, Antioch::Species::CH4, 5.73e+16,0.50, Planet::DiffusionType::Massman); //atmosphere Planet::Atmosphere<Scalar, std::vector<Scalar>, std::vector<std::vector<Scalar> > > atm(neutrals,ions,photon); atm.make_altitude_grid(600.,1400.,10.); //temperature std::vector<Scalar> T0,Tz; read_temperature<Scalar>(T0,Tz,"input/temperature.dat"); atm.set_temperature(T0,Tz); //cross-section std::vector<Scalar> sigma; read_crossSection<Scalar>(lambda,sigma,"./input/N2_hv_cross-sections.dat",3); atm.add_photoabsorption("N2",lambda,sigma); read_crossSection<Scalar>(lambda,sigma,"./input/CH4_hv_cross-sections.dat",9); atm.add_photoabsorption("N2",lambda,sigma); atm.add_photoabsorption("CH4",lambda,sigma); //init compo atm.init_composition(molar_frac,dens_tot); //diffusion atm.diffusion().set_binary_coefficient(0,0,N2N2); atm.diffusion().set_binary_coefficient(0,1,N2CH4); atm.diffusion().set_binary_coefficient(1,1,CH4CH4); atm.make_diffusion(); //thermal coefficient Scalar K0(4.3e6L); atm.set_K0(K0); atm.make_thermal_coefficient(); //solver Planet::CrankNicholson<Scalar,std::vector<Scalar>, std::vector<std::vector<Scalar> > > solver; int return_flag(0); return return_flag; }
FINT CINTinit_int3c2e_EnvVars(CINTEnvVars *envs, const FINT *ng, const FINT *shls, const FINT *atm, const FINT natm, const FINT *bas, const FINT nbas, const double *env) { envs->natm = natm; envs->nbas = nbas; envs->atm = atm; envs->bas = bas; envs->env = env; envs->shls = shls; const FINT i_sh = shls[0]; const FINT j_sh = shls[1]; const FINT k_sh = shls[2]; envs->i_l = bas(ANG_OF, i_sh); envs->j_l = bas(ANG_OF, j_sh); envs->k_l = bas(ANG_OF, k_sh); envs->i_prim = bas(NPRIM_OF, i_sh); envs->j_prim = bas(NPRIM_OF, j_sh); envs->k_prim = bas(NPRIM_OF, k_sh); envs->i_ctr = bas(NCTR_OF, i_sh); envs->j_ctr = bas(NCTR_OF, j_sh); envs->k_ctr = bas(NCTR_OF, k_sh); envs->nfi = CINTlen_cart(envs->i_l); envs->nfj = CINTlen_cart(envs->j_l); envs->nfk = CINTlen_cart(envs->k_l); envs->nf = envs->nfi * envs->nfk * envs->nfj; envs->ri = env + atm(PTR_COORD, bas(ATOM_OF, i_sh)); envs->rj = env + atm(PTR_COORD, bas(ATOM_OF, j_sh)); envs->rk = env + atm(PTR_COORD, bas(ATOM_OF, k_sh)); envs->common_factor = (M_PI*M_PI*M_PI)*2/SQRTPI * CINTcommon_fac_sp(envs->i_l) * CINTcommon_fac_sp(envs->j_l) * CINTcommon_fac_sp(envs->k_l); envs->gbits = ng[GSHIFT]; envs->ncomp_e1 = ng[POS_E1]; envs->ncomp_tensor = ng[TENSOR]; envs->li_ceil = envs->i_l + ng[IINC]; envs->lj_ceil = envs->j_l + ng[JINC]; envs->lk_ceil = envs->k_l + ng[KINC]; envs->ll_ceil = 0; // to reuse CINTg0_2e_2d envs->nrys_roots =(envs->li_ceil + envs->lj_ceil + envs->lk_ceil)/2 + 1; assert(i_sh < SHLS_MAX); assert(j_sh < SHLS_MAX); assert(k_sh < SHLS_MAX); assert(envs->i_l < ANG_MAX); assert(envs->j_l < ANG_MAX); assert(envs->k_l < ANG_MAX); assert(envs->i_ctr < NCTR_MAX); assert(envs->j_ctr < NCTR_MAX); assert(envs->k_ctr < NCTR_MAX); assert(envs->i_prim < NPRIM_MAX); assert(envs->j_prim < NPRIM_MAX); assert(envs->k_prim < NPRIM_MAX); assert(envs->i_prim >= envs->i_ctr); assert(envs->j_prim >= envs->j_ctr); assert(envs->k_prim >= envs->k_ctr); assert(bas(ATOM_OF,i_sh) >= 0); assert(bas(ATOM_OF,j_sh) >= 0); assert(bas(ATOM_OF,k_sh) >= 0); assert(bas(ATOM_OF,i_sh) < natm); assert(bas(ATOM_OF,j_sh) < natm); assert(bas(ATOM_OF,k_sh) < natm); assert(envs->nrys_roots < MXRYSROOTS); CINTset_g3c2e_params(envs); return 0; }
bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config prefConfig, Mode mode) { #ifdef TIME_DECODE AutoTimeMillis atm("JPEG Decode"); #endif SkAutoMalloc srcStorage; JPEGAutoClean autoClean; jpeg_decompress_struct cinfo; sk_error_mgr sk_err; sk_source_mgr sk_stream(stream); cinfo.err = jpeg_std_error(&sk_err); sk_err.error_exit = sk_error_exit; // All objects need to be instantiated before this setjmp call so that // they will be cleaned up properly if an error occurs. if (setjmp(sk_err.fJmpBuf)) { return false; } jpeg_create_decompress(&cinfo); autoClean.set(&cinfo); //jpeg_stdio_src(&cinfo, file); cinfo.src = &sk_stream; jpeg_read_header(&cinfo, true); /* Try to fulfill the requested sampleSize. Since jpeg can do it (when it can) much faster that we, just use their num/denom api to approximate the size. */ int sampleSize = this->getSampleSize(); cinfo.dct_method = JDCT_IFAST; cinfo.scale_num = 1; cinfo.scale_denom = sampleSize; /* image_width and image_height are the original dimensions, available after jpeg_read_header(). To see the scaled dimensions, we have to call jpeg_start_decompress(), and then read output_width and output_height. */ jpeg_start_decompress(&cinfo); /* If we need to better match the request, we might examine the image and output dimensions, and determine if the downsampling jpeg provided is not sufficient. If so, we can recompute a modified sampleSize value to make up the difference. To skip this additional scaling, just set sampleSize = 1; below. */ sampleSize = sampleSize * cinfo.output_width / cinfo.image_width; // check for supported formats bool isRGB; // as opposed to gray8 if (3 == cinfo.num_components && JCS_RGB == cinfo.out_color_space) { isRGB = true; } else if (1 == cinfo.num_components && JCS_GRAYSCALE == cinfo.out_color_space) { isRGB = false; // could use Index8 config if we want... } else { SkDEBUGF(("SkJPEGImageDecoder: unsupported jpeg colorspace %d with %d components\n", cinfo.jpeg_color_space, cinfo.num_components)); return false; } SkBitmap::Config config = prefConfig; // if no user preference, see what the device recommends if (config == SkBitmap::kNo_Config) config = SkImageDecoder::GetDeviceConfig(); // only these make sense for jpegs if (config != SkBitmap::kARGB_8888_Config && config != SkBitmap::kARGB_4444_Config && config != SkBitmap::kRGB_565_Config) { config = SkBitmap::kARGB_8888_Config; } // should we allow the Chooser (if present) to pick a config for us??? if (!this->chooseFromOneChoice(config, cinfo.output_width, cinfo.output_height)) { return false; } SkScaledBitmapSampler sampler(cinfo.output_width, cinfo.output_height, sampleSize); bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); // jpegs are always opauqe (i.e. have no per-pixel alpha) bm->setIsOpaque(true); if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; } if (!this->allocPixelRef(bm, NULL)) { return false; } SkAutoLockPixels alp(*bm); if (!sampler.begin(bm, isRGB ? SkScaledBitmapSampler::kRGB : SkScaledBitmapSampler::kGray, this->getDitherImage())) { return false; } uint8_t* srcRow = (uint8_t*)srcStorage.alloc(cinfo.output_width * 3); skip_src_rows(&cinfo, srcRow, sampler.srcY0()); for (int y = 0;; y++) { JSAMPLE* rowptr = (JSAMPLE*)srcRow; int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1); SkASSERT(row_count == 1); sampler.next(srcRow); if (bm->height() - 1 == y) { break; } skip_src_rows(&cinfo, srcRow, sampler.srcDY() - 1); } // ??? If I don't do this, I get an error from finish_decompress skip_src_rows(&cinfo, srcRow, cinfo.output_height - cinfo.output_scanline); jpeg_finish_decompress(&cinfo); return true; }
int main() { int natm = 8; int nbas = natm*20; // ATM_SLOTS = 6; BAS_SLOTS = 8; int *atm = malloc(sizeof(int) * natm * ATM_SLOTS); int *bas = malloc(sizeof(int) * nbas * BAS_SLOTS); double *env = malloc(sizeof(double) * 10000); int i, j, ia, n, off; off = PTR_ENV_START; // = 20 atm(CHARGE_OF,0)=6; atm(PTR_COORD,0)=off; env[off+0]= 0.000; env[off+1]= 0.000; env[off+2]= 0.769; off+=3; atm(CHARGE_OF,1)=1; atm(PTR_COORD,1)=off; env[off+0]= 0.000; env[off+1]= 1.014; env[off+2]= 1.174; off+=3; atm(CHARGE_OF,2)=1; atm(PTR_COORD,2)=off; env[off+0]=-0.878; env[off+1]=-0.507; env[off+2]= 1.174; off+=3; atm(CHARGE_OF,3)=1; atm(PTR_COORD,3)=off; env[off+0]= 0.878; env[off+1]=-0.507; env[off+2]= 1.174; off+=3; atm(CHARGE_OF,4)=6; atm(PTR_COORD,4)=off; env[off+0]= 0.000; env[off+1]= 0.000; env[off+2]=-0.769; off+=3; atm(CHARGE_OF,5)=1; atm(PTR_COORD,5)=off; env[off+0]= 0.000; env[off+1]= 1.014; env[off+2]=-1.174; off+=3; atm(CHARGE_OF,6)=1; atm(PTR_COORD,6)=off; env[off+0]=-0.878; env[off+1]=-0.507; env[off+2]=-1.174; off+=3; atm(CHARGE_OF,7)=1; atm(PTR_COORD,7)=off; env[off+0]= 0.878; env[off+1]=-0.507; env[off+2]=-1.174; off+=3; // 6-31G env[off+0 ] = 3047.5249; env[off+6 ] = 0.0018347*CINTgto_norm(0,env[off+0 ]); env[off+1 ] = 457.36951; env[off+7 ] = 0.0140373*CINTgto_norm(0,env[off+1 ]); env[off+2 ] = 103.94869; env[off+8 ] = 0.0688426*CINTgto_norm(0,env[off+2 ]); env[off+3 ] = 29.210155; env[off+9 ] = 0.2321844*CINTgto_norm(0,env[off+3 ]); env[off+4 ] = 9.2866630; env[off+10] = 0.4679413*CINTgto_norm(0,env[off+4 ]); env[off+5 ] = 3.1639270; env[off+11] = 0.3623120*CINTgto_norm(0,env[off+5 ]); env[off+12] = 7.8682724; env[off+15] =-0.1193324*CINTgto_norm(0,env[off+12]); env[off+13] = 1.8812885; env[off+16] =-0.1608542*CINTgto_norm(0,env[off+13]); env[off+14] = 0.5442493; env[off+17] = 1.1434564*CINTgto_norm(0,env[off+14]); env[off+18] = 0.1687144; env[off+19] = 1.0000000*CINTgto_norm(0,env[off+18]); env[off+20] = 7.8682724; env[off+23] = 0.0689991*CINTgto_norm(1,env[off+20]); env[off+21] = 1.8812885; env[off+24] = 0.3164240*CINTgto_norm(1,env[off+21]); env[off+22] = 0.5442493; env[off+25] = 0.7443083*CINTgto_norm(1,env[off+22]); env[off+26] = 0.1687144; env[off+27] = 1.0000000*CINTgto_norm(1,env[off+26]); env[off+28] = 18.731137; env[off+31] = 0.0334946*CINTgto_norm(0,env[off+28]); env[off+29] = 2.8253937; env[off+32] = 0.2347269*CINTgto_norm(0,env[off+29]); env[off+30] = 0.6401217; env[off+33] = 0.8137573*CINTgto_norm(0,env[off+30]); env[off+34] = 0.1612778; env[off+35] = 1.0000000*CINTgto_norm(0,env[off+34]); for (i = 0, ia = 0, n = 0; i < 2; i++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 6; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+0; bas[PTR_COEFF+BAS_SLOTS*n] = off+6; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+12; bas[PTR_COEFF+BAS_SLOTS*n] = off+15; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+18; bas[PTR_COEFF+BAS_SLOTS*n] = off+19; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+20; bas[PTR_COEFF+BAS_SLOTS*n] = off+23; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+26; bas[PTR_COEFF+BAS_SLOTS*n] = off+27; n++; ia++; for (j = 0; j < 3; j++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+28; bas[PTR_COEFF+BAS_SLOTS*n] = off+31; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+34; bas[PTR_COEFF+BAS_SLOTS*n] = off+35; n++; ia++; } } nbas = n; printf("6-31G basis\n"); run_all(atm, natm, bas, nbas, env); // 6-311G** env[off+ 0] = 4563.240; env[off+17] = 0.0019666*CINTgto_norm(0,env[off+ 0]); env[off+ 1] = 682.0240; env[off+18] = 0.0152306*CINTgto_norm(0,env[off+ 1]); env[off+ 2] = 154.9730; env[off+19] = 0.0761269*CINTgto_norm(0,env[off+ 2]); env[off+ 3] = 44.45530; env[off+20] = 0.2608010*CINTgto_norm(0,env[off+ 3]); env[off+ 4] = 13.02900; env[off+21] = 0.6164620*CINTgto_norm(0,env[off+ 4]); env[off+ 5] = 1.827730; env[off+22] = 0.2210060*CINTgto_norm(0,env[off+ 5]); env[off+ 6] = 20.96420; env[off+23] = 0.1146600*CINTgto_norm(0,env[off+ 6]); env[off+ 7] = 4.803310; env[off+24] = 0.9199990*CINTgto_norm(0,env[off+ 7]); env[off+ 8] = 1.459330; env[off+25] = -0.003030*CINTgto_norm(0,env[off+ 8]); env[off+ 9] = 0.483456; env[off+26] = 1.0000000*CINTgto_norm(0,env[off+ 9]); env[off+10] = 0.145585; env[off+27] = 1.0000000*CINTgto_norm(0,env[off+10]); env[off+11] = 20.96420; env[off+28] = 0.0402487*CINTgto_norm(1,env[off+11]); env[off+12] = 4.803310; env[off+29] = 0.2375940*CINTgto_norm(1,env[off+12]); env[off+13] = 1.459330; env[off+30] = 0.8158540*CINTgto_norm(1,env[off+13]); env[off+14] = 0.483456; env[off+31] = 1.0000000*CINTgto_norm(1,env[off+14]); env[off+15] = 0.145585; env[off+32] = 1.0000000*CINTgto_norm(1,env[off+15]); env[off+16] = 0.626000; env[off+33] = 1.0000000*CINTgto_norm(2,env[off+16]); env[off+34] = 33.86500; env[off+40] = 0.0254938*CINTgto_norm(0,env[off+34]); env[off+35] = 5.094790; env[off+41] = 0.1903730*CINTgto_norm(0,env[off+35]); env[off+36] = 1.158790; env[off+42] = 0.8521610*CINTgto_norm(0,env[off+36]); env[off+37] = 0.325840; env[off+43] = 1.0000000*CINTgto_norm(0,env[off+37]); env[off+38] = 0.102741; env[off+44] = 1.0000000*CINTgto_norm(0,env[off+38]); env[off+39] = 0.750000; env[off+45] = 1.0000000*CINTgto_norm(0,env[off+39]); for (i = 0, ia = 0, n = 0; i < 2; i++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 6; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 0; bas[PTR_COEFF+BAS_SLOTS*n] = off+17; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 6; bas[PTR_COEFF+BAS_SLOTS*n] = off+23; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 9; bas[PTR_COEFF+BAS_SLOTS*n] = off+26; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+10; bas[PTR_COEFF+BAS_SLOTS*n] = off+27; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+11; bas[PTR_COEFF+BAS_SLOTS*n] = off+28; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+14; bas[PTR_COEFF+BAS_SLOTS*n] = off+31; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+15; bas[PTR_COEFF+BAS_SLOTS*n] = off+32; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+16; bas[PTR_COEFF+BAS_SLOTS*n] = off+33; n++; ia++; for (j = 0; j < 3; j++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+34; bas[PTR_COEFF+BAS_SLOTS*n] = off+40; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+37; bas[PTR_COEFF+BAS_SLOTS*n] = off+43; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+38; bas[PTR_COEFF+BAS_SLOTS*n] = off+44; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+39; bas[PTR_COEFF+BAS_SLOTS*n] = off+45; n++; ia++; } } nbas = n; printf("6-311G(dp) basis\n"); run_all(atm, natm, bas, nbas, env); // cc-pVDZ, C env[off+ 0] = 6665.0; env[off+ 8]=0.000692*CINTgto_norm(0,env[off+ 0]); env[off+16]=-0.000146*CINTgto_norm(0,env[off+0]); env[off+ 1] = 1000.0; env[off+ 9]=0.005329*CINTgto_norm(0,env[off+ 1]); env[off+17]=-0.001154*CINTgto_norm(0,env[off+1]); env[off+ 2] = 228.00; env[off+10]=0.027077*CINTgto_norm(0,env[off+ 2]); env[off+18]=-0.005725*CINTgto_norm(0,env[off+2]); env[off+ 3] = 64.710; env[off+11]=0.101718*CINTgto_norm(0,env[off+ 3]); env[off+19]=-0.023312*CINTgto_norm(0,env[off+3]); env[off+ 4] = 21.060; env[off+12]=0.274740*CINTgto_norm(0,env[off+ 4]); env[off+20]=-0.063955*CINTgto_norm(0,env[off+4]); env[off+ 5] = 7.4950; env[off+13]=0.448564*CINTgto_norm(0,env[off+ 5]); env[off+21]=-0.149981*CINTgto_norm(0,env[off+5]); env[off+ 6] = 2.7970; env[off+14]=0.285074*CINTgto_norm(0,env[off+ 6]); env[off+22]=-0.127262*CINTgto_norm(0,env[off+6]); env[off+ 7] = 0.5215; env[off+15]=0.015204*CINTgto_norm(0,env[off+ 7]); env[off+23]= 0.544529*CINTgto_norm(0,env[off+7]); env[off+24] = 0.1596; env[off+25]=1.000000*CINTgto_norm(0,env[off+24]); env[off+26] = 9.4390; env[off+29]=0.038109*CINTgto_norm(1,env[off+26]); env[off+27] = 2.0020; env[off+30]=0.209480*CINTgto_norm(1,env[off+27]); env[off+28] = 0.5456; env[off+31]=0.508557*CINTgto_norm(1,env[off+28]); env[off+32] = 0.1517; env[off+33]=1.000000*CINTgto_norm(1,env[off+32]); env[off+34] = 0.55 ; env[off+35]=1.000000*CINTgto_norm(2,env[off+34]); // H env[off+36] = 13.010; env[off+39]=0.019685*CINTgto_norm(0,env[off+36]); env[off+37] = 1.9620; env[off+40]=0.137977*CINTgto_norm(0,env[off+37]); env[off+38] = 0.4446; env[off+41]=0.478148*CINTgto_norm(0,env[off+38]); env[off+42] = 0.1220; env[off+43]=1 *CINTgto_norm(0,env[off+42]); env[off+44] = 0.7270; env[off+45]=1 *CINTgto_norm(0,env[off+44]); for (i = 0, ia = 0, n = 0; i < 2; i++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 8; bas[NCTR_OF +BAS_SLOTS*n] = 2; bas[PTR_EXP +BAS_SLOTS*n] = off+0; bas[PTR_COEFF+BAS_SLOTS*n] = off+8; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+24; bas[PTR_COEFF+BAS_SLOTS*n] = off+25; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+26; bas[PTR_COEFF+BAS_SLOTS*n] = off+29; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+32; bas[PTR_COEFF+BAS_SLOTS*n] = off+33; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+34; bas[PTR_COEFF+BAS_SLOTS*n] = off+35; n++; ia++; for (j = 0; j < 3; j++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+36; bas[PTR_COEFF+BAS_SLOTS*n] = off+39; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+42; bas[PTR_COEFF+BAS_SLOTS*n] = off+43; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+44; bas[PTR_COEFF+BAS_SLOTS*n] = off+45; n++; ia++; } } nbas = n; printf("cc-pVDZ basis\n"); run_all(atm, natm, bas, nbas, env); // cc-pVTZ env[off+ 0] = 8236.0; env[off+18]= 0.000531*CINTgto_norm(0,env[off+ 0]); env[off+26]=-0.000113*CINTgto_norm(0,env[off+ 0]); env[off+ 1] = 1235.0; env[off+19]= 0.004108*CINTgto_norm(0,env[off+ 1]); env[off+27]=-0.000878*CINTgto_norm(0,env[off+ 1]); env[off+ 2] = 280.80; env[off+20]= 0.021087*CINTgto_norm(0,env[off+ 2]); env[off+28]=-0.004540*CINTgto_norm(0,env[off+ 2]); env[off+ 3] = 79.270; env[off+21]= 0.081853*CINTgto_norm(0,env[off+ 3]); env[off+29]=-0.018133*CINTgto_norm(0,env[off+ 3]); env[off+ 4] = 25.590; env[off+22]= 0.234817*CINTgto_norm(0,env[off+ 4]); env[off+30]=-0.055760*CINTgto_norm(0,env[off+ 4]); env[off+ 5] = 8.9970; env[off+23]= 0.434401*CINTgto_norm(0,env[off+ 5]); env[off+31]=-0.126895*CINTgto_norm(0,env[off+ 5]); env[off+ 6] = 3.3190; env[off+24]= 0.346129*CINTgto_norm(0,env[off+ 6]); env[off+32]=-0.170352*CINTgto_norm(0,env[off+ 6]); env[off+ 7] = 0.3643; env[off+25]=-0.008983*CINTgto_norm(0,env[off+ 7]); env[off+33]= 0.598684*CINTgto_norm(0,env[off+ 7]); env[off+ 8] = 0.9059; env[off+34]= 1.000000*CINTgto_norm(0,env[off+ 8]); env[off+ 9] = 0.1285; env[off+35]= 1.000000*CINTgto_norm(0,env[off+ 9]); env[off+10] = 18.710; env[off+36]= 0.014031*CINTgto_norm(1,env[off+10]); env[off+11] = 4.1330; env[off+37]= 0.086866*CINTgto_norm(1,env[off+11]); env[off+12] = 1.2000; env[off+38]= 0.290216*CINTgto_norm(1,env[off+12]); env[off+13] = 0.3827; env[off+39]= 1.000000*CINTgto_norm(1,env[off+13]); env[off+14] = 0.1209; env[off+40]= 1.000000*CINTgto_norm(1,env[off+14]); env[off+15] = 1.0970; env[off+41]= 1.000000*CINTgto_norm(2,env[off+15]); env[off+16] = 0.3180; env[off+42]= 1.000000*CINTgto_norm(2,env[off+16]); env[off+17] = 0.7610; env[off+43]= 1.000000*CINTgto_norm(3,env[off+17]); env[off+44] = 33.870; env[off+52]= 0.006068*CINTgto_norm(0,env[off+44]); env[off+45] = 5.0950; env[off+53]= 0.045308*CINTgto_norm(0,env[off+45]); env[off+46] = 1.1590; env[off+54]= 0.202822*CINTgto_norm(0,env[off+46]); env[off+47] = 0.3258; env[off+55]= 1.000000*CINTgto_norm(0,env[off+47]); env[off+48] = 0.1027; env[off+56]= 1.000000*CINTgto_norm(0,env[off+48]); env[off+49] = 1.4070; env[off+57]= 1.000000*CINTgto_norm(1,env[off+49]); env[off+50] = 0.3880; env[off+58]= 1.000000*CINTgto_norm(1,env[off+50]); env[off+51] = 1.0570; env[off+59]= 1.000000*CINTgto_norm(2,env[off+51]); for (i = 0, ia = 0, n = 0; i < 2; i++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 8; bas[NCTR_OF +BAS_SLOTS*n] = 2; bas[PTR_EXP +BAS_SLOTS*n] = off+ 0; bas[PTR_COEFF+BAS_SLOTS*n] = off+18; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 8; bas[PTR_COEFF+BAS_SLOTS*n] = off+34; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 9; bas[PTR_COEFF+BAS_SLOTS*n] = off+35; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+10; bas[PTR_COEFF+BAS_SLOTS*n] = off+38; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+13; bas[PTR_COEFF+BAS_SLOTS*n] = off+39; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+14; bas[PTR_COEFF+BAS_SLOTS*n] = off+40; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+15; bas[PTR_COEFF+BAS_SLOTS*n] = off+41; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+16; bas[PTR_COEFF+BAS_SLOTS*n] = off+42; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 3; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+17; bas[PTR_COEFF+BAS_SLOTS*n] = off+43; n++; ia++; for (j = 0; j < 3; j++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+44; bas[PTR_COEFF+BAS_SLOTS*n] = off+52; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+47; bas[PTR_COEFF+BAS_SLOTS*n] = off+55; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+48; bas[PTR_COEFF+BAS_SLOTS*n] = off+56; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+49; bas[PTR_COEFF+BAS_SLOTS*n] = off+57; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+50; bas[PTR_COEFF+BAS_SLOTS*n] = off+58; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+51; bas[PTR_COEFF+BAS_SLOTS*n] = off+59; n++; ia++; } } nbas = n; printf("cc-pVTZ basis\n"); run_all(atm, natm, bas, nbas, env); env[off+ 0] = 33980.; env[off+24]= 0.000091*CINTgto_norm(0,env[off+ 0]); env[off+33]= -0.000019*CINTgto_norm(0,env[off+0]); env[off+ 1] = 5089.0; env[off+25]= 0.000704*CINTgto_norm(0,env[off+ 1]); env[off+34]= -0.000151*CINTgto_norm(0,env[off+1]); env[off+ 2] = 1157.0; env[off+26]= 0.003693*CINTgto_norm(0,env[off+ 2]); env[off+35]= -0.000785*CINTgto_norm(0,env[off+2]); env[off+ 3] = 326.60; env[off+27]= 0.015360*CINTgto_norm(0,env[off+ 3]); env[off+36]= -0.003324*CINTgto_norm(0,env[off+3]); env[off+ 4] = 106.10; env[off+28]= 0.052929*CINTgto_norm(0,env[off+ 4]); env[off+37]= -0.011512*CINTgto_norm(0,env[off+4]); env[off+ 5] = 38.110; env[off+29]= 0.147043*CINTgto_norm(0,env[off+ 5]); env[off+38]= -0.034160*CINTgto_norm(0,env[off+5]); env[off+ 6] = 14.750; env[off+30]= 0.305631*CINTgto_norm(0,env[off+ 6]); env[off+39]= -0.077173*CINTgto_norm(0,env[off+6]); env[off+ 7] = 6.0350; env[off+31]= 0.399345*CINTgto_norm(0,env[off+ 7]); env[off+40]= -0.141493*CINTgto_norm(0,env[off+7]); env[off+ 8] = 2.5300; env[off+32]= 0.217051*CINTgto_norm(0,env[off+ 8]); env[off+41]= -0.118019*CINTgto_norm(0,env[off+8]); env[off+ 9] = 0.7355; env[off+42]= 1.000000*CINTgto_norm(0,env[off+ 9]); env[off+10] = 0.2905; env[off+43]= 1.000000*CINTgto_norm(0,env[off+10]); env[off+11] = 0.1111; env[off+44]= 1.000000*CINTgto_norm(0,env[off+11]); env[off+12] = 34.510; env[off+45]= 0.005378*CINTgto_norm(1,env[off+12]); env[off+13] = 7.9150; env[off+46]= 0.036132*CINTgto_norm(1,env[off+13]); env[off+14] = 2.3680; env[off+47]= 0.142493*CINTgto_norm(1,env[off+14]); env[off+15] = 0.8132; env[off+48]= 1.000000*CINTgto_norm(1,env[off+15]); env[off+16] = 0.2890; env[off+49]= 1.000000*CINTgto_norm(1,env[off+16]); env[off+17] = 0.1007; env[off+50]= 1.000000*CINTgto_norm(1,env[off+17]); env[off+18] = 1.8480; env[off+51]= 1.000000*CINTgto_norm(2,env[off+18]); env[off+19] = 0.6490; env[off+52]= 1.000000*CINTgto_norm(2,env[off+19]); env[off+20] = 0.2280; env[off+53]= 1.000000*CINTgto_norm(2,env[off+20]); env[off+21] = 1.4190; env[off+54]= 1.000000*CINTgto_norm(3,env[off+21]); env[off+22] = 0.4850; env[off+55]= 1.000000*CINTgto_norm(3,env[off+22]); env[off+23] = 1.0110; env[off+56]= 1.000000*CINTgto_norm(4,env[off+23]); env[off+57] = 82.64; env[off+69] = 0.002006*CINTgto_norm(0,env[off+57]); env[off+58] = 12.41; env[off+70] = 0.015343*CINTgto_norm(0,env[off+58]); env[off+59] = 2.824; env[off+71] = 0.075579*CINTgto_norm(0,env[off+59]); env[off+60] = 0.797; env[off+72] = 1.000000*CINTgto_norm(0,env[off+60]); env[off+61] = 0.258; env[off+73] = 1.000000*CINTgto_norm(0,env[off+61]); env[off+62] = 0.089; env[off+74] = 1.000000*CINTgto_norm(0,env[off+62]); env[off+63] = 2.292; env[off+75] = 1.000000*CINTgto_norm(1,env[off+63]); env[off+64] = 0.838; env[off+76] = 1.000000*CINTgto_norm(1,env[off+64]); env[off+65] = 0.292; env[off+77] = 1.000000*CINTgto_norm(1,env[off+65]); env[off+66] = 2.062; env[off+78] = 1.000000*CINTgto_norm(2,env[off+66]); env[off+67] = 0.662; env[off+79] = 1.000000*CINTgto_norm(2,env[off+67]); env[off+68] = 1.397; env[off+80] = 1.000000*CINTgto_norm(3,env[off+68]); for (i = 0, ia = 0, n = 0; i < 2; i++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 8; bas[NCTR_OF +BAS_SLOTS*n] = 2; bas[PTR_EXP +BAS_SLOTS*n] = off+ 0; bas[PTR_COEFF+BAS_SLOTS*n] = off+24; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+ 9; bas[PTR_COEFF+BAS_SLOTS*n] = off+42; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+10; bas[PTR_COEFF+BAS_SLOTS*n] = off+43; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+11; bas[PTR_COEFF+BAS_SLOTS*n] = off+44; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+12; bas[PTR_COEFF+BAS_SLOTS*n] = off+45; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+15; bas[PTR_COEFF+BAS_SLOTS*n] = off+48; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+16; bas[PTR_COEFF+BAS_SLOTS*n] = off+49; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+17; bas[PTR_COEFF+BAS_SLOTS*n] = off+50; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+18; bas[PTR_COEFF+BAS_SLOTS*n] = off+51; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+19; bas[PTR_COEFF+BAS_SLOTS*n] = off+52; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+20; bas[PTR_COEFF+BAS_SLOTS*n] = off+53; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 3; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+21; bas[PTR_COEFF+BAS_SLOTS*n] = off+54; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 3; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+22; bas[PTR_COEFF+BAS_SLOTS*n] = off+55; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 4; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+23; bas[PTR_COEFF+BAS_SLOTS*n] = off+56; n++; ia++; for (j = 0; j < 3; j++) { bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+57; bas[PTR_COEFF+BAS_SLOTS*n] = off+69; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+60; bas[PTR_COEFF+BAS_SLOTS*n] = off+72; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+61; bas[PTR_COEFF+BAS_SLOTS*n] = off+73; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+62; bas[PTR_COEFF+BAS_SLOTS*n] = off+74; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+63; bas[PTR_COEFF+BAS_SLOTS*n] = off+75; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+64; bas[PTR_COEFF+BAS_SLOTS*n] = off+76; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+65; bas[PTR_COEFF+BAS_SLOTS*n] = off+77; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+66; bas[PTR_COEFF+BAS_SLOTS*n] = off+78; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+67; bas[PTR_COEFF+BAS_SLOTS*n] = off+79; n++; bas[ATOM_OF +BAS_SLOTS*n] = ia; bas[ANG_OF +BAS_SLOTS*n] = 3; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+68; bas[PTR_COEFF+BAS_SLOTS*n] = off+80; n++; ia++; } } nbas = n; printf("cc-pVQZ basis\n"); run_all(atm, natm, bas, nbas, env); free(atm); free(bas); free(env); }
/* * 1e GTO integral basic loop for < i|1/r|j>, no 1/r * if nuc_id >= 0: nuclear attraction, use nuclear model * if nuc_id < 0: 1/r potential, do not use nuclear model */ FINT CINT1e_nuc_loop(double *gctr, CINTEnvVars *envs, double fac, FINT nuc_id) { const FINT *shls = envs->shls; const FINT *atm = envs->atm; const FINT *bas = envs->bas; const double *env = envs->env; const FINT i_sh = shls[0]; const FINT j_sh = shls[1]; const FINT i_l = envs->i_l; const FINT j_l = envs->j_l; const FINT i_ctr = envs->i_ctr; const FINT j_ctr = envs->j_ctr; const FINT nfi = envs->nfi; const FINT nfj = envs->nfj; const FINT nf = envs->nf; const FINT n_comp = envs->ncomp_e1 * envs->ncomp_tensor; const double *ri = envs->ri; const double *rj = envs->rj; const double *ai = env + bas(PTR_EXP, i_sh); const double *aj = env + bas(PTR_EXP, j_sh); const double *ci = env + bas(PTR_COEFF, i_sh); const double *cj = env + bas(PTR_COEFF, j_sh); FINT ip, jp, i, n; FINT has_value = 0; double tau; const double *cr; double (*f_nuc_mod)(); double x, u[MXRYSROOTS], w[MXRYSROOTS]; FINT *const idx = malloc(sizeof(FINT) * nf * 3); double rij[3], aij, dij, eij, rrij, t2; double *g = malloc(sizeof(double) * envs->g_size * 3 * ((1<<envs->gbits)+1)); // +1 as buffer double *const gout = malloc(sizeof(double) * nf * n_comp); double *const gctri = malloc(sizeof(double) * nf * i_ctr * n_comp); if (nuc_id < 0) { cr = &env[PTR_RINV_ORIG]; f_nuc_mod = CINTno_nuc_mod; } else { cr = &env[atm(PTR_COORD, nuc_id)], f_nuc_mod = CINTnuc_mod; } CINTg1e_index_xyz(idx, envs); rrij = CINTsquare_dist(ri, rj); fac *= 2 * M_PI * CINTcommon_fac_sp(i_l) * CINTcommon_fac_sp(j_l); for (jp = 0; jp < envs->j_prim; jp++) { envs->aj = aj[jp]; n = nf * i_ctr * n_comp; CINTdset0(n, gctri); for (ip = 0; ip < envs->i_prim; ip++) { envs->ai = ai[ip]; aij = ai[ip] + aj[jp]; eij = (ai[ip] * aj[jp] / aij) * rrij; if (eij > EXPCUTOFF) continue; has_value = 1; rij[0] = (ai[ip] * ri[0] + aj[jp] * rj[0]) / aij; rij[1] = (ai[ip] * ri[1] + aj[jp] * rj[1]) / aij; rij[2] = (ai[ip] * ri[2] + aj[jp] * rj[2]) / aij; tau = (*f_nuc_mod)(aij, nuc_id, atm, env); x = aij * CINTsquare_dist(rij, cr) * tau * tau; CINTrys_roots(envs->nrys_roots, x, u, w); dij = exp(-eij) / aij * fac; CINTdset0(nf * n_comp, gout); for (i = 0; i < envs->nrys_roots; i++) { t2 = u[i] / (1 + u[i]) * tau * tau; CINTg_nuc(g, aij, rij, cr, t2, dij * w[i] * tau, envs); (*envs->f_gout)(g, gout, idx, envs); } n = nf * n_comp; CINTprim_to_ctr(gctri, n, gout, 1, envs->i_prim, i_ctr, ci+ip); } n = nf * i_ctr; CINTprim_to_ctr(gctr, n, gctri, n_comp, envs->j_prim, j_ctr, cj+jp); } free(g); free(idx); free(gout); free(gctri); return has_value; }
bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { #ifdef TIME_DECODE AutoTimeMillis atm("JPEG Decode"); #endif SkAutoMalloc srcStorage; JPEGAutoClean autoClean; jpeg_decompress_struct cinfo; skjpeg_error_mgr sk_err; skjpeg_source_mgr sk_stream(stream, this, false); cinfo.err = jpeg_std_error(&sk_err); sk_err.error_exit = skjpeg_error_exit; // All objects need to be instantiated before this setjmp call so that // they will be cleaned up properly if an error occurs. if (setjmp(sk_err.fJmpBuf)) { return return_false(cinfo, *bm, "setjmp"); } jpeg_create_decompress(&cinfo); autoClean.set(&cinfo); #ifdef SK_BUILD_FOR_ANDROID overwrite_mem_buffer_size(&cinfo); #endif //jpeg_stdio_src(&cinfo, file); cinfo.src = &sk_stream; int status = jpeg_read_header(&cinfo, true); if (status != JPEG_HEADER_OK) { return return_false(cinfo, *bm, "read_header"); } /* Try to fulfill the requested sampleSize. Since jpeg can do it (when it can) much faster that we, just use their num/denom api to approximate the size. */ int sampleSize = this->getSampleSize(); if (this->getPreferQualityOverSpeed()) { cinfo.dct_method = JDCT_ISLOW; } else { cinfo.dct_method = JDCT_IFAST; } cinfo.scale_num = 1; cinfo.scale_denom = sampleSize; /* this gives about 30% performance improvement. In theory it may reduce the visual quality, in practice I'm not seeing a difference */ cinfo.do_fancy_upsampling = 0; /* this gives another few percents */ cinfo.do_block_smoothing = 0; /* default format is RGB */ cinfo.out_color_space = JCS_RGB; SkBitmap::Config config = this->getPrefConfig(k32Bit_SrcDepth, false); // only these make sense for jpegs if (config != SkBitmap::kARGB_8888_Config && config != SkBitmap::kARGB_4444_Config && config != SkBitmap::kRGB_565_Config) { config = SkBitmap::kARGB_8888_Config; } #ifdef ANDROID_RGB cinfo.dither_mode = JDITHER_NONE; if (config == SkBitmap::kARGB_8888_Config) { cinfo.out_color_space = JCS_RGBA_8888; } else if (config == SkBitmap::kRGB_565_Config) { cinfo.out_color_space = JCS_RGB_565; if (this->getDitherImage()) { cinfo.dither_mode = JDITHER_ORDERED; } } #endif if (sampleSize == 1 && mode == SkImageDecoder::kDecodeBounds_Mode) { bm->setConfig(config, cinfo.image_width, cinfo.image_height); bm->setIsOpaque(true); return true; } /* image_width and image_height are the original dimensions, available after jpeg_read_header(). To see the scaled dimensions, we have to call jpeg_start_decompress(), and then read output_width and output_height. */ if (!jpeg_start_decompress(&cinfo)) { /* If we failed here, we may still have enough information to return to the caller if they just wanted (subsampled bounds). If sampleSize was 1, then we would have already returned. Thus we just check if we're in kDecodeBounds_Mode, and that we have valid output sizes. One reason to fail here is that we have insufficient stream data to complete the setup. However, output dimensions seem to get computed very early, which is why this special check can pay off. */ if (SkImageDecoder::kDecodeBounds_Mode == mode && valid_output_dimensions(cinfo)) { SkScaledBitmapSampler smpl(cinfo.output_width, cinfo.output_height, recompute_sampleSize(sampleSize, cinfo)); bm->setConfig(config, smpl.scaledWidth(), smpl.scaledHeight()); bm->setIsOpaque(true); return true; } else { return return_false(cinfo, *bm, "start_decompress"); } } sampleSize = recompute_sampleSize(sampleSize, cinfo); // should we allow the Chooser (if present) to pick a config for us??? if (!this->chooseFromOneChoice(config, cinfo.output_width, cinfo.output_height)) { return return_false(cinfo, *bm, "chooseFromOneChoice"); } #ifdef ANDROID_RGB /* short-circuit the SkScaledBitmapSampler when possible, as this gives a significant performance boost. */ if (sampleSize == 1 && ((config == SkBitmap::kARGB_8888_Config && cinfo.out_color_space == JCS_RGBA_8888) || (config == SkBitmap::kRGB_565_Config && cinfo.out_color_space == JCS_RGB_565))) { bm->lockPixels(); JSAMPLE* rowptr = (JSAMPLE*)bm->getPixels(); bm->unlockPixels(); bool reuseBitmap = (rowptr != NULL); if (reuseBitmap && ((int) cinfo.output_width != bm->width() || (int) cinfo.output_height != bm->height())) { // Dimensions must match return false; } if (!reuseBitmap) { bm->setConfig(config, cinfo.output_width, cinfo.output_height); bm->setIsOpaque(true); if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; } if (!this->allocPixelRef(bm, NULL)) { return return_false(cinfo, *bm, "allocPixelRef"); } } else if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; } SkAutoLockPixels alp(*bm); rowptr = (JSAMPLE*)bm->getPixels(); INT32 const bpr = bm->rowBytes(); while (cinfo.output_scanline < cinfo.output_height) { int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1); // if row_count == 0, then we didn't get a scanline, so abort. // if we supported partial images, we might return true in this case if (0 == row_count) { return return_false(cinfo, *bm, "read_scanlines"); } if (this->shouldCancelDecode()) { return return_false(cinfo, *bm, "shouldCancelDecode"); } rowptr += bpr; } if (reuseBitmap) { bm->notifyPixelsChanged(); } jpeg_finish_decompress(&cinfo); return true; } #endif // check for supported formats SkScaledBitmapSampler::SrcConfig sc; if (3 == cinfo.out_color_components && JCS_RGB == cinfo.out_color_space) { sc = SkScaledBitmapSampler::kRGB; #ifdef ANDROID_RGB } else if (JCS_RGBA_8888 == cinfo.out_color_space) { sc = SkScaledBitmapSampler::kRGBX; } else if (JCS_RGB_565 == cinfo.out_color_space) { sc = SkScaledBitmapSampler::kRGB_565; #endif } else if (1 == cinfo.out_color_components && JCS_GRAYSCALE == cinfo.out_color_space) { sc = SkScaledBitmapSampler::kGray; } else { return return_false(cinfo, *bm, "jpeg colorspace"); } SkScaledBitmapSampler sampler(cinfo.output_width, cinfo.output_height, sampleSize); bm->lockPixels(); JSAMPLE* rowptr = (JSAMPLE*)bm->getPixels(); bool reuseBitmap = (rowptr != NULL); bm->unlockPixels(); if (reuseBitmap && (sampler.scaledWidth() != bm->width() || sampler.scaledHeight() != bm->height())) { // Dimensions must match return false; } if (!reuseBitmap) { bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight()); // jpegs are always opaque (i.e. have no per-pixel alpha) bm->setIsOpaque(true); if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; } if (!this->allocPixelRef(bm, NULL)) { return return_false(cinfo, *bm, "allocPixelRef"); } } else if (SkImageDecoder::kDecodeBounds_Mode == mode) { return true; } SkAutoLockPixels alp(*bm); if (!sampler.begin(bm, sc, this->getDitherImage())) { return return_false(cinfo, *bm, "sampler.begin"); } uint8_t* srcRow = (uint8_t*)srcStorage.reset(cinfo.output_width * 4); // Possibly skip initial rows [sampler.srcY0] if (!skip_src_rows(&cinfo, srcRow, sampler.srcY0())) { return return_false(cinfo, *bm, "skip rows"); } // now loop through scanlines until y == bm->height() - 1 for (int y = 0;; y++) { JSAMPLE* rowptr = (JSAMPLE*)srcRow; int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1); if (0 == row_count) { return return_false(cinfo, *bm, "read_scanlines"); } if (this->shouldCancelDecode()) { return return_false(cinfo, *bm, "shouldCancelDecode"); } sampler.next(srcRow); if (bm->height() - 1 == y) { // we're done break; } if (!skip_src_rows(&cinfo, srcRow, sampler.srcDY() - 1)) { return return_false(cinfo, *bm, "skip rows"); } } // we formally skip the rest, so we don't get a complaint from libjpeg if (!skip_src_rows(&cinfo, srcRow, cinfo.output_height - cinfo.output_scanline)) { return return_false(cinfo, *bm, "skip rows"); } if (reuseBitmap) { bm->notifyPixelsChanged(); } jpeg_finish_decompress(&cinfo); // SkDebugf("------------------- bm2 size %d [%d %d] %d\n", bm->getSize(), bm->width(), bm->height(), bm->config()); return true; }
int main() { int natm = 60; int nbas = natm*20; // ATM_SLOTS = 6; BAS_SLOTS = 8; int *atm = malloc(sizeof(int) * natm * ATM_SLOTS); int *bas = malloc(sizeof(int) * nbas * BAS_SLOTS); double *env = malloc(sizeof(double) * 10000); int i, n, off; off = PTR_ENV_START; // = 20 atm(CHARGE_OF, 0)=6; atm(PTR_COORD, 0)=off; env[off+0]=-0.779; env[off+1]= 0.757; env[off+2]= 0.000; off+=3; atm(CHARGE_OF, 1)=6; atm(PTR_COORD, 1)=off; env[off+0]= 0.684; env[off+1]= 0.757; env[off+2]= 0.000; off+=3; atm(CHARGE_OF, 2)=6; atm(PTR_COORD, 2)=off; env[off+0]= 1.376; env[off+1]= 1.956; env[off+2]= 0.000; off+=3; atm(CHARGE_OF, 3)=6; atm(PTR_COORD, 3)=off; env[off+0]= 0.644; env[off+1]= 3.224; env[off+2]=-0.000; off+=3; atm(CHARGE_OF, 4)=6; atm(PTR_COORD, 4)=off; env[off+0]=-0.739; env[off+1]= 3.224; env[off+2]= 0.000; off+=3; atm(CHARGE_OF, 5)=6; atm(PTR_COORD, 5)=off; env[off+0]=-1.471; env[off+1]= 1.956; env[off+2]= 0.000; off+=3; atm(CHARGE_OF, 6)=6; atm(PTR_COORD, 6)=off; env[off+0]=-1.231; env[off+1]=-0.348; env[off+2]=-0.845; off+=3; atm(CHARGE_OF, 7)=6; atm(PTR_COORD, 7)=off; env[off+0]=-0.047; env[off+1]=-1.032; env[off+2]=-1.367; off+=3; atm(CHARGE_OF, 8)=6; atm(PTR_COORD, 8)=off; env[off+0]= 1.137; env[off+1]=-0.348; env[off+2]=-0.845; off+=3; atm(CHARGE_OF, 9)=6; atm(PTR_COORD, 9)=off; env[off+0]= 2.257; env[off+1]=-0.196; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,10)=6; atm(PTR_COORD,10)=off; env[off+0]= 2.561; env[off+1]= 2.118; env[off+2]=-0.845; off+=3; atm(CHARGE_OF,11)=6; atm(PTR_COORD,11)=off; env[off+0]= 1.376; env[off+1]= 4.169; env[off+2]=-0.845; off+=3; atm(CHARGE_OF,12)=6; atm(PTR_COORD,12)=off; env[off+0]= 0.684; env[off+1]= 5.063; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,13)=6; atm(PTR_COORD,13)=off; env[off+0]=-0.779; env[off+1]= 5.063; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,14)=6; atm(PTR_COORD,14)=off; env[off+0]=-1.471; env[off+1]= 4.169; env[off+2]=-0.845; off+=3; atm(CHARGE_OF,15)=6; atm(PTR_COORD,15)=off; env[off+0]=-2.656; env[off+1]= 3.485; env[off+2]=-1.367; off+=3; atm(CHARGE_OF,16)=6; atm(PTR_COORD,16)=off; env[off+0]=-2.655; env[off+1]= 2.118; env[off+2]=-0.845; off+=3; atm(CHARGE_OF,17)=6; atm(PTR_COORD,17)=off; env[off+0]=-3.083; env[off+1]= 1.071; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,18)=6; atm(PTR_COORD,18)=off; env[off+0]=-2.351; env[off+1]=-0.196; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,19)=6; atm(PTR_COORD,19)=off; env[off+0]=-0.047; env[off+1]=-1.526; env[off+2]=-2.661; off+=3; atm(CHARGE_OF,20)=6; atm(PTR_COORD,20)=off; env[off+0]=-1.231; env[off+1]=-1.365; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,21)=6; atm(PTR_COORD,21)=off; env[off+0]=-2.351; env[off+1]=-0.718; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,22)=6; atm(PTR_COORD,22)=off; env[off+0]=-3.083; env[off+1]= 0.226; env[off+2]=-3.857; off+=3; atm(CHARGE_OF,23)=6; atm(PTR_COORD,23)=off; env[off+0]=-3.536; env[off+1]= 1.332; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,24)=6; atm(PTR_COORD,24)=off; env[off+0]=-3.536; env[off+1]= 2.626; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,25)=6; atm(PTR_COORD,25)=off; env[off+0]=-3.083; env[off+1]= 3.732; env[off+2]=-2.660; off+=3; atm(CHARGE_OF,26)=6; atm(PTR_COORD,26)=off; env[off+0]=-2.352; env[off+1]= 4.677; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,27)=6; atm(PTR_COORD,27)=off; env[off+0]=-1.231; env[off+1]= 5.324; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,28)=6; atm(PTR_COORD,28)=off; env[off+0]= 2.561; env[off+1]= 3.485; env[off+2]=-1.367; off+=3; atm(CHARGE_OF,29)=6; atm(PTR_COORD,29)=off; env[off+0]= 1.136; env[off+1]= 4.307; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,30)=6; atm(PTR_COORD,30)=off; env[off+0]= 2.256; env[off+1]= 4.155; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,31)=6; atm(PTR_COORD,31)=off; env[off+0]= 2.988; env[off+1]= 2.887; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,32)=6; atm(PTR_COORD,32)=off; env[off+0]= 2.561; env[off+1]= 1.841; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,33)=6; atm(PTR_COORD,33)=off; env[off+0]= 1.376; env[off+1]= 2.002; env[off+2]=-6.518; off+=3; atm(CHARGE_OF,34)=6; atm(PTR_COORD,34)=off; env[off+0]=-0.779; env[off+1]= 3.201; env[off+2]=-6.518; off+=3; atm(CHARGE_OF,35)=6; atm(PTR_COORD,35)=off; env[off+0]=-1.231; env[off+1]= 4.307; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,36)=6; atm(PTR_COORD,36)=off; env[off+0]=-0.047; env[off+1]= 4.991; env[off+2]=-5.150; off+=3; atm(CHARGE_OF,37)=6; atm(PTR_COORD,37)=off; env[off+0]=-0.047; env[off+1]= 5.485; env[off+2]=-3.857; off+=3; atm(CHARGE_OF,38)=6; atm(PTR_COORD,38)=off; env[off+0]= 1.136; env[off+1]= 5.324; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,39)=6; atm(PTR_COORD,39)=off; env[off+0]= 2.257; env[off+1]= 4.677; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,40)=6; atm(PTR_COORD,40)=off; env[off+0]= 3.441; env[off+1]= 2.626; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,41)=6; atm(PTR_COORD,41)=off; env[off+0]= 3.441; env[off+1]= 1.332; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,42)=6; atm(PTR_COORD,42)=off; env[off+0]= 2.989; env[off+1]= 0.226; env[off+2]=-3.857; off+=3; atm(CHARGE_OF,43)=6; atm(PTR_COORD,43)=off; env[off+0]= 2.561; env[off+1]= 0.473; env[off+2]=-5.150; off+=3; atm(CHARGE_OF,44)=6; atm(PTR_COORD,44)=off; env[off+0]= 1.376; env[off+1]=-0.210; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,45)=6; atm(PTR_COORD,45)=off; env[off+0]= 0.644; env[off+1]= 0.734; env[off+2]=-6.518; off+=3; atm(CHARGE_OF,46)=6; atm(PTR_COORD,46)=off; env[off+0]=-0.739; env[off+1]= 0.734; env[off+2]=-6.518; off+=3; atm(CHARGE_OF,47)=6; atm(PTR_COORD,47)=off; env[off+0]=-1.471; env[off+1]= 2.002; env[off+2]=-6.518; off+=3; atm(CHARGE_OF,48)=6; atm(PTR_COORD,48)=off; env[off+0]=-2.352; env[off+1]= 4.155; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,49)=6; atm(PTR_COORD,49)=off; env[off+0]=-3.084; env[off+1]= 2.887; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,50)=6; atm(PTR_COORD,50)=off; env[off+0]=-2.656; env[off+1]= 1.840; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,51)=6; atm(PTR_COORD,51)=off; env[off+0]=-2.656; env[off+1]= 0.473; env[off+2]=-5.150; off+=3; atm(CHARGE_OF,52)=6; atm(PTR_COORD,52)=off; env[off+0]=-1.471; env[off+1]=-0.210; env[off+2]=-5.673; off+=3; atm(CHARGE_OF,53)=6; atm(PTR_COORD,53)=off; env[off+0]=-0.779; env[off+1]=-1.104; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,54)=6; atm(PTR_COORD,54)=off; env[off+0]= 0.684; env[off+1]=-1.104; env[off+2]=-4.873; off+=3; atm(CHARGE_OF,55)=6; atm(PTR_COORD,55)=off; env[off+0]= 1.136; env[off+1]=-1.365; env[off+2]=-3.506; off+=3; atm(CHARGE_OF,56)=6; atm(PTR_COORD,56)=off; env[off+0]= 2.257; env[off+1]=-0.718; env[off+2]=-3.012; off+=3; atm(CHARGE_OF,57)=6; atm(PTR_COORD,57)=off; env[off+0]= 2.988; env[off+1]= 3.732; env[off+2]=-2.661; off+=3; atm(CHARGE_OF,58)=6; atm(PTR_COORD,58)=off; env[off+0]= 2.989; env[off+1]= 1.071; env[off+2]=-1.644; off+=3; atm(CHARGE_OF,59)=6; atm(PTR_COORD,59)=off; env[off+0]= 0.684; env[off+1]= 3.201; env[off+2]=-6.518; off+=3; // cc-pVDZ env[off+ 0] = 6665.0; // s env[off+ 1] = 1000.0; env[off+ 2] = 228.00; env[off+ 3] = 64.710; env[off+ 4] = 21.060; env[off+ 5] = 7.4950; env[off+ 6] = 2.7970; env[off+ 7] = 0.5215; env[off+ 8] = 0.000692*CINTgto_norm(0,env[off+0]); env[off+16] =-0.000146*CINTgto_norm(0,env[off+0]); env[off+ 9] = 0.005329*CINTgto_norm(0,env[off+1]); env[off+17] =-0.001154*CINTgto_norm(0,env[off+1]); env[off+10] = 0.027077*CINTgto_norm(0,env[off+2]); env[off+18] =-0.005725*CINTgto_norm(0,env[off+2]); env[off+11] = 0.101718*CINTgto_norm(0,env[off+3]); env[off+19] =-0.023312*CINTgto_norm(0,env[off+3]); env[off+12] = 0.274740*CINTgto_norm(0,env[off+4]); env[off+20] =-0.063955*CINTgto_norm(0,env[off+4]); env[off+13] = 0.448564*CINTgto_norm(0,env[off+5]); env[off+21] =-0.149981*CINTgto_norm(0,env[off+5]); env[off+14] = 0.285074*CINTgto_norm(0,env[off+6]); env[off+22] =-0.127262*CINTgto_norm(0,env[off+6]); env[off+15] = 0.015204*CINTgto_norm(0,env[off+7]); env[off+23] = 0.544529*CINTgto_norm(0,env[off+7]); env[off+24] = 0.1596; // s env[off+25] = 1*CINTgto_norm(0,env[off+24]); env[off+26] = 9.4390; // p env[off+27] = 2.0020; env[off+28] = 0.5456; env[off+29] = 0.038109*CINTgto_norm(1,env[off+26]); env[off+30] = 0.209480*CINTgto_norm(1,env[off+27]); env[off+31] = 0.508557*CINTgto_norm(1,env[off+28]); env[off+32] = 0.1517; // p env[off+33] = 1*CINTgto_norm(1,env[off+32]); env[off+34] = 0.55; // d env[off+35] = 1*CINTgto_norm(2,env[off+34]); for (i = 0, n = 0; i < natm; i++) { bas[ATOM_OF +BAS_SLOTS*n] = i; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 8; bas[NCTR_OF +BAS_SLOTS*n] = 2; bas[PTR_EXP +BAS_SLOTS*n] = off+0; bas[PTR_COEFF+BAS_SLOTS*n] = off+8; n++; bas[ATOM_OF +BAS_SLOTS*n] = i; bas[ANG_OF +BAS_SLOTS*n] = 0; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+24; bas[PTR_COEFF+BAS_SLOTS*n] = off+25; n++; bas[ATOM_OF +BAS_SLOTS*n] = i; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 3; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+26; bas[PTR_COEFF+BAS_SLOTS*n] = off+29; n++; bas[ATOM_OF +BAS_SLOTS*n] = i; bas[ANG_OF +BAS_SLOTS*n] = 1; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+32; bas[PTR_COEFF+BAS_SLOTS*n] = off+33; n++; bas[ATOM_OF +BAS_SLOTS*n] = i; bas[ANG_OF +BAS_SLOTS*n] = 2; bas[NPRIM_OF +BAS_SLOTS*n] = 1; bas[NCTR_OF +BAS_SLOTS*n] = 1; bas[PTR_EXP +BAS_SLOTS*n] = off+34; bas[PTR_COEFF+BAS_SLOTS*n] = off+35; n++; } nbas = n; run_all(atm, natm, bas, nbas, env); // 6478s on one core of 3.1G I5 CPU free(atm); free(bas); free(env); }
void PivotSnap::Snap(Object* pobj, IPoint2 *p, TimeValue t) { // This snap computes the bounding box points of a node as // well as the pivot point //local copy of the cursor position Point2 fp = Point2((float)p->x, (float)p->y); //In this snap mode we actually need to get a pointer to the node so that we // can check for WSM's and compute the pivot point INode *inode = theman->GetNode(); Matrix3 atm(1); //This will hold the nodes tm before WSMs //See if this guys has any spacewarps applied BOOL wsm = (BOOL) inode->GetProperty(PROPID_HAS_WSM); //If it does then we'll need to get a meaningful tm as follows if(wsm) atm = inode->GetObjTMBeforeWSM(t); //get the node's bounding box Box3 box; box.Init(); pobj->GetDeformBBox(t, box, NULL ); if(EssentiallyEmpty(box)) pobj->GetLocalBoundBox(t, inode, theman->GetVpt() , box); //We need a hitmesh which shows the bounding box of the node //This automatic variable gets passed to the hitmesh copy constructor // in every case HitMesh thehitmesh, *phitmesh; thehitmesh.setNumVerts(8); for(int jj = 0;jj<8;++jj) thehitmesh.setVert(jj,box[jj]); BOOL got_one= FALSE; //Compute all the hit point candidates if( GetActive(PIV_SUB)) { got_one = FALSE; Point3 *pivpt; //JH 10/02/01 //DID 296059 Matrix3 tm(1); Point3 pos = inode->GetObjOffsetPos(); tm.PreTranslate(pos); Quat quat = inode->GetObjOffsetRot(); PreRotateMatrix(tm, quat); ScaleValue scale = inode->GetObjOffsetScale(); ApplyScaling(tm, scale); Matrix3 InvTm = Inverse(tm); //JH 10/02/01 //atm contains the identity normally, or the node TM before spacewarps, when space warps are applied //We're computing a point relative to the node TM, so in the former case the inverse of //the object offset pos is what we want. In the latter (when the node TM is identtity, we must add //in the node TM before WSM. pivpt = new Point3(atm.GetTrans() + InvTm.GetTrans()); //Make a hitmesh phitmesh = new HitMesh(thehitmesh); //now register a hit with the osnap manager theman->RecordHit(new OsnapHit(*pivpt, this, PIV_SUB, phitmesh)); } if( GetActive(BBOX_SUB)) { //set up our highlight mesh for(int ii = 0;ii<8;++ii) { phitmesh = new HitMesh(thehitmesh); theman->RecordHit(new OsnapHit(box[ii], this, BBOX_SUB, phitmesh)); } } };
//===========================================================================// int main(int argc, char ** argv){ try{ //--- //--- create the utility class for parsing parameters //--- UtilParameters utilParam(argc, argv); bool doGenRandom = utilParam.GetSetting("doGenRandom", false); int randSeed = utilParam.GetSetting("randSeed", 1 ); int randNumAtms = utilParam.GetSetting("randNumAtms", 5 ); int randNumDates = utilParam.GetSetting("randNumDates", 10 ); bool doCut = utilParam.GetSetting("doCut", true); bool doPriceCut = utilParam.GetSetting("doPriceCut", false); bool doDirect = utilParam.GetSetting("doDirect", false); UtilTimer timer; double timeSetupReal = 0.0; double timeSetupCpu = 0.0; double timeSolveReal = 0.0; double timeSolveCpu = 0.0; //--- //--- start overall timer //--- timer.start(); if(doGenRandom){ //--- //--- generate a random instance //--- ATM_Instance instance; instance.generateRandom(randNumAtms, randNumDates, randSeed); } else{ //--- //--- create the user application (a DecompApp) //--- ATM_DecompApp atm(utilParam); //--- //--- create the algorithm (a DecompAlgo) //--- DecompAlgo * algo = NULL; assert(doCut + doPriceCut == 1); //--- //--- create the CPM algorithm object //--- if(doCut) algo = new DecompAlgoC(&atm, utilParam); //--- //--- create the PC algorithm object //--- if(doPriceCut) algo = new DecompAlgoPC(&atm, utilParam); if(doCut && doDirect){ timer.stop(); timeSetupCpu = timer.getCpuTime(); timeSetupReal = timer.getRealTime(); //--- //--- solve //--- timer.start(); algo->solveDirect(); timer.stop(); timeSolveCpu = timer.getCpuTime(); timeSolveReal = timer.getRealTime(); } else{ //--- //--- create the driver AlpsDecomp model //--- int status = 0; AlpsDecompModel alpsModel(utilParam, algo); timer.stop(); timeSetupCpu = timer.getCpuTime(); timeSetupReal = timer.getRealTime(); //--- //--- solve //--- timer.start(); status = alpsModel.solve(); timer.stop(); timeSolveCpu = timer.getCpuTime(); timeSolveReal = timer.getRealTime(); //TODO: move doDirect solve into alpsModel so access // solution the same way? //--- //--- sanity check //--- cout << setiosflags(ios::fixed|ios::showpoint); cout << "Status= " << status << " BestLB= " << setw(10) << UtilDblToStr(alpsModel.getGlobalLB(),2) << " BestUB= " << setw(10) << UtilDblToStr(alpsModel.getGlobalUB(),2) << " Nodes= " << setw(6) << alpsModel.getNumNodesProcessed() << " SetupCPU= " << timeSetupCpu << " SolveCPU= " << timeSolveCpu << " TotalCPU= " << timeSetupCpu + timeSolveCpu << " SetupReal= " << timeSetupReal << " SolveReal= " << timeSolveReal << " TotalReal= " << timeSetupReal + timeSolveReal << endl; //--- //--- now, initialize direct solve with best //--- solution to PC //--- TODO: only useful if stop early on time or nodes //--- TODO: cbc currently doesn't use warm-start, only cpx //--- //DecompAlgo * algoC = new DecompAlgoC(&atm, &utilParam); //algoC->solveDirect(algo->getXhatIPBest()); //delete algoC; } //--- //--- free local memory //--- delete algo; } } catch(CoinError & ex){ cerr << "COIN Exception [ " << ex.message() << " ]" << " at " << ex.fileName() << ":L" << ex.lineNumber() << " in " << ex.className() << "::" << ex.methodName() << endl; } return 0; }