Example #1
0
int main() {
	clock_t start, finish;
	double duration;
	start = clock();

    for (int i = 0; i <= M; ++i)
        Told[i] = 1 + (sigma - 1) * (xi(i) + L) / (2*L);

    d[0] = 1; du[0] = 0;
    d[M] = 1; dl[M-1] = 0;
    b[0] = 1; b[M] = sigma;
    for (int i = 1; i < M; ++i) {
        dl[i-1] = 1/(h*h) - v(alpha, xi(i))/(2*h);
        du[i] = 1/(h*h) + v(alpha, xi(i))/(2*h);
        d[i] = -2/(h*h);
        b[i] = -K*w(beta, Told[i]);
    }

    finish = clock();
    duration = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << "matrix construction time: " << duration << " sec\n";

	start = clock();

    lapack_int info = LAPACKE_dgtsv(LAPACK_COL_MAJOR, Neq, 1,
        dl, d, du, b, Neq);
    if (info != 0) {
        std::cout << "Error when solving a linear system, info = " << info << std::endl;
        exit(1);
    }
    for (int i = 0; i <= M; ++i)
        T[i] = b[i];

    finish = clock();
    duration = (double)(finish - start) / CLOCKS_PER_SEC;
    std::cout << "system solving time: " << duration << " sec\n";

    return 0;
}
Example #2
0
template <> inline
int gtsv(const char order, const int N, const int M, double *DL, double *D, double *DU, double *B, const int LDB)
{
	return LAPACKE_dgtsv(order, N, M, DL, D, DU, B, LDB);
}