void div_AOS_1D(double* p, double delta_t, int len, // input // because this functinon is called repeatedly by outside, so it's better // to let the caller manages the memory of the following variables double* alpha, double *beta, double *gamma, // inputs double* L, double *M, double *R) // outputs { double s = 9*delta_t; gamma[0] = -s*(p[0] + p[1])/2; beta[0] = gamma[0]; alpha[0] = 3 - gamma[0]; for(int i = 1; i < len-1; i++) { gamma[i] = -s*(p[i] + p[i+1])/2; beta[i] = gamma[i]; alpha[i] = 3 - (gamma[i-1] + beta[i]); } alpha[len-1] = 3 - beta[len-2]; // PRINT_MACRO(" alpha : ", alpha, len); // PRINT_MACRO(" beta : ", beta, len-1); // PRINT_MACRO(" gamma : ", gamma, len-1); ac_tridiagonal_Thomas_decomposition(alpha, beta, gamma, L, M, R, len); }
void div_AOS_1D(double delta_t, int len, // input // because this functinon is called repeatedly by outside, so it's better // to let the caller manages the memory of the following variables double* alpha, double *gamma, // inputs double* L, double *M, double *R) // outputs { double s = 4*delta_t; gamma[0] = -s; alpha[0] = 2 - gamma[0]; for(int i = 1; i < len-1; i++) { gamma[i] = -s; alpha[i] = 2 - (gamma[i-1] + gamma[i]); } alpha[len-1] = 2 - gamma[len-2]; ac_tridiagonal_Thomas_decomposition(alpha, gamma, gamma, L, M, R, len); }