dp_blas.tcc

来自「Flens库-一个在C++的矩阵运算库」· TCC 代码 · 共 76 行

TCC
76
字号
namespace flens {template <typename X>voiddp2d_copy(const GeMatrix<X> &x,  GeMatrix<X> &y){    int i0 = x.firstRow()+1;    int j0 = x.firstCol()+1;    int i1 = x.lastRow()-1;    int j1 = x.lastCol()-1;    for (int i=i0; i<=i1; ++i) {        for (int j=j0; j<=j1; ++j) {            y(i,j) = x(i,j);        }    }}template <typename X>voiddp2d_scal(double alpha, GeMatrix<X> &x){    int i0 = x.firstRow()+1;    int j0 = x.firstCol()+1;    int i1 = x.lastRow()-1;    int j1 = x.lastCol()-1;    for (int i=i0; i<=i1; ++i) {        for (int j=j0; j<=j1; ++j) {            x(i,j) *= alpha;        }    }}template <typename X, typename Y>doubledp2d_dot(const GeMatrix<X> &x, const GeMatrix<Y> &y){    int i0 = x.firstRow()+1;    int j0 = x.firstCol()+1;    int i1 = x.lastRow()-1;    int j1 = x.lastCol()-1;    double result = 0;    for (int i=i0; i<=i1; ++i) {        for (int j=j0; j<=j1; ++j) {            result += x(i,j)*y(i,j);        }    }    return result;}template <typename T, typename X, typename Y>voiddp2d_mv(int rh, T alpha, const GeMatrix<X> &x, T beta, GeMatrix<Y> &y){    int rhh = rh*rh;    int i0 = x.firstRow()+1;    int j0 = x.firstCol()+1;    int i1 = x.lastRow()-1;    int j1 = x.lastCol()-1;    for (int i=i0; i<=i1; ++i) {        for (int j=j0; j<=j1; ++j) {            y(i,j) = alpha*rhh*(4*x(i,j)-x(i-1,j)-x(i+1,j)-x(i,j-1)-x(i,j+1)) + beta*y(i,j);        }    }}} // namespace flens

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?